-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged PR 309: RELEASE: Version 3.2.15.3 released
- 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
Showing
159 changed files
with
25,946 additions
and
21,912 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
69
Examples/Caching Configuration/Caching Configuration.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); | ||
} | ||
} | ||
} |
Oops, something went wrong.