Skip to content

Commit

Permalink
Merged PR 240: RELEASE: Version 3.2.14.3 released.
Browse files Browse the repository at this point in the history
 - FEAT: Usage data is now shared over HTTPS
 - OPTIM: Modified the implementation of getValues to use a ConcurrentDictionary.
 - DATA: Updated the Lite data files for December data.
 - BUILD: Updated version number.
 - EXAMPLE: All example projects now build as AnyCPU in the appropriate directory
 - DOC: Updated Readme.


Former-commit-id: 09922c00fd24f767371d0c3a1e87d2c42a4b0a52
  • Loading branch information
ben51degrees committed Dec 15, 2016
2 parents ec251de + 1cec886 commit bf65cde
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 97 deletions.
2 changes: 1 addition & 1 deletion Examples/All Profiles/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Examples/Find Profiles/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Examples/Getting Started/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Examples/Match For Device Id/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Examples/Match Metrics/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions Examples/Meta Data/Meta Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\x64\Debug\</OutputPath>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -26,7 +26,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\x64\Release\</OutputPath>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down
2 changes: 1 addition & 1 deletion Examples/Meta Data/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions Examples/Offline Processing/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Examples/Strongly Typed/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
111 changes: 31 additions & 80 deletions FoundationV3/Mobile/Detection/Entities/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ public abstract class Profile : BaseEntity<DataSet>, IComparable<Profile>, IEqua
/// </summary>
public readonly int ProfileId;

/// <summary>
/// A dictionary relating the index of a property to the values
/// returned by the profile. Used to speed up subsequent data
/// processing.
/// </summary>
private readonly ConcurrentDictionary<int, Values>
PropertyIndexToValues = new ConcurrentDictionary<int, Entities.Values>();

/// <summary>
/// A dictionary relating the name of a property to the values returned
/// by the profile. Used to speed up subsequent data processing.
/// </summary>
private readonly ConcurrentDictionary<string, Values>
PropertyNameToValues = new ConcurrentDictionary<string, Entities.Values>();


#endregion

#region Internal Properties
Expand Down Expand Up @@ -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;
}
}

/// <summary>
/// A dictionary relating the index of a property to the values
/// returned by the profile. Used to speed up subsequent data
/// processing.
/// </summary>
private IDictionary<int, Values> PropertyIndexToValues
{
get
{
if (_propertyIndexToValues == null)
{
lock(this)
{
if (_propertyIndexToValues == null)
{
_propertyIndexToValues =
new Dictionary<int, Values>();
}
}
}
return _propertyIndexToValues;
}
}
private IDictionary<int, Values> _propertyIndexToValues;
});

/// <summary>
/// A dictionary relating the name of a property to the values returned
/// by the profile. Used to speed up subsequent data processing.
/// </summary>
private IDictionary<string, Values> PropertyNameToValues
{
get
{
if (_propertyNameToValues == null)
{
lock (this)
{
if (_propertyNameToValues == null)
{
_propertyNameToValues =
new Dictionary<string, Values>();
}
}
}
return _propertyNameToValues;
return values;
}
}
private IDictionary<string, Values> _propertyNameToValues;

/// <summary>
/// Gets the values associated with the property name.
Expand All @@ -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;
}
}
Expand Down
9 changes: 9 additions & 0 deletions FoundationV3/Mobile/Detection/NewDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions FoundationV3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
2 changes: 1 addition & 1 deletion FoundationV3/Properties/DetectionConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public static class Constants
/// <summary>
/// The URL usage sharing information should be sent to.
/// </summary>
internal const string NewDevicesUrl = "http://devices.51degrees.mobi/new.ashx";
internal const string NewDevicesUrl = "https://devices.51degrees.com/new.ashx";

/// <summary>
/// The detail that should be provided relating to new devices.
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit bf65cde

Please sign in to comment.