diff --git a/Examples/All Profiles/Program.cs b/Examples/All Profiles/Program.cs index 6efdff1..80b4afd 100644 --- a/Examples/All Profiles/Program.cs +++ b/Examples/All Profiles/Program.cs @@ -179,7 +179,7 @@ static string getProfileValues(Profile profile, Property property) static void Main(string[] args) { - string fileName = args.Length > 0 ? args[0] : "../../../../../data/51Degrees-LiteV3.2.dat"; + string fileName = args.Length > 0 ? args[0] : "../../../../data/51Degrees-LiteV3.2.dat"; Run(fileName); // Waits for a character to be pressed. diff --git a/Examples/Find Profiles/Program.cs b/Examples/Find Profiles/Program.cs index 0c01c9b..b95cc6b 100644 --- a/Examples/Find Profiles/Program.cs +++ b/Examples/Find Profiles/Program.cs @@ -83,7 +83,7 @@ public static void Run(string fileName) static void Main(string[] args) { - string fileName = args.Length > 0 ? args[0] : "../../../../../data/51Degrees-LiteV3.2.dat"; + string fileName = args.Length > 0 ? args[0] : "../../../../data/51Degrees-LiteV3.2.dat"; Run(fileName); // Waits for a character to be pressed. diff --git a/Examples/Getting Started/Program.cs b/Examples/Getting Started/Program.cs index d4c4195..bd1445f 100644 --- a/Examples/Getting Started/Program.cs +++ b/Examples/Getting Started/Program.cs @@ -126,7 +126,7 @@ public static void Run(string fileName) static void Main(string[] args) { - string fileName = args.Length > 0 ? args[0] : "../../../../../data/51Degrees-LiteV3.2.dat"; + string fileName = args.Length > 0 ? args[0] : "../../../../data/51Degrees-LiteV3.2.dat"; Run(fileName); // Waits for a character to be pressed. diff --git a/Examples/Match For Device Id/Program.cs b/Examples/Match For Device Id/Program.cs index ee1cd77..cf652bb 100644 --- a/Examples/Match For Device Id/Program.cs +++ b/Examples/Match For Device Id/Program.cs @@ -109,7 +109,7 @@ public static void Run(string fileName) // Snippet End static void Main(string[] args) { - string fileName = args.Length > 0 ? args[0] : "../../../../../data/51Degrees-LiteV3.2.dat"; + string fileName = args.Length > 0 ? args[0] : "../../../../data/51Degrees-LiteV3.2.dat"; Run(fileName); // Waits for a character to be pressed. diff --git a/Examples/Match Metrics/Program.cs b/Examples/Match Metrics/Program.cs index 2182a9d..ff6c3ba 100644 --- a/Examples/Match Metrics/Program.cs +++ b/Examples/Match Metrics/Program.cs @@ -153,7 +153,7 @@ public static void OutputMatchMetrics(Match match) static void Main(string[] args) { - string fileName = args.Length > 0 ? args[0] : "../../../../../data/51Degrees-LiteV3.2.dat"; + string fileName = args.Length > 0 ? args[0] : "../../../../data/51Degrees-LiteV3.2.dat"; Run(fileName); // Waits for a character to be pressed. diff --git a/Examples/Meta Data/Meta Data.csproj b/Examples/Meta Data/Meta Data.csproj index a89c8f7..8984347 100644 --- a/Examples/Meta Data/Meta Data.csproj +++ b/Examples/Meta Data/Meta Data.csproj @@ -13,11 +13,11 @@ 512 - x64 + AnyCPU true full false - bin\x64\Debug\ + bin\Debug\ DEBUG;TRACE prompt 4 @@ -26,7 +26,7 @@ AnyCPU pdbonly true - bin\x64\Release\ + bin\Release\ TRACE prompt 4 diff --git a/Examples/Meta Data/Program.cs b/Examples/Meta Data/Program.cs index 19bc36f..1267d29 100644 --- a/Examples/Meta Data/Program.cs +++ b/Examples/Meta Data/Program.cs @@ -125,7 +125,7 @@ public static void Run(string fileName) static void Main(string[] args) { - string fileName = args.Length > 0 ? args[0] : "../../../../../data/51Degrees-LiteV3.2.dat"; + string fileName = args.Length > 0 ? args[0] : "../../../../data/51Degrees-LiteV3.2.dat"; Run(fileName); // Waits for a character to be pressed. diff --git a/Examples/Offline Processing/Program.cs b/Examples/Offline Processing/Program.cs index 33095f3..d1e4326 100644 --- a/Examples/Offline Processing/Program.cs +++ b/Examples/Offline Processing/Program.cs @@ -166,8 +166,8 @@ public static void Run(string fileName, string inputFile) static void Main(string[] args) { - string fileName = args.Length > 0 ? args[0] : "../../../../../data/51Degrees-LiteV3.2.dat"; - string userAgents = args.Length > 1 ? args[1] : "../../../../../data/20000 User Agents.csv"; + string fileName = args.Length > 0 ? args[0] : "../../../../data/51Degrees-LiteV3.2.dat"; + string userAgents = args.Length > 1 ? args[1] : "../../../../data/20000 User Agents.csv"; Run(fileName, userAgents); // Waits for a character to be pressed. diff --git a/Examples/Strongly Typed/Program.cs b/Examples/Strongly Typed/Program.cs index df1d112..f465b7d 100644 --- a/Examples/Strongly Typed/Program.cs +++ b/Examples/Strongly Typed/Program.cs @@ -162,7 +162,7 @@ public static bool getIsMobileBool(Match match) static void Main(string[] args) { - string fileName = args.Length > 0 ? args[0] : "../../../../../data/51Degrees-LiteV3.2.dat"; + string fileName = args.Length > 0 ? args[0] : "../../../../data/51Degrees-LiteV3.2.dat"; Run(fileName); // Waits for a character to be pressed. diff --git a/FoundationV3/Mobile/Detection/Entities/Profile.cs b/FoundationV3/Mobile/Detection/Entities/Profile.cs index 811b9e2..e626629 100644 --- a/FoundationV3/Mobile/Detection/Entities/Profile.cs +++ b/FoundationV3/Mobile/Detection/Entities/Profile.cs @@ -72,6 +72,22 @@ public abstract class Profile : BaseEntity, IComparable, IEqua /// public readonly int ProfileId; + /// + /// A dictionary relating the index of a property to the values + /// returned by the profile. Used to speed up subsequent data + /// processing. + /// + private readonly ConcurrentDictionary + PropertyIndexToValues = new ConcurrentDictionary(); + + /// + /// A dictionary relating the name of a property to the values returned + /// by the profile. Used to speed up subsequent data processing. + /// + private readonly ConcurrentDictionary + PropertyNameToValues = new ConcurrentDictionary(); + + #endregion #region Internal Properties @@ -150,76 +166,17 @@ public Values this[Property property] { get { - Values values = null; - - // A read / write upgradable guard could be used in the future - // should the performance of GetPropertyValueIndexes prove too - // slow in the future. The use of a lock on the dictionary - // ensures that this implementation is thread safe. - lock (PropertyIndexToValues) - { - if (PropertyIndexToValues.TryGetValue( - property.Index, - out values) == false) + Values values = + PropertyIndexToValues.GetOrAdd(property.Index, i => { - values = new Entities.Values( + return new Entities.Values( property, GetPropertyValueIndexes(property)); - PropertyIndexToValues.Add(property.Index, values); - } - } - return values; - } - } - - /// - /// A dictionary relating the index of a property to the values - /// returned by the profile. Used to speed up subsequent data - /// processing. - /// - private IDictionary PropertyIndexToValues - { - get - { - if (_propertyIndexToValues == null) - { - lock(this) - { - if (_propertyIndexToValues == null) - { - _propertyIndexToValues = - new Dictionary(); - } - } - } - return _propertyIndexToValues; - } - } - private IDictionary _propertyIndexToValues; + }); - /// - /// A dictionary relating the name of a property to the values returned - /// by the profile. Used to speed up subsequent data processing. - /// - private IDictionary PropertyNameToValues - { - get - { - if (_propertyNameToValues == null) - { - lock (this) - { - if (_propertyNameToValues == null) - { - _propertyNameToValues = - new Dictionary(); - } - } - } - return _propertyNameToValues; + return values; } } - private IDictionary _propertyNameToValues; /// /// Gets the values associated with the property name. @@ -240,24 +197,18 @@ public Values this[string propertyName] { get { - Values values = null; - - // A read / write upgradable guard could be used in the future - // should the performance of this[property] prove too slow in - // the future. The use of a lock on the dictionary ensures that - // this implementation is thread safe. - lock (PropertyNameToValues) - { - if (PropertyNameToValues.TryGetValue(propertyName, out values) == false) - { - var property = DataSet.Properties[propertyName]; - if (property != null) + Values values = + PropertyNameToValues.GetOrAdd(propertyName, i => { - values = this[property]; + Values _values = null; + var property = DataSet.Properties[propertyName]; + if (property != null) + { + _values = this[property]; + } + return _values; } - PropertyNameToValues.Add(propertyName, values); - } - } + ); return values; } } diff --git a/FoundationV3/Mobile/Detection/NewDevice.cs b/FoundationV3/Mobile/Detection/NewDevice.cs index 2673d15..1ed6b5b 100644 --- a/FoundationV3/Mobile/Detection/NewDevice.cs +++ b/FoundationV3/Mobile/Detection/NewDevice.cs @@ -348,6 +348,15 @@ private static void HandleException(Exception ex) // the timeout. HandleTimeout(); } + else if (ex.Message.Contains("SSL/TLS")) + { + // A secure connection could not be established. + EventLog.Debug( + String.Format( + "Stopping usage sharing as a secure connection to remote '{0}' could " + + "not be established and threw error '{1}'", + _newDevicesUrl, ex.InnerException.Message)); + } else { // Another unhandled error occured so just disable the feature. diff --git a/FoundationV3/Properties/AssemblyInfo.cs b/FoundationV3/Properties/AssemblyInfo.cs index 31c4e4b..8f41802 100644 --- a/FoundationV3/Properties/AssemblyInfo.cs +++ b/FoundationV3/Properties/AssemblyInfo.cs @@ -47,7 +47,7 @@ // Build Number // Revision -[assembly: AssemblyVersion("3.2.12.3")] -[assembly: AssemblyFileVersion("3.2.12.3")] +[assembly: AssemblyVersion("3.2.14.3")] +[assembly: AssemblyFileVersion("3.2.14.3")] [assembly: NeutralResourcesLanguage("en-GB")] [assembly: AllowPartiallyTrustedCallers] diff --git a/FoundationV3/Properties/DetectionConstants.cs b/FoundationV3/Properties/DetectionConstants.cs index db46f6e..534496a 100644 --- a/FoundationV3/Properties/DetectionConstants.cs +++ b/FoundationV3/Properties/DetectionConstants.cs @@ -235,7 +235,7 @@ public static class Constants /// /// The URL usage sharing information should be sent to. /// - internal const string NewDevicesUrl = "http://devices.51degrees.mobi/new.ashx"; + internal const string NewDevicesUrl = "https://devices.51degrees.com/new.ashx"; /// /// The detail that should be provided relating to new devices. diff --git a/README.md b/README.md index d90f722..52e367f 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,11 @@ Data files which are updated weekly and daily, automatically, and with more prop ## Recent Changes -### Version 3.2.11 Highlights +### Version 3.2.14 Highlights -New Lite Data File released for August. +New Lite Data File released for December. +Usage data is now shared securely over HTTPS +getValues now uses a concurrent dictionary to improve performance. ### Major Changes in Version 3.2