Author: esjr
Date: Tue Jul 9 03:46:29 2013
New Revision: 1501055
URL: http://svn.apache.org/r1501055
Log: (empty)
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap.sln
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap.v11.suo
(with props)
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/Constants.cs
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/DeviceMap.csproj
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/DeviceMapClient.cs
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/Properties/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/Properties/AssemblyInfo.cs
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/bin/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/data/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/data/Device.cs
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/data/Pattern.cs
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/dmap.pfx
(with props)
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/loaders/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/loaders/FileLoader.cs
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/loaders/Loader.cs
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/obj/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/obj/Debug/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
(with props)
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/parser/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/parser/XmlParser.cs
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/util/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/util/Util.cs
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/App.config
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/DeviceMapConsole.csproj
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/Program.cs
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/Properties/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/Properties/AssemblyInfo.cs
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/bin/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/bin/Debug/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/obj/
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/obj/Debug/
incubator/devicemap/trunk/devicemapcsharp/ReadMe
Added: incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap.sln
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap.sln?rev=1501055&view=auto
==============================================================================
--- incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap.sln (added)
+++ incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap.sln Tue Jul
9 03:46:29 2013
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceMap",
"DeviceMap\DeviceMap.csproj", "{D3B37884-D622-4132-8700-C93ADF2A5304}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceMapConsole",
"DeviceMapConsole\DeviceMapConsole.csproj",
"{74AC7942-317D-4BAC-B2C6-8A6BFAC2CBCB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D3B37884-D622-4132-8700-C93ADF2A5304}.Debug|Any CPU.ActiveCfg
= Debug|Any CPU
+ {D3B37884-D622-4132-8700-C93ADF2A5304}.Debug|Any CPU.Build.0 =
Debug|Any CPU
+ {D3B37884-D622-4132-8700-C93ADF2A5304}.Release|Any
CPU.ActiveCfg = Release|Any CPU
+ {D3B37884-D622-4132-8700-C93ADF2A5304}.Release|Any CPU.Build.0
= Release|Any CPU
+ {74AC7942-317D-4BAC-B2C6-8A6BFAC2CBCB}.Debug|Any CPU.ActiveCfg
= Debug|Any CPU
+ {74AC7942-317D-4BAC-B2C6-8A6BFAC2CBCB}.Debug|Any CPU.Build.0 =
Debug|Any CPU
+ {74AC7942-317D-4BAC-B2C6-8A6BFAC2CBCB}.Release|Any
CPU.ActiveCfg = Release|Any CPU
+ {74AC7942-317D-4BAC-B2C6-8A6BFAC2CBCB}.Release|Any CPU.Build.0
= Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Added: incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap.v11.suo
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap.v11.suo?rev=1501055&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap.v11.suo
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/Constants.cs
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/Constants.cs?rev=1501055&view=auto
==============================================================================
--- incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/Constants.cs
(added)
+++ incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/Constants.cs
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeviceMap
+{
+ public sealed class Constants
+ {
+ public const string VERSION = "0.1";
+ }
+}
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/DeviceMap.csproj
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/DeviceMap.csproj?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/DeviceMap.csproj
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/DeviceMap.csproj
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import
Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{D3B37884-D622-4132-8700-C93ADF2A5304}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>DeviceMap</RootNamespace>
+ <AssemblyName>DeviceMap</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU'
">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>dmap.pfx</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Constants.cs" />
+ <Compile Include="data\Device.cs" />
+ <Compile Include="data\Pattern.cs" />
+ <Compile Include="DeviceMapClient.cs" />
+ <Compile Include="loaders\FileLoader.cs" />
+ <Compile Include="loaders\Loader.cs" />
+ <Compile Include="parser\XmlParser.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="util\Util.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="dmap.pfx" />
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <ProjectExtensions>
+ <VisualStudio>
+ <UserProperties BuildVersion_UpdateAssemblyVersion="True"
BuildVersion_UpdateFileVersion="True" BuildVersion_UseGlobalSettings="True"
BuildVersion_UseUniversalClock="True" />
+ </VisualStudio>
+ </ProjectExtensions>
+ <!-- To modify your build process, add your task inside one of the targets
below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/DeviceMapClient.cs
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/DeviceMapClient.cs?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/DeviceMapClient.cs
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/DeviceMapClient.cs
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,168 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.RegularExpressions;
+/// <summary>
+/// @author : eberhard speer jr.
+/// .Net version of Reza Naghibi's DeviceMapClient.java
+/// </summary>
+public sealed class DeviceMapClient
+{
+ internal IDictionary<string, Device> devices;
+
+ internal IDictionary<string, List<Device>> patterns;
+
+ public int DeviceCount
+ {
+ get
+ {
+ return this.devices.Count;
+ }
+ }
+
+ public int PatternCount
+ {
+ get
+ {
+ return this.patterns.Count;
+ }
+ }
+
+ public DeviceMapClient()
+ {
+ this.devices = new Dictionary<string, Device>();
+ this.patterns = new Dictionary<string, List<Device>>();
+ }
+
+ private void createIndex()
+ {
+ foreach (Device device in devices.Values)
+ {
+ foreach (IList<string> patternset in device.Patterns.Patterns)
+ {
+ for (int i = 0; i <= patternset.Count - 1; i++)
+ {
+ string pattern = patternset[i];
+
+ if (patterns.ContainsKey(pattern))
+ {
+ if (i == (patternset.Count - 1) &&
!patterns[pattern].Contains(device))
+ {
+ patterns[pattern].Add(device);
+ }
+ }
+ else
+ {
+ List<Device> solo = new List<Device>();
+ solo.Add(device);
+ if (patterns.ContainsKey(pattern))
+ {
+ patterns[pattern] = solo;
+ }
+ else
+ {
+ patterns.Add(pattern, solo);
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+
+ public void loadFromFolder(string folder)
+ {
+ this.devices = FileLoader.dataFolder(folder);
+ this.createIndex();
+ }
+
+
+ public IDictionary<string, string> Map(string useragent)
+ {
+ if (string.IsNullOrEmpty(useragent))
+ {
+ return null;
+ }
+
+ Dictionary<string, IList<Device>> hits = new Dictionary<string,
IList<Device>>();
+ Device winner = null;
+ string winnerStr = string.Empty;
+ string[] parts = Regex.Split(useragent, "
|-|_|/|\\\\|\\[|\\]|\\(|\\)|;");
+
+ for (int i = 0; i <= parts.Length - 1; i++)
+ {
+ if (!string.IsNullOrEmpty(parts[i]))
+ {
+ string pattern = "";
+ int j = 0;
+ while (j < 4 && (j + i) < parts.Length)
+ {
+ pattern += Util.normalize(parts[i + j]);
+ if (patterns.ContainsKey(pattern))
+ {
+ hits[pattern] = patterns[pattern];
+ }
+ j += 1;
+ }
+ }
+ }
+
+ foreach (string hit in hits.Keys)
+ {
+ foreach (Device device in hits[hit])
+ {
+ if (device.Patterns.isValid(hits.Keys.ToList()))
+ {
+ if (winner != null)
+ {
+ if ("simple".Equals(winner.Type) &&
!"simple".Equals(device.Type))
+ {
+ winner = device;
+ winnerStr = hit;
+ }
+ else if (hit.Length > winnerStr.Length &&
!"simple".Equals(device.Type))
+ {
+ winner = device;
+ winnerStr = hit;
+ }
+ }
+ else
+ {
+ winner = device;
+ winnerStr = hit;
+ }
+ }
+ }
+ }
+
+ if (winner != null)
+ {
+ return winner.Attributes;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+}
\ No newline at end of file
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/Properties/AssemblyInfo.cs
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/Properties/AssemblyInfo.cs?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/Properties/AssemblyInfo.cs
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/Properties/AssemblyInfo.cs
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("DeviceMap")]
+[assembly: AssemblyDescription(".Net version of DeviceMap Client")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("ASF")]
+[assembly: AssemblyProduct("DeviceMap")]
+[assembly: AssemblyCopyright("Copyright © ASF 2013")]
+[assembly: AssemblyTrademark("dmap_20130709")]
+[assembly: AssemblyCulture("")]
+[assembly: System.CLSCompliant(true)]
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed
to COM
+[assembly: Guid("c5308144-8def-4189-bcac-768e3a07ca5e")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision
Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.7.9.15")]
+[assembly: AssemblyFileVersion("1.7.9.15")]
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/data/Device.cs
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/data/Device.cs?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/data/Device.cs
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/data/Device.cs
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,104 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+using System;
+using System.Collections.Generic;
+/// <summary>
+/// @author : eberhard speer jr.
+/// .Net version of Reza Naghibi's Device.java
+/// </summary>
+internal sealed class Device
+{
+ private string deviceId;
+
+ private string deviceParent;
+
+ private string builderType;
+
+ private Pattern pattern;
+
+ private IDictionary<string, string> properties;
+
+ public IDictionary<string, string> Attributes
+ {
+ get
+ {
+ return this.properties;
+ }
+ set
+ {
+ this.properties = value;
+ }
+ }
+
+ public string Id
+ {
+ get
+ {
+ return this.deviceId;
+ }
+ set
+ {
+ this.deviceId = value;
+ }
+ }
+
+ public string ParentId
+ {
+ get
+ {
+ return this.deviceParent;
+ }
+ set
+ {
+ this.deviceParent = value;
+ }
+ }
+
+ public Pattern Patterns
+ {
+ get
+ {
+ return this.pattern;
+ }
+ }
+
+ public string Type
+ {
+ get
+ {
+ return this.builderType;
+ }
+ set
+ {
+ this.builderType = value;
+ }
+ }
+
+ public Device()
+ {
+ this.deviceParent = string.Empty;
+ this.pattern = new Pattern();
+ }
+
+ public override string ToString()
+ {
+ string[] str = new string[] { "id='", this.deviceId, "',parentId='",
this.deviceParent, "',type='", this.builderType, "',pattern=",
Convert.ToString(this.pattern), ",attribytes=",
Convert.ToString(this.properties), "." };
+ return string.Concat(str);
+ }
+}
\ No newline at end of file
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/data/Pattern.cs
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/data/Pattern.cs?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/data/Pattern.cs
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/data/Pattern.cs
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,97 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+using System;
+using System.Collections;
+using System.Collections.Generic;
+/// <summary>
+/// @author : eberhard speer jr.
+/// .Net version of Reza Naghibi's Pattern.java
+/// </summary>
+internal class Pattern
+{
+
+ private IList<IList<string>> patterns;
+
+ public Pattern()
+ {
+ patterns = new List<IList<string>>();
+ }
+
+ public override string ToString()
+ {
+ return patterns.ToString();
+ }
+
+ public virtual IList<string> AndPattern
+ {
+ set
+ {
+ this.patterns.Add(value);
+ }
+ }
+
+ public virtual IList<string> OrPattern
+ {
+ set
+ {
+ foreach (string pattern in value)
+ {
+ AddPattern = pattern;
+ }
+ }
+ }
+
+ public virtual string AddPattern
+ {
+ set
+ {
+ IList<string> subList = new List<string>();
+ subList.Add(value);
+ patterns.Add(subList);
+ }
+ }
+
+ public virtual IList<IList<string>> Patterns
+ {
+ get
+ {
+ return patterns;
+ }
+ }
+
+ public virtual bool isValid(List<string> patterns)
+ {
+ bool found = false;
+ foreach (IList<string> patternset in Patterns)
+ {
+ foreach (string pattern in patternset)
+ {
+ if (!patterns.Contains(pattern))
+ {
+ goto patternsContinue;
+ }
+ }
+ found = true;
+ break;
+ patternsContinue: ;
+ }
+ return found;
+ }
+
+}
\ No newline at end of file
Added: incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/dmap.pfx
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/dmap.pfx?rev=1501055&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/dmap.pfx
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/loaders/FileLoader.cs
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/loaders/FileLoader.cs?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/loaders/FileLoader.cs
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/loaders/FileLoader.cs
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,72 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+using System;
+using System.Collections.Generic;
+using System.IO;
+/// <summary>
+/// @author : eberhard speer jr.
+/// .Net version of Reza Naghibi's FileLoader.java
+/// </summary>
+internal sealed class FileLoader
+{
+ public FileLoader()
+ {
+ }
+
+ public static IDictionary<string, Device> dataFolder(string folder)
+ {
+ Loader loader = new Loader();
+ string deviceData = Path.Combine(folder, "DeviceDataSource.xml");
+ string devicePatch = Path.Combine(folder, "DeviceDataSourcePatch.xml");
+ string builderData = Path.Combine(folder, "BuilderDataSource.xml");
+ string builderPatch = Path.Combine(folder,
"BuilderDataSourcePatch.xml");
+ using (StreamReader reader = new StreamReader(deviceData))
+ {
+ loader.loadDeviceData(reader);
+ }
+ if (File.Exists(devicePatch))
+ {
+ using (StreamReader reader = new StreamReader(devicePatch))
+ {
+ loader.loadDeviceData(reader);
+ }
+ }
+ else
+ {
+ Util.debugLog(string.Concat("WARNING: file not found ",
devicePatch));
+ }
+ loader.setParentAttributes();
+ using (StreamReader bin = new StreamReader(builderData))
+ {
+ loader.loadDevicePatterns(bin);
+ }
+ if (File.Exists(devicePatch))
+ {
+ using (StreamReader reader = new StreamReader(builderPatch))
+ {
+ loader.loadDevicePatterns(reader);
+ }
+ }
+ else
+ {
+ Util.debugLog(string.Concat("WARNING: file not found ",
builderPatch));
+ }
+ return loader.Devices;
+ }
+}
\ No newline at end of file
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/loaders/Loader.cs
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/loaders/Loader.cs?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/loaders/Loader.cs
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/loaders/Loader.cs
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,246 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+/// <summary>
+/// @author : eberhard speer jr.
+/// .Net version of Reza Naghibi's Loader.java
+/// </summary>
+internal sealed class Loader
+{
+ private IDictionary<string, Device> deviceList;
+
+ public IDictionary<string, Device> Devices
+ {
+ get
+ {
+ return this.deviceList;
+ }
+ }
+
+ public Loader()
+ {
+ this.deviceList = new Dictionary<string, Device>();
+ }
+
+ private static T InlineAssignHelper<T>(ref T target, T value)
+ {
+ target = value;
+ return value;
+ }
+
+ public void loadDeviceData(StreamReader inSteam)
+ {
+ XmlParser parser = new XmlParser(inSteam);
+ string tag = string.Empty;
+ try
+ {
+ Device device = new Device();
+ IDictionary<string, string> attributes = new Dictionary<string,
string>();
+ while (Loader.InlineAssignHelper<string>(ref tag,
parser.NextTag).Length > 0)
+ {
+ if (tag.StartsWith("<device "))
+ {
+ device.Id = XmlParser.getAttribute(tag, "id");
+ device.ParentId = XmlParser.getAttribute(tag, "parentId");
+ }
+ else if (!tag.Equals("</device>"))
+ {
+ if (!tag.StartsWith("<property "))
+ {
+ continue;
+ }
+ string key = XmlParser.getAttribute(tag, "name");
+ attributes[key] = XmlParser.getAttribute(tag, "value");
+ }
+ else
+ {
+ if (device.Id != null && !string.IsNullOrEmpty(device.Id))
+ {
+ attributes["id"] = device.Id;
+ device.Attributes = attributes;
+ if (!this.Devices.ContainsKey(device.Id))
+ {
+ this.Devices.Add(device.Id, device);
+ }
+ else
+ {
+ this.Devices[device.Id] = device;
+ }
+ }
+ device = new Device();
+ attributes = new Dictionary<string, string>();
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ Exception ex = exception;
+ Util.debugLog(string.Concat("ERROR: loadDeviceData ",
ex.ToString()), ex);
+ }
+ }
+
+ public void loadDevicePatterns(StreamReader inStream)
+ {
+ XmlParser parser = new XmlParser(inStream);
+ string tag = "";
+ try
+ {
+ string builder = "";
+ Device device = null;
+ string id = "";
+ IList<string> patterns = new List<string>();
+ while (Loader.InlineAssignHelper<string>(ref tag,
parser.NextTag).Length > 0)
+ {
+ if (tag.StartsWith("<builder "))
+ {
+ builder = XmlParser.getAttribute(tag, "class");
+ if (builder.LastIndexOf(".") < 0)
+ {
+ continue;
+ }
+ builder =
builder.Substring(checked(builder.LastIndexOf(".") + 1));
+ }
+ else if (tag.StartsWith("<device "))
+ {
+ device = this.Devices[XmlParser.getAttribute(tag, "id")];
+ }
+ else if (!tag.Equals("</device>"))
+ {
+ if (!tag.Equals("<value>"))
+ {
+ continue;
+ }
+ string pattern = Util.normalize(parser.TagValue);
+ if (pattern.Length == 0)
+ {
+ continue;
+ }
+ patterns.Add(pattern);
+ }
+ else
+ {
+ if (device == null)
+ {
+ Util.debugLog(string.Concat("ERROR: device not found:
'", id, "'"));
+ }
+ else
+ {
+ if (builder.Equals("TwoStepDeviceBuilder"))
+ {
+ device.Patterns.AndPattern = patterns;
+
+ string unigram = "";
+
+ foreach (string pattern in patterns)
+ {
+ if (pattern.Contains(unigram))
+ {
+ unigram = pattern;
+ }
+ else
+ {
+ unigram += pattern;
+ }
+ }
+
+ device.Patterns.AddPattern = unigram;
+ }
+ else
+ {
+ device.Patterns.OrPattern = patterns;
+ }
+
+
+ if (!builder.Equals("SimpleDeviceBuilder"))
+ {
+ device.Type = "weak";
+ }
+ else
+ {
+ device.Type = "simple";
+ }
+ }
+ device = null;
+ id = "";
+ patterns = new List<string>();
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ Exception ex = exception;
+ Util.debugLog(string.Concat("ERROR: loadDevicePatterns ",
ex.ToString()), ex);
+ }
+ }
+
+ private void mergeParent(Device device)
+ {
+ string parentId = device.ParentId;
+
+ if (string.IsNullOrEmpty(parentId))
+ {
+ return;
+ }
+
+ Device parent = null;
+
+ if (!deviceList.TryGetValue(parentId, out parent))
+ {
+ return;
+ }
+
+ mergeParent(parent);
+
+ foreach (string key in parent.Attributes.Keys)
+ {
+ if (!device.Attributes.ContainsKey(key))
+ {
+ device.Attributes[key] = parent.Attributes[key];
+ }
+ }
+ }
+
+
+ /// <summary>
+ /// Sets attributes from parents
+ /// </summary>
+ public void setParentAttributes()
+ {
+ IEnumerator<Device> enumerator = null;
+ try
+ {
+ enumerator = this.deviceList.Values.GetEnumerator();
+ while (enumerator.MoveNext())
+ {
+ Device device = enumerator.Current;
+ this.mergeParent(device);
+ }
+ }
+ finally
+ {
+ if (enumerator != null)
+ {
+ enumerator.Dispose();
+ }
+ }
+ }
+}
\ No newline at end of file
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache?rev=1501055&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/parser/XmlParser.cs
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/parser/XmlParser.cs?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/parser/XmlParser.cs
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/parser/XmlParser.cs
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,139 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+using System;
+using System.IO;
+using System.Text;
+/// <summary>
+/// @author : eberhard speer jr.
+/// .Net version of Reza Naghibi's XMLParser.java
+/// </summary>
+internal sealed class XmlParser
+{
+ private StreamReader inStream;
+
+ private char pre;
+
+ public string NextTag
+ {
+ get
+ {
+ int i = 0;
+ StringBuilder localBuilder = new StringBuilder();
+ bool start = false;
+ if (this.pre == '<')
+ {
+ localBuilder.Append(this.pre);
+ this.pre = '\0';
+ start = true;
+ }
+ while (XmlParser.InlineAssignHelper<int>(ref i,
this.inStream.Read()) != -1)
+ {
+ char c = (char)i; // Strings.ChrW(i);
+ if (c == '<')
+ {
+ start = true;
+ localBuilder.Append(c);
+ }
+ else if (c != '>')
+ {
+ if (!start)
+ {
+ continue;
+ }
+ localBuilder.Append(c);
+ }
+ else
+ {
+ localBuilder.Append(c);
+ break;
+ }
+ }
+ return localBuilder.ToString();
+ }
+ }
+
+ public string TagValue
+ {
+ get
+ {
+ int i = 0;
+ StringBuilder localBuilder = new StringBuilder();
+ while (XmlParser.InlineAssignHelper<int>(ref i,
this.inStream.Read()) != -1)
+ {
+ char c = (char)i;
+ if (c != '<')
+ {
+ localBuilder.Append(c);
+ }
+ else
+ {
+ this.pre = '<';
+ break;
+ }
+ }
+ return localBuilder.ToString().Trim();
+ }
+ }
+
+ private XmlParser()
+ {
+ }
+
+ public XmlParser(StreamReader str)
+ {
+ this.inStream = str;
+ this.pre = '\0';
+ }
+
+ public static string getAttribute(string tag, string name)
+ {
+ int retpos = tag.ToLower().IndexOf(string.Concat(name.ToLower(), "="));
+ if (retpos == -1)
+ {
+ return "";
+ }
+ string ret = tag.Substring(checked(checked(retpos + name.Length) + 1));
+ if (!ret.StartsWith("\""))
+ {
+ int endpos = ret.IndexOf(" ");
+ if (endpos == -1)
+ {
+ return "";
+ }
+ ret = ret.Substring(0, endpos);
+ }
+ else
+ {
+ ret = ret.Substring(1);
+ int endpos = ret.IndexOf("\"");
+ if (endpos == -1)
+ {
+ return "";
+ }
+ ret = ret.Substring(0, endpos);
+ }
+ return ret;
+ }
+
+ private static T InlineAssignHelper<T>(ref T target, T value)
+ {
+ target = value;
+ return value;
+ }
+}
\ No newline at end of file
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/util/Util.cs
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/util/Util.cs?rev=1501055&view=auto
==============================================================================
--- incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/util/Util.cs
(added)
+++ incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMap/util/Util.cs
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,67 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+using System;
+using System.Text;
+/// <summary>
+/// @author : eberhard speer jr.
+/// .Net version of Reza Naghibi's Util.java
+/// </summary>
+internal sealed class Util
+{
+ public Util()
+ {
+ }
+
+ public static void debugLog(string msg)
+ {
+ Util.debugLog(msg, null);
+ }
+
+ public static void debugLog(string msg, Exception e)
+ {
+ string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff");
+ Console.WriteLine(string.Concat(date, " [dmapjclient] ", msg));
+ if (e != null)
+ {
+ Console.WriteLine(e.ToString());
+ Console.Write(e.StackTrace);
+ }
+ }
+
+ public static string normalize(string p)
+ {
+ if (p == null)
+ {
+ return p;
+ }
+ p = p.ToLower().Trim();
+ p = p.Replace("[bb]", "b");
+ StringBuilder ret = new StringBuilder();
+ int length = checked(p.Length - 1);
+ for (int i = 0; i <= length; i++)
+ {
+ char? c = p[i];
+ if (char.IsLetter((char)c) || char.IsDigit((char)c))
+ {
+ ret.Append(c);
+ }
+ }
+ return ret.ToString();
+ }
+}
\ No newline at end of file
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/App.config
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/App.config?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/App.config
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/App.config
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+ </startup>
+</configuration>
\ No newline at end of file
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/DeviceMapConsole.csproj
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/DeviceMapConsole.csproj?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/DeviceMapConsole.csproj
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/DeviceMapConsole.csproj
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import
Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{74AC7942-317D-4BAC-B2C6-8A6BFAC2CBCB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>DeviceMapConsole</RootNamespace>
+ <AssemblyName>DeviceMapConsole</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU'
">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\DeviceMap\DeviceMap.csproj">
+ <Project>{d3b37884-d622-4132-8700-c93adf2a5304}</Project>
+ <Name>DeviceMap</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets
below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/Program.cs
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/Program.cs?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/Program.cs
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/Program.cs
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DMapConsole
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine(string.Format("DeviceMap .Net Client {0}",
DeviceMap.Constants.VERSION));
+
+ DeviceMapClient client = new DeviceMapClient();
+
+ System.Diagnostics.Stopwatch stopWatch = new
System.Diagnostics.Stopwatch();
+ stopWatch.Start();
+ // set path to your path to OpenDDR XML resources
+ client.loadFromFolder(("C:\\esdev\\Ddr\\OpenDDR\\resources"));
+
+ stopWatch.Stop();
+ Console.WriteLine(string.Format("Loaded {0} devices with {1}
patterns in {2} ms", client.DeviceCount.ToString(),
client.PatternCount.ToString(),
stopWatch.Elapsed.TotalMilliseconds.ToString()));
+
+ classify(client, "Mozilla/5.0 (Linux; U; Android 2.2; en; HTC Aria
A6380 Build/ERE27) AppleWebKit/540.13+ (KHTML, like Gecko) Version/3.1 Mobile
Safari/524.15.0");
+ classify(client, "Mozilla/5.0 (Linux; U; Android 2.2; en; HTC Aria
A6380 Build/ERE27) AppleWebKit/540.13+ (KHTML, like Gecko) Version/3.1 Mobile
Safari/524.15.0");
+ //classify(client, "Mozilla/5.0 (Linux; U; Android 2.2; en; HTC
Aria A6380 Build/ERE27) AppleWebKit/540.13+ (KHTML, like Gecko) Version/3.1
Mobile Safari/524.15.0")
+ //classify(client, "Mozilla/5.0 (iPad; U; CPU OS 4_3_5 like Mac OS
X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8L1")
+ //classify(client, "Mozilla/5.0 (BlackBerry; U; BlackBerry 9810;
en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.261 Mobile
Safari/534.11+")
+ //classify(client, "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like
Mac OS X; en-us) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/23.0.1271.91
Mobile/10A403 Safari/8536.25")
+ //classify(client, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT
6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR
3.0.30729; Media Center PC 6.0; MDDC; .NET4.0C; IPH 1.1.21.4019;
AskTbORJ/5.13.1.18107)")
+ classify(client, "Mozilla/5.0 (SymbianOS/9.3; Series60/3.2
NokiaC5-00/032.010; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/525
(KHTML, like Gecko) Version/3.0 BrowserNG/7.2.5.2");
+ classify(client, "Browser Mozilla/4.0 (compatible; MSIE 7.0;
Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; SAMSUNG; SGH-i917)");
+
+ Console.ReadKey();
+ }
+
+ public static void classify(DeviceMapClient client, string text)
+ {
+ System.Diagnostics.Stopwatch stopWatch = new
System.Diagnostics.Stopwatch();
+ stopWatch.Start();
+
+ IDictionary<string, string> ret = client.Map(text);
+ stopWatch.Stop();
+ string deviceId = "unknown";
+ if (ret != null)
+ {
+ deviceId = ret["id"];
+ }
+ Console.WriteLine("Result: " + deviceId + " took " +
stopWatch.Elapsed.TotalMilliseconds.ToString() + " ms");
+ }
+ }
+}
\ No newline at end of file
Added:
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/Properties/AssemblyInfo.cs
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/Properties/AssemblyInfo.cs?rev=1501055&view=auto
==============================================================================
---
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/Properties/AssemblyInfo.cs
(added)
+++
incubator/devicemap/trunk/devicemapcsharp/DeviceMap/DeviceMapConsole/Properties/AssemblyInfo.cs
Tue Jul 9 03:46:29 2013
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("DeviceMapConsole")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("DeviceMapConsole")]
+[assembly: AssemblyCopyright("Copyright © 2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed
to COM
+[assembly: Guid("f815ffcd-e663-4400-a711-41200f94ef4a")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision
Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Added: incubator/devicemap/trunk/devicemapcsharp/ReadMe
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapcsharp/ReadMe?rev=1501055&view=auto
==============================================================================
--- incubator/devicemap/trunk/devicemapcsharp/ReadMe (added)
+++ incubator/devicemap/trunk/devicemapcsharp/ReadMe Tue Jul 9 03:46:29 2013
@@ -0,0 +1,3 @@
+Device Map .Net Client
+
+.Net version of Device Map Java Client
\ No newline at end of file