Skip to content

Commit

Permalink
fix: #13;
Browse files Browse the repository at this point in the history
fix: #6;
fix: #8;

update code and yaml regex files to last version (commit 81b7c6c from commit c136bf9);

https://github.com/matomo-org/device-detector/compare/c136bf9..81b7c6c
  • Loading branch information
totpero committed Apr 25, 2019
1 parent d6c507f commit 4eeea7f
Show file tree
Hide file tree
Showing 40 changed files with 67,190 additions and 39,877 deletions.
5 changes: 3 additions & 2 deletions DeviceDetector.NET.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>DeviceDetector.NET</id>
<version>3.11.4</version>
<version>3.11.6</version>
<title>DeviceDetector.NET</title>
<authors>totpero</authors>
<owners>totpero</owners>
Expand All @@ -15,7 +15,7 @@
<tags>parse detection-library user-agent bot-detection mobile-detection desktop tablet mobile tv cars console</tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="YamlDotNet.Signed" version="5.3.0" />
<dependency id="YamlDotNet.Signed" version="6.0.0" />
</group>
</dependencies>
</metadata>
Expand All @@ -38,6 +38,7 @@
<file src="src\DeviceDetector.NET\regexes\device\portable_media_player.yml" target="regexes\device\portable_media_player.yml" />
<file src="src\DeviceDetector.NET\regexes\device\televisions.yml" target="regexes\device\televisions.yml" />
<file src="src\DeviceDetector.NET\bin\Debug\DeviceDetector.NET.dll" target="lib\net45\DeviceDetector.NET.dll" />
<file src="src\DeviceDetector.NET\bin\Debug\DeviceDetector.NET.pdb" target="lib\net45\DeviceDetector.NET.pdb" />
<file src="src\DeviceDetector.NET\bin\Debug\DeviceDetector.NET.xml" target="lib\net45\DeviceDetector.NET.xml" />
</files>
</package>
8 changes: 4 additions & 4 deletions README.md

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions src/DeviceDetector.NET/Cache/DictionaryCache.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
using System.Collections.Generic;
using System.Collections.Concurrent;

namespace DeviceDetectorNET.Cache
{
public class DictionaryCache : ICache
{
private static Dictionary<string,object> _staticCache = new Dictionary<string, object>();
private static ConcurrentDictionary<string,object> _staticCache = new ConcurrentDictionary<string, object>();
public bool Contains(string id)
{
return _staticCache !=null && _staticCache.Keys.Count > 0 && _staticCache.ContainsKey(id);
}

public bool Delete(string id)
{
_staticCache.Remove(id);
return true;
if (Contains(id))
{
_staticCache.TryRemove(id, out _);
return true;
}
return false;
}

public object Fetch(string id)
Expand All @@ -23,7 +27,7 @@ public object Fetch(string id)

public bool FlushAll()
{
_staticCache = new Dictionary<string, object>();
_staticCache = new ConcurrentDictionary<string, object>();
return true;
}

Expand All @@ -35,7 +39,7 @@ public bool Save(string id, object data, int lifeTime = 0)
}
else
{
_staticCache.Add(id, data);
_staticCache.TryAdd(id, data);
}
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/DeviceDetector.NET/DeviceDetector.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="YamlDotNet, Version=5.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<HintPath>..\..\packages\YamlDotNet.Signed.5.3.0\lib\net45\YamlDotNet.dll</HintPath>
<Reference Include="YamlDotNet, Version=6.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<HintPath>..\..\packages\YamlDotNet.6.0.0\lib\net45\YamlDotNet.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/DeviceDetector.NET/DeviceDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class DeviceDetector
/// <summary>
/// Current version number of DeviceDetector
/// </summary>
public const string VERSION = "3.11.4";
public const string VERSION = "3.11.6";

/// <summary>
/// Operating system families that are known as desktop only
Expand Down Expand Up @@ -262,6 +262,11 @@ private bool UsesMobileBrowser()
BrowserParser.IsMobileOnlyBrowser(((BrowserMatchResult) match).ShortName);
}

