Skip to content

Commit

Permalink
Merged PR 309: RELEASE: Version 3.2.15.3 released
Browse files Browse the repository at this point in the history
- FEAT: A new fluent builder, 'DataSetBuilder', replaces StreamFactory as the preferred DataSet creation method.
- FEAT: DataSetBuilder allows the user to specify cache sizes and replace the 51 degrees cache implementation with their own if desired.
- DATA: Updated lite data files with February 2017 data.
- DATA: Updated 20,000 user agents test file.
- OPTIM: Improve performance of GetCompleteNumericNode method.
- BUG: Autoupdate now handles null response correctly.


Former-commit-id: d0a593e8caa3f496ee6c5b52e8a1f64d54a196ac
  • Loading branch information
Steve51D committed Mar 7, 2017
2 parents bf65cde + e58ef89 commit 9c8f392
Show file tree
Hide file tree
Showing 159 changed files with 25,946 additions and 21,912 deletions.
7 changes: 7 additions & 0 deletions 51degrees 4.sln
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "All Profiles", "Examples\Al
EndProject
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "FiftyOne.Foundation SQL", "FoundationV3\FiftyOne.Foundation SQL.sqlproj", "{334A1D9F-82F5-41C0-8583-76823D8BF2B1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Caching Configuration", "Examples\Caching Configuration\Caching Configuration.csproj", "{D3C0A9BC-E020-4ED0-A24A-13402FB668D8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -131,6 +133,10 @@ Global
{334A1D9F-82F5-41C0-8583-76823D8BF2B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{334A1D9F-82F5-41C0-8583-76823D8BF2B1}.Release|Any CPU.Build.0 = Release|Any CPU
{334A1D9F-82F5-41C0-8583-76823D8BF2B1}.Release|Any CPU.Deploy.0 = Release|Any CPU
{D3C0A9BC-E020-4ED0-A24A-13402FB668D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3C0A9BC-E020-4ED0-A24A-13402FB668D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3C0A9BC-E020-4ED0-A24A-13402FB668D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3C0A9BC-E020-4ED0-A24A-13402FB668D8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -148,5 +154,6 @@ Global
{608157FD-165C-40F4-AF79-BC812C9BC70E} = {1AB29287-EBE4-42DD-BCF6-95E5D1158E4C}
{B91129C0-224A-4AA7-BE18-C13EB2E2BDFD} = {1AB29287-EBE4-42DD-BCF6-95E5D1158E4C}
{EA6A83FE-D698-4E4D-821E-1B5BCC22D501} = {1AB29287-EBE4-42DD-BCF6-95E5D1158E4C}
{D3C0A9BC-E020-4ED0-A24A-13402FB668D8} = {1AB29287-EBE4-42DD-BCF6-95E5D1158E4C}
EndGlobalSection
EndGlobal
4 changes: 4 additions & 0 deletions Examples Tests/Examples Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
<Project>{dba7559b-ef3c-496d-bdc7-9ef76a5d3eb9}</Project>
<Name>Strongly Typed</Name>
</ProjectReference>
<ProjectReference Include="..\FoundationV3\FiftyOne.Foundation 4.csproj">
<Project>{9D658044-FB65-4939-8449-A3A1DEBBB31A}</Project>
<Name>FiftyOne.Foundation 4</Name>
</ProjectReference>
<ProjectReference Include="..\Integration Tests\Integration Tests.csproj">
<Project>{1211a461-73ca-4d7e-86a7-983540f12539}</Project>
<Name>Integration Tests</Name>
Expand Down
6 changes: 6 additions & 0 deletions Examples/Caching Configuration/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
69 changes: 69 additions & 0 deletions Examples/Caching Configuration/Caching Configuration.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{D3C0A9BC-E020-4ED0-A24A-13402FB668D8}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Caching_Configuration</RootNamespace>
<AssemblyName>Caching Configuration</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CustomCache.cs" />
<Compile Include="CustomCacheBuilder.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\FoundationV3\FiftyOne.Foundation 4.csproj">
<Project>{9d658044-fb65-4939-8449-a3a1debbb31a}</Project>
<Name>FiftyOne.Foundation 4</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
137 changes: 137 additions & 0 deletions Examples/Caching Configuration/CustomCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/**
* This Source Code Form is copyright of 51Degrees Mobile Experts Limited.
* Copyright (c) 2015 51Degrees Mobile Experts Limited, 5 Charlotte Close,
* Caversham, Reading, Berkshire, United Kingdom RG4 7BY
*
* This Source Code Form is the subject of the following patent
* applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte
* Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY:
* European Patent Application No. 13192291.6; and
* United States Patent Application Nos. 14/085,223 and 14/085,301.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0.
*
* If a copy of the MPL was not distributed with this file, You can obtain
* one at http://mozilla.org/MPL/2.0/.
*
* This Source Code Form is "Incompatible With Secondary Licenses", as
* defined by the Mozilla Public License, v. 2.0.
*/

using FiftyOne.Foundation.Mobile.Detection.Caching;
using System;
using System.Runtime.Caching;
using System.Threading;

namespace Caching_Configuration
{
/// <summary>
/// Class that adapts the .NET <see cref="MemoryCache"/> to the 51Degrees
/// <see cref="IPutCache{K, V}"/> interface.
/// A sliding expiry is used to evict items that are not accessed
/// for 10 minutes.
/// </summary>
/// <typeparam name="K">
/// The type of the key used in the cache
/// </typeparam>
/// <typeparam name="V">
/// The type of the objects stored in the cache
/// </typeparam>
public class CustomCache<K, V> : IPutCache<K, V>
{
/// <summary>
/// The cache
/// </summary>
private MemoryCache _cache;
/// <summary>
/// The cache eviction policy
/// </summary>
private CacheItemPolicy _policy;

/// <summary>
/// Number of requests to the cache
/// </summary>
private long _requestCount;
/// <summary>
/// Number of cache misses
/// </summary>
private long _missCount;

/// <summary>
/// Constructor
/// </summary>
public CustomCache()
{
// initialise the cache
_cache = new MemoryCache("CustomCache");

// Create the eviction policy object
_policy = new CacheItemPolicy();
_policy.SlidingExpiration = new TimeSpan(0, 10, 0);
}

/// <summary>
/// Get the percentage of cache misses
/// </summary>
public double PercentageMisses
{
get
{
return _missCount / _requestCount;
}
}

/// <summary>
/// Get the specified data item from the cache
/// </summary>
/// <param name="key">
/// The key of the data item
/// </param>
/// <returns>
/// The data item
/// </returns>
public V this[K key]
{
get
{
Interlocked.Increment(ref _requestCount);
return (V)_cache[key.ToString()];
}
}

/// <summary>
/// Put the specified data item into the cache using the specified key.
/// This is called by the 51Degrees API when a cache miss occurs
/// </summary>
/// <param name="key">
/// The key
/// </param>
/// <param name="value">
/// The data item
/// </param>
public void Put(K key, V value)
{
Interlocked.Increment(ref _missCount);
_cache.Set(key.ToString(), value, _policy);
}

/// <summary>
/// Clear all items from the cache
/// </summary>
public void ResetCache()
{
_cache.Dispose();
_cache = new MemoryCache("CustomCache");
}

/// <summary>
/// Dispose
/// </summary>
public void Dispose()
{
_cache.Dispose();
}

}
}
32 changes: 32 additions & 0 deletions Examples/Caching Configuration/CustomCacheBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using FiftyOne.Foundation.Mobile.Detection.Caching;

namespace Caching_Configuration
{
/// <summary>
/// Implementation of ICacheBuilder to build
/// <see cref="CustomCache{K, V}"/>
/// </summary>
public class CustomCacheBuilder : ICacheBuilder
{
/// <summary>
/// Build and return a <see cref="CustomCache{K, V}"/>
/// </summary>
/// <typeparam name="K">
/// The type of the key to use when accessing cache items
/// </typeparam>
/// <typeparam name="V">
/// The type of the data items to store in the cache
/// </typeparam>
/// <param name="cacheSize">
/// Not used by CustomCache
/// </param>
/// <returns>
/// The cache
/// </returns>
public ICache<K, V> Build<K, V>(int cacheSize)
{
return new CustomCache<K, V>();
}
}
}
Loading

0 comments on commit 9c8f392

Please sign in to comment.