You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devicemap.apache.org by es...@apache.org on 2014/07/24 22:55:15 UTC
svn commit: r1613292 - in
/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap:
./ Data/ Loader/ My Project/ Parser/ Util/ bin/ obj/
Author: esjr
Date: Thu Jul 24 20:55:14 2014
New Revision: 1613292
URL: http://svn.apache.org/r1613292
Log: (empty)
Added:
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Constants.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Data/
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Data/Device.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Data/Pattern.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMap.vbproj
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMapClient.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMapException.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/FileLoader.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/ILoader.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/Loader.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/UrlLoader.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Application.Designer.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Application.myapp
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/AssemblyInfo.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Resources.Designer.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Resources.resx
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Settings.Designer.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Settings.settings
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Parser/
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Parser/XmlParser.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Util/
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Util/Util.vb
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/bin/
incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/obj/
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Constants.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Constants.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Constants.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Constants.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,22 @@
+Public Class Constants
+ Public Const APP_NAME As String = "DeviceMap"
+ ' data files
+ Public Const BUILDER_DATA As String = "BuilderDataSource.xml"
+ Public Const BUILDER_DATA_PATCH As String = "BuilderDataSourcePatch.xml"
+ Public Const DEVICE_DATA As String = "DeviceDataSource.xml"
+ Public Const DEVICE_DATA_PATCH As String = "DeviceDataSourcePatch.xml"
+
+ Public Const DEVICEMAP_UA As String = "org.apache.devicemap.client"
+
+ Public Const DEVICE_TOSTRING_FORMAT As String = "Id='{0}', ParentId='{1}', Type='{2}', Pattern={3}, Attributes={4}"
+ Public Const HTTP_PREFIX As String = "http"
+ Public Const RELEASE_VERSION As String = "1.0"
+ Public Const SIMPLE As String = "simple"
+ Public Const USER_AGENT_SPLIT As String = " |-|_|/|\\|\[|\]|\(|\)|;"
+ Public Const VERSION_FORMAT As String = "Version : {0}, Build : {1}"
+
+ Public Const CONFIG_ERROR_FORMAT As String = "Error in configuration file '{0}' : {1}."
+ Public Const CONFIG_ERROR_CONN_FORMAT As String = "Error in configuration file '{0}' : ConnectionString entry for DeviceMap is missing."
+ Public Const FILE_ERROR_FORMAT As String = "File '{0}' not found."
+ Public Const WEB_ERROR_FORMAT As String = "Web exception : {0}."
+End Class
\ No newline at end of file
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Data/Device.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Data/Device.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Data/Device.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Data/Device.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,118 @@
+#Region "Header"
+' 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.
+#End Region ' Header
+''' <summary>
+''' Device
+''' </summary>
+''' <author>eberhard speer jr.</author>
+''' <remarks>Apache's DeviceMap Project .Net version<br />
+''' ported from Reza Naghibi's Device.java</remarks>
+Public NotInheritable Class Device
+ '
+ Private builderType As String = String.Empty
+ Private deviceId As String = String.Empty
+ Private deviceParent As String = String.Empty
+ Private pattern As Pattern
+ Private properties As IDictionary(Of String, String)
+
+#Region "Properties"
+ ''' <summary>
+ ''' Property dictionary
+ ''' </summary>
+ ''' <returns>IDictionary(Of String, String)</returns>
+ ''' <remarks>-</remarks>
+ Public Property Attributes() As IDictionary(Of String, String)
+ Get
+ Return properties
+ End Get
+ Set(value As IDictionary(Of String, String))
+ properties = value
+ End Set
+ End Property
+ ''' <summary>
+ ''' Unique Id
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public Property Id() As String
+ Get
+ Return deviceId
+ End Get
+ Set(value As String)
+ deviceId = value
+ End Set
+ End Property
+ ''' <summary>
+ ''' Unique Parent Id
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public Property ParentId() As String
+ Get
+ Return deviceParent
+ End Get
+ Set(value As String)
+ deviceParent = value
+ End Set
+ End Property
+ ''' <summary cref="Pattern">
+ ''' Pattern collection
+ ''' </summary>
+ ''' <returns>Pattern</returns>
+ ''' <remarks>Collection of patterns for 'matching' with User-Agent string</remarks>
+ Public ReadOnly Property Patterns() As Pattern
+ Get
+ Return pattern
+ End Get
+ End Property
+ ''' <summary>
+ ''' Builder type
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>used to destinguish between 'simple' and 'two-step' device builders</remarks>
+ Public Property Type() As String
+ Get
+ Return builderType
+ End Get
+ Set(value As String)
+ builderType = value
+ End Set
+ End Property
+#End Region ' Properties
+
+#Region "Constructor"
+ ''' <summary>
+ ''' Default new Device
+ ''' </summary>
+ ''' <remarks>-</remarks>
+ Public Sub New()
+ pattern = New Pattern()
+ End Sub
+#End Region ' Constructor
+
+#Region "Functions"
+ ''' <summary>
+ ''' ToString override
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public Overrides Function ToString() As String
+ Return String.Format(Constants.DEVICE_TOSTRING_FORMAT, deviceId, deviceParent, builderType, pattern.ToString, properties.ToString)
+ End Function
+#End Region ' Functions
+End Class
\ No newline at end of file
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Data/Pattern.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Data/Pattern.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Data/Pattern.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Data/Pattern.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,119 @@
+#Region "Header"
+' 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.
+#End Region ' Header
+'
+Imports System.Text
+''' <summary>
+''' Device Pattern data
+''' </summary>
+''' <author>eberhard speer jr.</author>
+''' <remarks>Apache's DeviceMap Project .Net version<br />
+''' ported from Reza Naghibi's Pattern.java</remarks>
+Public NotInheritable Class Pattern
+ '
+ Private patternList As IList(Of IList(Of String))
+
+#Region "Properties"
+ ''' <summary>
+ ''' List of Patterns which <em>all</em> must occur in User-Agent string for a match
+ ''' </summary>
+ ''' <remarks>-</remarks>
+ Public WriteOnly Property AndPattern() As IList(Of String)
+ Set(value As IList(Of String))
+ patternList.Add(value)
+ End Set
+ End Property
+ ''' <summary>
+ ''' List of Patterns of which <em>at least one</em> must occur in User-Agent string for a match
+ ''' </summary>
+ ''' <remarks>-</remarks>
+ Public WriteOnly Property OrPattern() As IList(Of String)
+ Set(value As IList(Of String))
+ For Each patternString As String In value
+ Pattern = patternString
+ Next
+ End Set
+ End Property
+ ''' <summary>
+ ''' List of Patterns to match with User-Agent string
+ ''' </summary>
+ ''' <remarks>-</remarks>
+ Public WriteOnly Property Pattern() As String
+ Set(value As String)
+ Dim subList As New List(Of String)
+ subList.Add(value)
+ patternList.Add(subList)
+ End Set
+ End Property
+ ''' <summary>
+ ''' List of Patterns Lists to match with User-Agent string
+ ''' </summary>
+ ''' <returns>IList(Of IList(Of String))</returns>
+ ''' <remarks></remarks>
+ Public ReadOnly Property Patterns() As IList(Of IList(Of String))
+ Get
+ Return patternList
+ End Get
+ End Property
+#End Region ' Properties
+
+#Region "Constructor"
+ ''' <summary>
+ ''' Default new Device Pattern data
+ ''' </summary>
+ ''' <remarks>-</remarks>
+ Public Sub New()
+ patternList = New List(Of IList(Of String))
+ End Sub
+#End Region ' Constructor
+
+#Region "Functions"
+ ''' <summary>
+ ''' Returns true if one of the patterns in patternList occurs in Device Pattern data
+ ''' </summary>
+ ''' <param name="patternList">List(Of String)</param>
+ ''' <returns>Boolean</returns>
+ ''' <remarks>-</remarks>
+ Public Function isValid(patternList As List(Of String)) As Boolean
+ Dim found As Boolean = False
+ For Each patternset As IList(Of String) In Patterns
+ For Each pattern As String In patternset
+ If Not patternList.Contains(pattern) Then
+ GoTo patternsContinue
+ End If
+ Next
+ found = True
+ Exit For
+patternsContinue:
+ Next
+ Return found
+ End Function
+ ''' <summary>
+ ''' ToString override
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public Overrides Function ToString() As String
+ Dim builder As New StringBuilder
+ For Each sublist As List(Of String) In patternList
+ builder.AppendFormat("'{0}',", String.Join(",", sublist.ToArray()))
+ Next
+ Return builder.ToString.TrimEnd(CChar(","))
+ End Function
+#End Region ' Functions
+End Class
\ No newline at end of file
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMap.vbproj
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMap.vbproj?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMap.vbproj (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMap.vbproj Thu Jul 24 20:55:14 2014
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.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>{2B8A4B1A-ADDF-4A37-BAD2-C389D69858B0}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>DeviceMap</RootNamespace>
+ <AssemblyName>DeviceMap</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ <MyType>Windows</MyType>
+ <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <DefineDebug>true</DefineDebug>
+ <DefineTrace>true</DefineTrace>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DocumentationFile>DeviceMap.xml</DocumentationFile>
+ <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <DefineDebug>false</DefineDebug>
+ <DefineTrace>true</DefineTrace>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DocumentationFile>DeviceMap.xml</DocumentationFile>
+ <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup>
+ <OptionExplicit>On</OptionExplicit>
+ </PropertyGroup>
+ <PropertyGroup>
+ <OptionCompare>Binary</OptionCompare>
+ </PropertyGroup>
+ <PropertyGroup>
+ <OptionStrict>On</OptionStrict>
+ </PropertyGroup>
+ <PropertyGroup>
+ <OptionInfer>On</OptionInfer>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>false</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>DeviceMap.pfx</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.configuration" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ </ItemGroup>
+ <ItemGroup>
+ <Import Include="Microsoft.VisualBasic" />
+ <Import Include="System" />
+ <Import Include="System.Collections" />
+ <Import Include="System.Collections.Generic" />
+ <Import Include="System.Data" />
+ <Import Include="System.Diagnostics" />
+ <Import Include="System.Linq" />
+ <Import Include="System.Xml.Linq" />
+ <Import Include="System.Threading.Tasks" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Constants.vb" />
+ <Compile Include="Data\Device.vb" />
+ <Compile Include="Data\Pattern.vb" />
+ <Compile Include="DeviceMapClient.vb" />
+ <Compile Include="DeviceMapException.vb" />
+ <Compile Include="Loader\FileLoader.vb" />
+ <Compile Include="Loader\ILoader.vb" />
+ <Compile Include="Loader\Loader.vb" />
+ <Compile Include="Loader\UrlLoader.vb" />
+ <Compile Include="My Project\AssemblyInfo.vb" />
+ <Compile Include="My Project\Application.Designer.vb">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Application.myapp</DependentUpon>
+ </Compile>
+ <Compile Include="My Project\Resources.Designer.vb">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <Compile Include="My Project\Settings.Designer.vb">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ <Compile Include="Parser\XmlParser.vb" />
+ <Compile Include="Util\Util.vb" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="My Project\Resources.resx">
+ <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.vb</LastGenOutput>
+ <CustomToolNamespace>My.Resources</CustomToolNamespace>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="DeviceMap.pfx" />
+ <None Include="My Project\Application.myapp">
+ <Generator>MyApplicationCodeGenerator</Generator>
+ <LastGenOutput>Application.Designer.vb</LastGenOutput>
+ </None>
+ <None Include="My Project\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <CustomToolNamespace>My</CustomToolNamespace>
+ <LastGenOutput>Settings.Designer.vb</LastGenOutput>
+ </None>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.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/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMapClient.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMapClient.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMapClient.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMapClient.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,168 @@
+#Region "Header"
+' 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.
+#End Region ' Header
+'
+Imports System.Reflection
+Imports System.Text.RegularExpressions
+''' <summary>
+''' DeviceMap User-Agent Mapper
+''' </summary>
+''' <author>eberhard speer jr.</author>
+''' <remarks>Apache's DeviceMap Project .Net version<br />
+''' ported from Reza Naghibi's DeviceMapClient.java</remarks>
+Public Class DeviceMapClient
+ '
+ Public devices As IDictionary(Of String, Device)
+ Friend patterns As IDictionary(Of String, List(Of Device))
+
+#Region "Properties"
+ ''' <summary>
+ ''' Main Release and build version
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public ReadOnly Property Version As String
+ Get
+ Return String.Format(Constants.VERSION_FORMAT, Constants.RELEASE_VERSION, Assembly.GetExecutingAssembly().GetName().Version.ToString)
+ End Get
+ End Property
+ ''' <summary>
+ ''' Returns number of Devices in Device data
+ ''' </summary>
+ ''' <returns>Integer</returns>
+ ''' <remarks>-</remarks>
+ Public ReadOnly Property DeviceCount() As Integer
+ Get
+ Return devices.Count
+ End Get
+ End Property
+ ''' <summary>
+ ''' Returns number of Device Patterns in Device pattern data
+ ''' </summary>
+ ''' <returns>Integer</returns>
+ ''' <remarks>-</remarks>
+ Public ReadOnly Property PatternCount() As Integer
+ Get
+ Return patterns.Count
+ End Get
+ End Property
+#End Region ' Properties
+
+#Region "Constructor"
+ ''' <summary>
+ ''' New Device User-Agent Resolver
+ ''' </summary>
+ ''' <exception cref="DeviceMapException">Thrown when (InnerException)<ul>
+ ''' <li>NullReferenceException : DeviceMap ConnectionStrings missing in config file</li>
+ ''' <li>WebException : URL Loader exception</li>
+ ''' <li>ArgumentException : File Loader exception</li>
+ ''' <li>ArgumentException : Loader exception</li>
+ ''' </ul>
+ ''' </exception>
+ ''' <remarks>-</remarks>
+ Public Sub New()
+ devices = New Dictionary(Of String, Device)
+ patterns = New Dictionary(Of String, List(Of Device))
+ devices = New Loader().Devices
+ CreateIndex()
+ End Sub
+#End Region ' Constructor
+
+#Region "Methods"
+ ''' <summary>
+ ''' Create Device and Pattern Index
+ ''' </summary>
+ ''' <remarks>-</remarks>
+ Private Sub CreateIndex()
+ For Each device As Device In devices.Values()
+ For Each patternset As IList(Of String) In device.Patterns.Patterns
+ For i As Integer = 0 To patternset.Count - 1
+ Dim pattern As String = patternset(i)
+ ' deal with duplicates
+ If patterns.ContainsKey(pattern) Then
+ If i = (patternset.Count - 1) AndAlso Not patterns(pattern).Contains(device) Then
+ patterns(pattern).Add(device)
+ End If
+ Else
+ Dim subList As New List(Of Device)
+ subList.Add(device)
+ If patterns.ContainsKey(pattern) Then
+ patterns(pattern) = subList
+ Else
+ patterns.Add(pattern, subList)
+ End If
+ End If
+ Next
+ Next
+ Next
+ End Sub
+#End Region ' Methods
+
+#Region "Functions"
+ ''' <summary>
+ ''' Main Resolver function : Returns Attribute dictionary for device resolved from useragent
+ ''' </summary>
+ ''' <param name="useragent">user-agnet string to resolve</param>
+ ''' <returns>IDictionary(Of String, String)</returns>
+ ''' <remarks>-</remarks>
+ Public Function Map(useragent As String) As IDictionary(Of String, String)
+ '' added ;
+ Dim parts As String() = Regex.Split(useragent, Constants.USER_AGENT_SPLIT)
+ Dim hits As New Dictionary(Of String, IList(Of Device))
+ For i As Integer = 0 To parts.Length - 1
+ Dim pattern As String = ""
+ Dim j As Integer = 0
+ While j < 4 AndAlso (j + i) < parts.Length
+ If Not String.IsNullOrEmpty(parts(i + j)) Then
+ pattern &= Util.Normalize(parts(i + j))
+ If patterns.ContainsKey(pattern) Then
+ hits(pattern) = patterns(pattern)
+ End If
+ End If
+ j += 1
+ End While
+ Next
+ Dim winner As Device = Nothing
+ Dim winnerStr As String = String.Empty
+ For Each hit As String In hits.Keys
+ For Each device As Device In hits(hit)
+ If device.Patterns.isValid(hits.Keys.ToList) Then
+ If winner IsNot Nothing Then
+ If Constants.SIMPLE.Equals(winner.Type) AndAlso Not Constants.SIMPLE.Equals(device.Type) Then
+ winner = device
+ winnerStr = hit
+ ''ElseIf hit.Length > winnerStr.Length AndAlso Not "simple".Equals(device.Type) Then
+ ElseIf hit.Length > winnerStr.Length AndAlso (Not Constants.SIMPLE.Equals(device.Type) OrElse device.Type.Equals(winner.Type)) Then
+ winner = device
+ winnerStr = hit
+ End If
+ Else
+ winner = device
+ winnerStr = hit
+ End If
+ End If
+ Next
+ Next
+ If winner IsNot Nothing Then
+ Return winner.Attributes
+ Else
+ Return Nothing
+ End If
+ End Function
+#End Region ' Functions
+End Class
\ No newline at end of file
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMapException.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMapException.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMapException.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/DeviceMapException.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,36 @@
+#Region "Header"
+' 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.
+#End Region ' Header
+''' <summary>
+''' DeviceMap Exception
+''' </summary>
+''' <remarks>-</remarks>
+<Serializable>
+Public NotInheritable Class DeviceMapException : Inherits ApplicationException
+ '
+#Region "Constructors"
+ ''' <summary>
+ ''' DeviceMap Exception
+ ''' </summary>
+ ''' <param name="msg">Message</param>
+ ''' <remarks>-</remarks>
+ Public Sub New(msg As String, ex As Exception)
+ MyBase.New(msg, ex)
+ End Sub
+#End Region ' Constructors
+End Class
\ No newline at end of file
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/FileLoader.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/FileLoader.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/FileLoader.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/FileLoader.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,81 @@
+#Region "Header"
+' 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.
+#End Region ' Header
+'
+Imports System.IO
+''' <summary>
+''' Load XML resources from local file
+''' </summary>
+''' <remarks>-</remarks>
+Friend NotInheritable Class FileLoader : Implements ILoader
+ '
+ Private Property resLength As Long = -1
+ Private Property resReader As IO.StreamReader = Nothing
+ Private Property resUrl As String = String.Empty
+ '
+#Region "Properties"
+ ''' <summary>
+ ''' Resource path
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public ReadOnly Property Path As String Implements ILoader.Path
+ Get
+ Return resUrl
+ End Get
+ End Property
+ ''' <summary>
+ ''' Returns the resource file length
+ ''' </summary>
+ ''' <returns>Long</returns>
+ ''' <remarks>file length</remarks>
+ Public ReadOnly Property ResponseLength As Long Implements ILoader.ResponseLength
+ Get
+ Return resLength
+ End Get
+ End Property
+ ''' <summary>
+ ''' Reader
+ ''' </summary>
+ ''' <returns>StreamReader</returns>
+ ''' <remarks>-</remarks>
+ Public ReadOnly Property Reader() As IO.StreamReader Implements ILoader.Reader
+ Get
+ Return resReader
+ End Get
+ End Property
+#End Region ' Properties
+
+#Region "Constructor"
+ ''' <summary>
+ ''' Load resource for path string
+ ''' </summary>
+ ''' <param name="filePath">path and file name of resource file</param>
+ ''' <exception cref="ArgumentException">thrown when file does not exist</exception>
+ ''' <remarks>-</remarks>
+ Public Sub New(filePath As String)
+ resUrl = filePath.Trim
+ If IO.File.Exists(resUrl) Then
+ resLength = New IO.FileInfo(filePath).Length
+ resReader = New IO.StreamReader(resUrl)
+ Else
+ Throw New ArgumentException(String.Format(Constants.FILE_ERROR_FORMAT, resUrl))
+ End If
+ End Sub
+#End Region ' Constructor
+End Class
\ No newline at end of file
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/ILoader.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/ILoader.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/ILoader.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/ILoader.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,41 @@
+#Region "Header"
+' 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.
+#End Region ' Header
+'
+Imports System.IO
+'
+Public Interface ILoader
+ ''' <summary>
+ ''' Resource URI
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ ReadOnly Property Path As String
+ ''' <summary>
+ ''' Response Lenght
+ ''' </summary>
+ ''' <returns>Long</returns>
+ ''' <remarks>-</remarks>
+ ReadOnly Property ResponseLength As Long
+ ''' <summary>
+ ''' Reader
+ ''' </summary>
+ ''' <returns>StreamReader</returns>
+ ''' <remarks>-</remarks>
+ ReadOnly Property Reader As StreamReader
+End Interface
\ No newline at end of file
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/Loader.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/Loader.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/Loader.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/Loader.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,224 @@
+#Region "Header"
+' 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.
+#End Region ' Header
+'
+Imports System.Configuration
+Imports System.IO
+''' <summary>
+''' Load Device and Pattern data from StreamReader
+''' </summary>
+''' <author>eberhard speer jr.</author>
+''' <remarks>-</remarks>
+Friend NotInheritable Class Loader
+ '
+ Private Property deviceList As IDictionary(Of String, Device)
+
+#Region "Properties"
+ ''' <summary>
+ ''' Returns Device data dictionary
+ ''' </summary>
+ ''' <returns>IDictionary(Of String, Device)</returns>
+ ''' <remarks>-</remarks>
+ Public ReadOnly Property Devices() As IDictionary(Of String, Device)
+ Get
+ Return deviceList
+ End Get
+ End Property
+#End Region ' Properties
+
+#Region "Constructor"
+ ''' <summary>
+ ''' Default new Device data Loader
+ ''' </summary>
+ ''' <exception cref="DeviceMapException">Thrown when (InnerException)<ul>
+ ''' <li>NullReferenceException : DeviceMap ConnectionStrings missing in config file</li>
+ ''' <li>WebException : URL Loader exception</li>
+ ''' <li>ArgumentException : File Loader exception</li>
+ ''' <li>ArgumentException : Loader exception</li>
+ ''' </ul>
+ ''' </exception>
+ ''' <remarks>-</remarks>
+ Public Sub New()
+ deviceList = New Dictionary(Of String, Device)
+ Try
+ Dim folder As String = ConfigurationManager.ConnectionStrings(Constants.APP_NAME).ToString.Trim.ToLowerInvariant
+ If folder.StartsWith(Constants.HTTP_PREFIX) Then
+ folder = folder.TrimEnd(CChar("/"))
+ ' Devices
+ For Each xmlFile In {Constants.DEVICE_DATA, Constants.DEVICE_DATA_PATCH}
+ LoadDeviceData(New UrlLoader(String.Format("{0}/{1}", folder, xmlFile)).Reader)
+ Next
+ ' Patterns
+ For Each xmlFile In {Constants.BUILDER_DATA, Constants.BUILDER_DATA_PATCH}
+ LoadDevicePatterns(New UrlLoader(String.Format("{0}/{1}", folder, xmlFile)).Reader)
+ Next
+ Else
+ folder = folder.TrimEnd(CChar("\"))
+ ' Devices
+ For Each xmlFile In {Constants.DEVICE_DATA, Constants.DEVICE_DATA_PATCH}
+ LoadDeviceData(New FileLoader(String.Format("{0}/{1}", folder, xmlFile)).Reader)
+ Next
+ ' Patterns
+ For Each xmlFile In {Constants.BUILDER_DATA, Constants.BUILDER_DATA_PATCH}
+ LoadDevicePatterns(New FileLoader(String.Format("{0}/{1}", folder, xmlFile)).Reader)
+ Next
+ End If
+ Catch ex As NullReferenceException
+ Throw New DeviceMapException(String.Format(Constants.CONFIG_ERROR_CONN_FORMAT, AppDomain.CurrentDomain.SetupInformation.ConfigurationFile), ex)
+ Catch ex As System.Net.WebException
+ Throw New DeviceMapException(String.Format(Constants.WEB_ERROR_FORMAT, ex.Message), ex)
+ Catch ex As ArgumentException
+ Throw New DeviceMapException(ex.Message, ex)
+ Catch ex As Exception
+ Throw New DeviceMapException(ex.Message, ex)
+ End Try
+ End Sub
+#End Region ' Constructor
+
+#Region "Methods"
+ ''' <summary>
+ ''' Load Device data from StreamReader
+ ''' </summary>
+ ''' <param name="inSteam">StreamReader</param>
+ ''' <remarks>-</remarks>
+ Private Sub LoadDeviceData(inSteam As IO.StreamReader)
+ Dim parser As New XmlParser(inSteam)
+ Dim tag As String = String.Empty
+ Try
+ Dim device As New Device()
+ Dim attributes As New Dictionary(Of String, String)
+ While (Util.InlineAssignHelper(tag, parser.NextTag)).Length > 0
+ If tag.StartsWith("<device ") Then
+ device.Id = XmlParser.getAttribute(tag, "id")
+ device.ParentId = XmlParser.getAttribute(tag, "parentId")
+ ElseIf tag.Equals("</device>") Then
+ If Not String.IsNullOrEmpty(device.Id) Then
+ attributes("id") = device.Id
+ device.Attributes = attributes
+ If Devices.ContainsKey(device.Id) Then
+ Devices(device.Id) = device
+ Else
+ Devices.Add(device.Id, device)
+ End If
+ End If
+ ' reset
+ device = New Device()
+ attributes = New Dictionary(Of String, String)
+ ElseIf tag.StartsWith("<property ") Then
+ Dim key As String = XmlParser.getAttribute(tag, "name")
+ Dim value As String = XmlParser.getAttribute(tag, "value")
+ attributes(key) = value
+ End If
+ End While
+ Catch ex As Exception
+ Throw New ArgumentException(String.Format("loadDeviceData : {0}", ex.Message), ex)
+ End Try
+ End Sub
+ ''' <summary>
+ ''' Load Device Pattern data from StreamReader
+ ''' </summary>
+ ''' <param name="inStream">StreamReader</param>
+ ''' <remarks></remarks>
+ Private Sub LoadDevicePatterns(inStream As IO.StreamReader)
+ Dim parser As New XmlParser(inStream)
+ Dim tag As String = ""
+ Try
+ Dim builder As String = ""
+ Dim device As Device = Nothing
+ Dim id As String = ""
+ Dim patterns As New List(Of String)
+ While (Util.InlineAssignHelper(tag, parser.NextTag)).Length > 0
+ If tag.StartsWith("<builder ") Then
+ builder = XmlParser.getAttribute(tag, "class")
+ If builder.LastIndexOf(".") >= 0 Then
+ builder = builder.Substring(builder.LastIndexOf(".") + 1)
+ End If
+ ElseIf tag.StartsWith("<device ") Then
+ device = Devices(XmlParser.getAttribute(tag, "id"))
+ ElseIf tag.Equals("</device>") Then
+ If device IsNot Nothing Then
+ If builder.Equals("TwoStepDeviceBuilder") Then
+ device.Patterns.AndPattern = patterns
+ Dim unigram As String = ""
+ For Each pattern As String In patterns
+ If pattern.Contains(unigram) Then
+ unigram = pattern
+ Else
+ unigram &= pattern
+ End If
+ Next
+ device.Patterns.Pattern = unigram
+ Else
+ device.Patterns.OrPattern = patterns
+ End If
+ If builder.Equals("SimpleDeviceBuilder") Then
+ device.Type = "simple"
+ Else
+ device.Type = "weak"
+ End If
+ Else
+ Util.Log("ERROR: device not found: '" & id & "'")
+ End If
+ ' reset
+ device = Nothing
+ id = ""
+ patterns = New List(Of String)()
+ ElseIf tag.Equals("<value>") Then
+ Dim pattern As String = Util.Normalize(parser.TagValue)
+ If String.IsNullOrEmpty(pattern) Then
+ Continue While
+ End If
+ patterns.Add(pattern)
+ End If
+ End While
+ Catch ex As Exception
+ Throw New ArgumentException(String.Format("loadDevicePatterns : {0}", ex.Message), ex)
+ End Try
+ End Sub
+ ''' <summary>
+ ''' Recursively add Device's Parent Attributes
+ ''' </summary>
+ ''' <param name="device">Device</param>
+ ''' <remarks>-</remarks>
+ Private Sub MergeParent(device As Device)
+ Dim parentId As String = device.ParentId
+ If String.IsNullOrEmpty(parentId) Then
+ Return
+ End If
+ Dim parent As Device = Nothing
+ If Not deviceList.TryGetValue(parentId, parent) Then
+ Return
+ End If
+ MergeParent(parent)
+ For Each key As String In parent.Attributes.Keys
+ If Not device.Attributes.ContainsKey(key) Then
+ device.Attributes(key) = parent.Attributes(key)
+ End If
+ Next
+ End Sub
+ ''' <summary>
+ ''' Sets Parent device attributes
+ ''' </summary>
+ ''' <remarks>-</remarks>
+ Private Sub setParentAttributes()
+ For Each device As Device In deviceList.Values
+ MergeParent(device)
+ Next
+ End Sub
+#End Region ' Methods
+End Class
\ No newline at end of file
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/UrlLoader.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/UrlLoader.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/UrlLoader.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Loader/UrlLoader.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,90 @@
+#Region "Header"
+' 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.
+#End Region ' Header
+'
+Imports System.Net
+''' <summary>
+''' Load XML resources from URL
+''' </summary>
+''' <remarks>-</remarks>
+Friend NotInheritable Class UrlLoader : Implements ILoader
+ '
+ Private Property resLength As Long = -1
+ Private Property resReader As IO.StreamReader = Nothing
+ Private Property resUrl As String = String.Empty
+ '
+#Region "Properties"
+ ''' <summary>
+ ''' Resource URI
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public ReadOnly Property Path As String Implements ILoader.Path
+ Get
+ Return resUrl
+ End Get
+ End Property
+ ''' <summary>
+ ''' Response Lenght
+ ''' </summary>
+ ''' <returns>Long</returns>
+ ''' <remarks>-</remarks>
+ Public ReadOnly Property ResponseLenght As Long Implements ILoader.ResponseLength
+ Get
+ Return resLength
+ End Get
+ End Property
+ ''' <summary>
+ ''' Reader
+ ''' </summary>
+ ''' <returns>StreamReader</returns>
+ ''' <remarks>-</remarks>
+ Public ReadOnly Property Reader() As IO.StreamReader Implements ILoader.Reader
+ Get
+ Return resReader
+ End Get
+ End Property
+#End Region ' Properties
+
+#Region "Constructor"
+ ''' <summary>
+ ''' Load resource for url string
+ ''' </summary>
+ ''' <param name="url">String</param>
+ ''' <exception cref="ArgumentException">thrown when HTTP Status-code is not 200 [ok]</exception>
+ ''' <remarks>-</remarks>
+ Public Sub New(url As String)
+ resUrl = url.Trim
+ Dim resStatus As Integer = 0
+ Dim ddrRequest As HttpWebRequest = CType(WebRequest.Create(New Uri(resUrl)), HttpWebRequest)
+ ddrRequest.UserAgent = String.Format("{0} {1}", Constants.DEVICEMAP_UA, Constants.RELEASE_VERSION)
+ ddrRequest.AllowAutoRedirect = False
+ Dim ddrResponse As WebResponse = ddrRequest.GetResponse()
+ resStatus = CType(ddrResponse, HttpWebResponse).StatusCode
+ Select Case resStatus
+ Case 200
+ resLength = ddrResponse.ContentLength
+ resReader = New System.IO.StreamReader(ddrResponse.GetResponseStream())
+ Case Is > 299
+ Throw New ArgumentException(String.Format("HTTP Status code : {0}", resStatus.ToString))
+ Case Else
+ Throw New ArgumentException(String.Format("Weird HTTP Status code : {0}", resStatus.ToString))
+ End Select
+ End Sub
+#End Region ' Constructor
+End Class
\ No newline at end of file
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Application.Designer.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My%20Project/Application.Designer.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Application.Designer.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Application.Designer.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,13 @@
+'------------------------------------------------------------------------------
+' <auto-generated>
+' This code was generated by a tool.
+' Runtime Version:4.0.30319.34209
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+' </auto-generated>
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Application.myapp
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My%20Project/Application.myapp?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Application.myapp (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Application.myapp Thu Jul 24 20:55:14 2014
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <MySubMain>false</MySubMain>
+ <SingleInstance>false</SingleInstance>
+ <ShutdownMode>0</ShutdownMode>
+ <EnableVisualStyles>true</EnableVisualStyles>
+ <AuthenticationMode>0</AuthenticationMode>
+ <ApplicationType>1</ApplicationType>
+ <SaveMySettingsOnExit>true</SaveMySettingsOnExit>
+</MyApplicationData>
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/AssemblyInfo.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My%20Project/AssemblyInfo.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/AssemblyInfo.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/AssemblyInfo.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,34 @@
+Imports System
+Imports System.Reflection
+Imports 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.
+
+' Review the values of the assembly attributes
+<Assembly: AssemblyTitle("DeviceMap")>
+<Assembly: AssemblyDescription(".Net version of DeviceMap")>
+<Assembly: AssemblyCompany("ASF")>
+<Assembly: AssemblyProduct("DeviceMap")>
+<Assembly: AssemblyCopyright("Copyright © ASF 2013")>
+<Assembly: AssemblyTrademark("")>
+<Assembly: CLSCompliant(True)>
+<Assembly: ComVisible(False)>
+
+'The following GUID is for the ID of the typelib if this project is exposed to COM
+<Assembly: Guid("11f5c6ab-cc22-490a-9143-406a384d8617")>
+
+' 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/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Resources.Designer.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My%20Project/Resources.Designer.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Resources.Designer.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Resources.Designer.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,62 @@
+'------------------------------------------------------------------------------
+' <auto-generated>
+' This code was generated by a tool.
+' Runtime Version:4.0.30319.34209
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+' </auto-generated>
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
+
+Namespace My.Resources
+
+ 'This class was auto-generated by the StronglyTypedResourceBuilder
+ 'class via a tool like ResGen or Visual Studio.
+ 'To add or remove a member, edit your .ResX file then rerun ResGen
+ 'with the /str option, or rebuild your VS project.
+ '''<summary>
+ ''' A strongly-typed resource class, for looking up localized strings, etc.
+ '''</summary>
+ <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
+ Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
+ Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
+ Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
+ Friend Module Resources
+
+ Private resourceMan As Global.System.Resources.ResourceManager
+
+ Private resourceCulture As Global.System.Globalization.CultureInfo
+
+ '''<summary>
+ ''' Returns the cached ResourceManager instance used by this class.
+ '''</summary>
+ <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
+ Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
+ Get
+ If Object.ReferenceEquals(resourceMan, Nothing) Then
+ Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("DeviceMap.Resources", GetType(Resources).Assembly)
+ resourceMan = temp
+ End If
+ Return resourceMan
+ End Get
+ End Property
+
+ '''<summary>
+ ''' Overrides the current thread's CurrentUICulture property for all
+ ''' resource lookups using this strongly typed resource class.
+ '''</summary>
+ <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
+ Friend Property Culture() As Global.System.Globalization.CultureInfo
+ Get
+ Return resourceCulture
+ End Get
+ Set(ByVal value As Global.System.Globalization.CultureInfo)
+ resourceCulture = value
+ End Set
+ End Property
+ End Module
+End Namespace
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Resources.resx
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My%20Project/Resources.resx?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Resources.resx (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Resources.resx Thu Jul 24 20:55:14 2014
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Settings.Designer.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My%20Project/Settings.Designer.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Settings.Designer.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Settings.Designer.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,73 @@
+'------------------------------------------------------------------------------
+' <auto-generated>
+' This code was generated by a tool.
+' Runtime Version:4.0.30319.34209
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+' </auto-generated>
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
+
+Namespace My
+
+ <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
+ Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0"), _
+ Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
+ Partial Friend NotInheritable Class MySettings
+ Inherits Global.System.Configuration.ApplicationSettingsBase
+
+ Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
+
+#Region "My.Settings Auto-Save Functionality"
+#If _MyType = "WindowsForms" Then
+ Private Shared addedHandler As Boolean
+
+ Private Shared addedHandlerLockObject As New Object
+
+ <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
+ Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
+ If My.Application.SaveMySettingsOnExit Then
+ My.Settings.Save()
+ End If
+ End Sub
+#End If
+#End Region
+
+ Public Shared ReadOnly Property [Default]() As MySettings
+ Get
+
+#If _MyType = "WindowsForms" Then
+ If Not addedHandler Then
+ SyncLock addedHandlerLockObject
+ If Not addedHandler Then
+ AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
+ addedHandler = True
+ End If
+ End SyncLock
+ End If
+#End If
+ Return defaultInstance
+ End Get
+ End Property
+ End Class
+End Namespace
+
+Namespace My
+
+ <Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
+ Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
+ Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
+ Friend Module MySettingsProperty
+
+ <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
+ Friend ReadOnly Property Settings() As Global.DeviceMap.My.MySettings
+ Get
+ Return Global.DeviceMap.My.MySettings.Default
+ End Get
+ End Property
+ End Module
+End Namespace
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Settings.settings
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My%20Project/Settings.settings?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Settings.settings (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/My Project/Settings.settings Thu Jul 24 20:55:14 2014
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile>
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Parser/XmlParser.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Parser/XmlParser.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Parser/XmlParser.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Parser/XmlParser.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,139 @@
+#Region "Header"
+' 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.
+#End Region ' Header
+'
+Imports System.Text
+''' <summary>
+''' XML Parser
+''' </summary>
+''' <author>eberhard speer jr.</author>
+''' <remarks>Apache's DeviceMap Project .Net version<br />
+''' ported from Reza Naghibi's XMLParser.java</remarks>
+Friend NotInheritable Class XmlParser
+ '
+ Private inStream As IO.StreamReader
+ Private pre As Char = ChrW(0)
+
+#Region "Properties"
+ ''' <summary>
+ ''' Returns next XML tag in StreamReader
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public ReadOnly Property NextTag() As String
+ Get
+ Dim localBuilder As New StringBuilder()
+
+ Dim i As Integer
+ Dim start As Boolean = False
+
+ If pre = "<"c Then
+ localBuilder.Append(pre)
+ pre = ChrW(0)
+ start = True
+ End If
+
+ While (Util.InlineAssignHelper(i, inStream.Read())) <> -1
+ Dim c As Char = ChrW(i)
+ If c = "<"c Then
+ start = True
+ localBuilder.Append(c)
+ ElseIf c = ">"c Then
+ localBuilder.Append(c)
+ Exit While
+ ElseIf start Then
+ localBuilder.Append(c)
+ End If
+ End While
+
+ Return localBuilder.ToString()
+ End Get
+ End Property
+ ''' <summary>
+ ''' Returns XML tag value from StreamReader
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public ReadOnly Property TagValue() As String
+ Get
+ Dim localBuilder As New StringBuilder()
+ Dim i As Integer
+ While (Util.InlineAssignHelper(i, inStream.Read())) <> -1
+ Dim c As Char = ChrW(i)
+ If c = "<"c Then
+ pre = "<"c
+ Exit While
+ Else
+ localBuilder.Append(c)
+ End If
+ End While
+ Return localBuilder.ToString.Trim()
+ End Get
+ End Property
+#End Region ' Properties
+
+#Region "Constructor"
+ ''' <summary>
+ ''' Prevent parameterless new
+ ''' </summary>
+ ''' <remarks>-</remarks>
+ Private Sub New()
+ ' Nice !
+ End Sub
+ ''' <summary>
+ ''' New XmlParser for StreamReader
+ ''' </summary>
+ ''' <param name="stream">StreamReader</param>
+ ''' <remarks>-</remarks>
+ Public Sub New(stream As IO.StreamReader)
+ inStream = stream
+ End Sub
+#End Region ' Constructor
+
+#Region "Functions"
+ ''' <summary>
+ ''' Returns Attribute (Device property) value of tag with name
+ ''' </summary>
+ ''' <param name="tag">XML tag</param>
+ ''' <param name="name">Attribute name</param>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public Shared Function getAttribute(tag As String, name As String) As String
+ Dim retpos As Integer = tag.ToLower.IndexOf(name.ToLower() & "=")
+ If retpos = -1 Then
+ Return ""
+ End If
+ Dim result As String = tag.Substring(retpos + name.Length + 1)
+ If result.StartsWith("""") Then
+ result = result.Substring(1)
+ Dim endpos As Integer = result.IndexOf("""")
+ If endpos = -1 Then
+ Return ""
+ End If
+ result = result.Substring(0, endpos)
+ Else
+ Dim endpos As Integer = result.IndexOf(" ")
+ If endpos = -1 Then
+ Return ""
+ End If
+ result = result.Substring(0, endpos)
+ End If
+ Return result
+ End Function
+#End Region ' Functions
+End Class
\ No newline at end of file
Added: incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Util/Util.vb
URL: http://svn.apache.org/viewvc/incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Util/Util.vb?rev=1613292&view=auto
==============================================================================
--- incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Util/Util.vb (added)
+++ incubator/devicemap/tags/releases/devicemap-vbnet-incubating-1.0.0/DeviceMap/Util/Util.vb Thu Jul 24 20:55:14 2014
@@ -0,0 +1,132 @@
+#Region "Header"
+' 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.
+#End Region ' Header
+'
+Imports System.Text
+''' <summary>
+''' Utilities
+''' </summary>
+''' <author>eberhard speer jr.</author>
+''' <remarks>Apache's DeviceMap Project .Net version
+''' ported from Reza Naghibi's Util.java</remarks>
+Public NotInheritable Class Util
+ ''' <summary>
+ ''' Inline Assign Helper
+ ''' </summary>
+ ''' <remarks>-</remarks>
+ Public Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
+ target = value
+ Return value
+ End Function
+ ''' <summary>
+ ''' Console debug messages
+ ''' </summary>
+ ''' <param name="msg">message</param>
+ ''' <remarks>-</remarks>
+ Public Shared Sub Log(msg As String)
+ Log(msg, Nothing)
+ End Sub
+ ''' <summary>
+ ''' Console debug exception messages
+ ''' </summary>
+ ''' <param name="msg">message</param>
+ ''' <param name="e">Exception</param>
+ ''' <remarks>-</remarks>
+ Public Shared Sub Log(msg As String, e As Exception)
+ Console.WriteLine(String.Format("{0} - {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff"), msg))
+ If e IsNot Nothing Then
+ Console.WriteLine("Exception")
+ Console.WriteLine(ExceptionToString("console", e))
+ End If
+ End Sub
+ ''' <summary>
+ ''' Normailze pattern to letters and digits only
+ ''' </summary>
+ ''' <param name="dirty">string to normalize</param>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public Shared Function Normalize(dirty As String) As String
+ If String.IsNullOrEmpty(dirty) Then
+ Return dirty
+ End If
+ dirty = dirty.ToLower.Trim.Replace("[bb]", "b")
+ Dim builder As New StringBuilder()
+ For i As Integer = 0 To dirty.Length - 1
+ Dim c As System.Nullable(Of Char) = dirty(i)
+ If Char.IsLetter(CChar(c)) OrElse Char.IsDigit(CChar(c)) Then
+ builder.Append(c)
+ End If
+ Next
+ Return builder.ToString()
+ End Function
+ ''' <summary>
+ ''' Log Object to Application Log
+ ''' </summary>
+ ''' <param name="entryStr">String</param>
+ ''' <param name="type">EventLogEntryType</param>
+ ''' <remarks></remarks>
+ Public Shared Sub WriteEntry(appName As String, entryStr As String, Optional type As EventLogEntryType = EventLogEntryType.Warning, Optional ex As Exception = Nothing)
+ Using myLog As New Diagnostics.EventLog()
+ myLog.Source = appName
+ If Not Diagnostics.EventLog.SourceExists(myLog.Source) Then
+ Diagnostics.EventLog.CreateEventSource(myLog.Source, "Application")
+ End If
+ If ex IsNot Nothing Then
+ entryStr = String.Format("{0} : {1}", entryStr, ExceptionToString("ex", ex))
+ End If
+ Dim btText() As Byte = Encoding.UTF8.GetBytes(entryStr)
+ If btText.Length > 32766 Then
+ ' The message string is longer than 32766 bytes.
+ entryStr = BitConverter.ToString(btText, 0, 32760)
+ End If
+ myLog.WriteEntry(entryStr, type)
+ End Using
+ End Sub
+ ''' <summary>
+ ''' Exception to string
+ ''' </summary>
+ ''' <param name="id">some id</param>
+ ''' <param name="ex">Exception</param>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Private Shared Function ExceptionToString(id As String, ex As Exception) As String
+ Dim result As New StringBuilder()
+ If Not String.IsNullOrEmpty(id) Then
+ result.AppendLine(String.Format("Id : {0}", id))
+ End If
+ result.AppendLine(String.Format("Message : {0}", ex.Message))
+ If Not ex.Data.Count = 0 Then
+ result.AppendLine("Data : ")
+ For Each de As DictionaryEntry In ex.Data
+ result.AppendLine(de.Key.ToString)
+ Next
+ End If
+ result.AppendLine(String.Format("Source : {0}", ex.Source))
+ result.AppendLine(String.Format("TargetSite : {0}", ex.TargetSite.ToString))
+ result.AppendLine(String.Format("StackTrace : {0}", ex.StackTrace))
+ Return result.ToString
+ End Function
+ ''' <summary>
+ ''' Returns directory of config file of running assembly
+ ''' </summary>
+ ''' <returns>String</returns>
+ ''' <remarks>-</remarks>
+ Public Shared Function Home() As String
+ Return New IO.FileInfo(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile).DirectoryName
+ End Function
+End Class
\ No newline at end of file