public bool IsTablet()
{
return device.HasValue && device.Value == DeviceType.DEVICE_TYPE_TABLET;
}

public bool IsMobile()
{
var mobileDeviceTypes = new List<int>
Expand Down
5 changes: 5 additions & 0 deletions src/DeviceDetector.NET/Parser/BotParserAbstract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

namespace DeviceDetectorNET.Parser
{
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TResult"></typeparam>
public abstract class BotParserAbstract<T, TResult> : ParserAbstract<T, TResult>, IBotParserAbstract
where T : class, IEnumerable<Bot>
where TResult : class, IBotMatchResult, new()
Expand Down
12 changes: 8 additions & 4 deletions src/DeviceDetector.NET/Parser/Client/BrowserParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ public class BrowserParser : ClientParserAbstract<List<Class.Client.Browser>, Br
{"AM","Amaya"},
{"AO","Amigo"},
{"AN","Android Browser"},
{"AD","AOL Shield"},
{"AR","Arora"},
{"AV","Amiga Voyager"},
{"AW","Amiga Aweb"},
{"AT","Atomic Web Browser"},
{"AS","Avast Secure Browser"},
{"BA","Beaker Browser"},
{"BB","BlackBerry Browser"},
{"BD","Baidu Browser"},
{"BS","Baidu Spark"},
Expand Down Expand Up @@ -150,6 +152,7 @@ public class BrowserParser : ClientParserAbstract<List<Class.Client.Browser>, Br
{"QQ","QQ Browser"},
{"QT","Qutebrowser"},
{"QZ","QupZilla"},
{"QM","Qwant Mobile"},
{"RK","Rekonq"},
{"RM","RockMelt"},
{"SB","Samsung Browser"},
Expand All @@ -167,6 +170,8 @@ public class BrowserParser : ClientParserAbstract<List<Class.Client.Browser>, Br
{"SP","SuperBird"},
{"ST","Streamy"},
{"SX","Swiftfox"},
{"TF","TenFourFox"},
{"TB","Tenta Browser"},
{"TZ","Tizen Browser"},
{"TS","TweakStyle"},
{"UC","UC Browser"},
Expand All @@ -189,16 +194,15 @@ public class BrowserParser : ClientParserAbstract<List<Class.Client.Browser>, Br
{"BlackBerry Browser" , new []{"BB"}},
{"Baidu" , new []{"BD", "BS"}},
{"Amiga" , new []{"AV", "AW"}},
{"Chrome" , new []{"CH", "BR", "CC", "CD", "CM", "CI", "CF", "CN", "CR", "CP", "IR", "RM", "AO", "TS", "VI", "PT", "AS"}},
{"Firefox" , new []{"FF", "FE", "FM", "SX", "FB", "PX", "MB", "EI", "WF", "CU"}},
{"Chrome" , new []{"CH", "BA", "BR", "CC", "CD", "CM", "CI", "CF", "CN", "CR", "CP", "IR", "RM", "AO", "TS", "VI", "PT", "AS", "TB", "AD"}},
{"Firefox" , new []{"FF", "FE", "FM", "SX", "FB", "PX", "MB", "EI", "WF", "CU", "TF", "QM"}},
{"Internet Explorer" , new []{"IE", "IM", "PS"}},
{"Konqueror" , new []{"KO"}},
{"NetFront" , new []{"NF"}},
{"Nokia Browser" , new []{"NB", "NO", "NV", "DO"}},
{"Opera" , new []{"OP", "OM", "OI", "ON", "OO"}},
{"Safari" , new []{"SF", "MF"}},
{"Sailfish Browser" , new []{"SA"}},

{"Sailfish Browser" , new []{"SA"}}
};

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/DeviceDetector.NET/Parser/Client/ClientType.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using DeviceDetectorNET.Results.Client;

namespace DeviceDetectorNET.Parser.Client
{
public class ClientType
Expand Down
Loading

0 comments on commit 4eeea7f

Please sign in to comment.