From 84b970b13b8ff9065e1f4607ce9efaf47adb972c Mon Sep 17 00:00:00 2001 From: mbellomi Date: Wed, 2 Aug 2017 11:55:22 +0200 Subject: [PATCH 1/7] DOC-17 --- CHANGELOG.txt | 3 + Client/WurflCloud/Properties/AssemblyInfo.cs | 4 +- CloudDemo/Web.config | 5 +- README.md | 63 ++++++++++++++----- .../CloudClientInvalidApiKeyTest.cs | 2 +- 5 files changed, 56 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3d03bf7..ffe3d87 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,6 @@ +v1.3.0.2 +- FIX: CloudDemo project "Conflicting versions of ASP.NET" exception + v1.3.0.1 - FIX: syntax not backward compatible with VS2013 diff --git a/Client/WurflCloud/Properties/AssemblyInfo.cs b/Client/WurflCloud/Properties/AssemblyInfo.cs index 4712a5e..93e9952 100644 --- a/Client/WurflCloud/Properties/AssemblyInfo.cs +++ b/Client/WurflCloud/Properties/AssemblyInfo.cs @@ -45,7 +45,7 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.0.1")] -[assembly: AssemblyFileVersion("1.3.0.1")] +[assembly: AssemblyVersion("1.3.0.2")] +[assembly: AssemblyFileVersion("1.3.0.2")] [assembly: AllowPartiallyTrustedCallers] diff --git a/CloudDemo/Web.config b/CloudDemo/Web.config index b5b0857..6f98ddb 100644 --- a/CloudDemo/Web.config +++ b/CloudDemo/Web.config @@ -10,7 +10,6 @@ providerName="System.Data.SqlClient"/> - @@ -77,6 +76,10 @@ + + + + \ No newline at end of file diff --git a/README.md b/README.md index e23d2ac..77bd7c3 100644 --- a/README.md +++ b/README.md @@ -29,44 +29,73 @@ the Client API, and how best to use it in your application. Here's a quick example of how to get up and running quickly: +In CloudDemo\Services\Home\WurflService.cs set your personal ApiKey +both in GetDataByRequest and GetDataByAgent methods. + +GetDataByRequest is an example on how to get capabilities starting from the HttpRequest. + ```c# public DeviceInfoViewModel GetDataByRequest(HttpContext context) { var config = new DefaultCloudClientConfig { - ApiKey = "123456:xxxxxxxxxxxxxxxxxxxxxxxxxx" + ApiKey = "xxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }; var manager = new CloudClientManager(config); var info = manager.GetDeviceInfo(context, new[] { "is_wireless_device", "model_name" }); var model = new DeviceInfoViewModel { - DeviceId = info.Id, - ServerVersion = info.ServerVersion, - DateOfRequest = info.WurflLastUpdate.ToString(), - Library = manager.GetClientVersion(), - Capabilities = info.Capabilities, - Errors = info.Errors, - Source = info.ResponseOrigin + DeviceId = info.Id, + ServerVersion = info.ServerVersion, + DateOfRequest = info.WurflLastUpdate.ToString(), + Library = manager.GetClientVersion(), + Capabilities = info.Capabilities, + Errors = info.Errors, + Source = info.ResponseOrigin }; return model; } ``` -The `CloudDemo\ViewModels\DeviceInfoViewModel` is a helper class that -gathers information from the WURFL cloud client API and makes it ready -for display. You can directly check a capability as below: +GetDataByAgent is an example on how to get capabilities starting from a User-Agent string ```c# -var isMobileAsText = info.Get("is_wireless_device"); // Returns a string! +public DeviceInfoViewModel GetDataByAgent(HttpContextBase context, String ua) +{ + var config = new DefaultCloudClientConfig + { + ApiKey = "xxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + }; + + var manager = new CloudClientManager(config).SetCache(new MemoryWurflCloudCache()); + var wurflRequest = new WurflCloudRequest(context) {UserAgent = ua}; + + // Grab data + var info = manager.GetDeviceInfo(wurflRequest, new[] { "is_wireless_device", "is_smartphone", "physical_screen_width" }); + var model = new DeviceInfoViewModel + { + DeviceId = info.Id, + UserAgent = ua, + ServerVersion = info.ServerVersion, + DateOfRequest = info.WurflLastUpdate.ToLongTimeString(), + CachingModule = manager.GetCachingModuleName(), + Library = manager.GetClientVersion(), + Capabilities = info.Capabilities, + Errors = info.Errors, + Source = info.ResponseOrigin + }; + return model; +} ``` -If you want to test capabilities starting from a user agent string, you proceed as follows: +The `CloudDemo\ViewModels\DeviceInfoViewModel` is a helper class that +gathers information from the WURFL cloud client API and makes it ready +for display. + +You can directly check a capability as below: ```c# -var ua = "apple iphone"; -var manager = new CloudClientManager(config); -var wurflRequest = new WurflCloudRequest(context) {UserAgent = ua}; -var info = manager.GetDeviceInfo(context, new[] { "is_wireless_device", "model_name" }); +var isMobileAsText = info.Get("is_wireless_device"); // Returns a string! ``` # Configuration diff --git a/ScientiaMobile.WurflCloudTest-NUnit/CloudClientInvalidApiKeyTest.cs b/ScientiaMobile.WurflCloudTest-NUnit/CloudClientInvalidApiKeyTest.cs index ad24935..594f2fe 100644 --- a/ScientiaMobile.WurflCloudTest-NUnit/CloudClientInvalidApiKeyTest.cs +++ b/ScientiaMobile.WurflCloudTest-NUnit/CloudClientInvalidApiKeyTest.cs @@ -38,7 +38,7 @@ public void testInvalidApiKey() foreach (KeyValuePair pair in di.Errors) { - if (pair.Value.Equals("No API key was provided")) + if (pair.Value.Equals("Invalid API key")) apiKeyError = true; } From cd08e5e541b41b73ba109918d281c10d5daba9de Mon Sep 17 00:00:00 2001 From: mbellomi Date: Wed, 2 Aug 2017 15:09:18 +0200 Subject: [PATCH 2/7] DOC-18 --- CHANGELOG.txt | 1 + CloudDemo/Services/Home/WurflService.cs | 3 +-- README.md | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ffe3d87..cd7bfdb 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,6 @@ v1.3.0.2 - FIX: CloudDemo project "Conflicting versions of ASP.NET" exception +- FIX: CloudDemo project detection error when using "By user-agent" tab v1.3.0.1 - FIX: syntax not backward compatible with VS2013 diff --git a/CloudDemo/Services/Home/WurflService.cs b/CloudDemo/Services/Home/WurflService.cs index e305e84..696ad6f 100644 --- a/CloudDemo/Services/Home/WurflService.cs +++ b/CloudDemo/Services/Home/WurflService.cs @@ -44,10 +44,9 @@ public DeviceInfoViewModel GetDataByAgent(HttpContextBase context, String ua) }; var manager = new CloudClientManager(config).SetCache(new MemoryWurflCloudCache()); - var wurflRequest = new WurflCloudRequest(context) {UserAgent = ua}; // Grab data - var info = manager.GetDeviceInfo(wurflRequest, new[] { "is_wireless_device", "is_smartphone", "physical_screen_width" }); + var info = manager.GetDeviceInfo(ua, new[] { "is_wireless_device", "is_smartphone", "physical_screen_width" }); var model = new DeviceInfoViewModel { DeviceId = info.Id, diff --git a/README.md b/README.md index 77bd7c3..0f5647b 100644 --- a/README.md +++ b/README.md @@ -68,17 +68,15 @@ public DeviceInfoViewModel GetDataByAgent(HttpContextBase context, String ua) }; var manager = new CloudClientManager(config).SetCache(new MemoryWurflCloudCache()); - var wurflRequest = new WurflCloudRequest(context) {UserAgent = ua}; // Grab data - var info = manager.GetDeviceInfo(wurflRequest, new[] { "is_wireless_device", "is_smartphone", "physical_screen_width" }); + var info = manager.GetDeviceInfo(ua, new[] { "is_wireless_device", "is_smartphone", "physical_screen_width" }); var model = new DeviceInfoViewModel { DeviceId = info.Id, UserAgent = ua, ServerVersion = info.ServerVersion, DateOfRequest = info.WurflLastUpdate.ToLongTimeString(), - CachingModule = manager.GetCachingModuleName(), Library = manager.GetClientVersion(), Capabilities = info.Capabilities, Errors = info.Errors, From f9f4d11dc8b1b7a95f4a59311ef6b72039c87fcc Mon Sep 17 00:00:00 2001 From: mbellomi Date: Wed, 9 Aug 2017 10:08:49 +0200 Subject: [PATCH 3/7] DOC-16 --- README.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0f5647b..f959eec 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,76 @@ for a free or paid WURFL Cloud account (see above). When you've finished creating your account, you must copy your API Key, as it will be needed in the Client. +### Get ScientiaMobile WURFL Cloud Client assembly +You can get ScientiaMobile WURFL Cloud Client assembly in two ways: +- by cloning this Github repo and building the *ScientiaMobile.WurflCloud* project from the *master* branch +- by installing it as a [NuGet package] (https://www.nuget.org/packages/Wurfl_Official_Cloud_API/) -## Integration +In both cases you need to reference in your project the *ScientiaMobile.WurflCloud.dll* assembly along with +the third party *Newtonsoft.Json.dll* + +## Integration examples + +### Simple Console application +Here's a quick example of how to get WurflCloud up and running in a Console Application. + +In your Console Application project, add *ScientiaMobile.WurflCloud.dll* *Newtonsoft.Json.dll* assemblies as reference. + +Add a new class to named *SimpleConsoleApplication* to your project with the following code. + +``` +using System; +using System.Collections.Generic; +using ScientiaMobile.WurflCloud; +using ScientiaMobile.WurflCloud.Config; +using ScientiaMobile.WurflCloud.Cache; +using ScientiaMobile.WurflCloud.Device; + +namespace YourNameSpace +{ + class SimpleConsoleApplication + { + static void Main(string[] args) + { + // The User-Agent to detect + var ua = "Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-US) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.466 Mobile Safari/534.8+"; + + // The WurflCloud configuration + var config = new DefaultCloudClientConfig + { + // Your API Key + ApiKey = "xxxxxx:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" + }; + + // Configure CloudClientManager with no cache + var cache = new NoWurflCloudCache(); + + var manager = new CloudClientManager(config, cache); + + // Get all static capability provided by your license + var capabilities = new string[0]; + + // Perform device detection using provided User-Agent + DeviceInfo di = manager.GetDeviceInfo(ua, capabilities); + + // Write the detected Device Id + Console.WriteLine(di.Id); + + // Write static capabilities name/value + foreach (KeyValuePair entry in di.Capabilities) + { + Console.WriteLine(entry.Key + " " + entry.Value); + } + + Console.ReadKey(); + } + } +} +``` + +### Simple Web application You should review the included example (CloudDemo) to get a feel for -the Client API, and how best to use it in your application. +the Client API, and how best to use it in your web application. Here's a quick example of how to get up and running quickly: @@ -96,7 +162,7 @@ You can directly check a capability as below: var isMobileAsText = info.Get("is_wireless_device"); // Returns a string! ``` -# Configuration +## Configuration --------------- The public interface of the WURFL Cloud API is fairly simple and consists of a single class, `Client\WurflCloud\CloudClientManager`. The members of this class are: @@ -157,7 +223,7 @@ Caching modules available: entry. By invalidating the helper cache entry, you can clear all cached data in a single shot. -# Querying the Cloud Client API +## Querying the Cloud Client API -------------- To query the WURFL database in the cloud, you use the GetDeviceInfo method on the `Client\WurflCloud\CloudClientManager` class. From da53be8c77149366497c0085c3ba851170c67614 Mon Sep 17 00:00:00 2001 From: mbellomi Date: Wed, 9 Aug 2017 10:13:24 +0200 Subject: [PATCH 4/7] DOC-16 : indentation --- README.md | 70 +++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index f959eec..344eed6 100644 --- a/README.md +++ b/README.md @@ -49,43 +49,43 @@ using ScientiaMobile.WurflCloud.Device; namespace YourNameSpace { - class SimpleConsoleApplication + class SimpleConsoleApplication + { + static void Main(string[] args) { - static void Main(string[] args) - { - // The User-Agent to detect - var ua = "Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-US) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.466 Mobile Safari/534.8+"; - - // The WurflCloud configuration - var config = new DefaultCloudClientConfig - { - // Your API Key - ApiKey = "xxxxxx:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" - }; - - // Configure CloudClientManager with no cache - var cache = new NoWurflCloudCache(); - - var manager = new CloudClientManager(config, cache); - - // Get all static capability provided by your license - var capabilities = new string[0]; - - // Perform device detection using provided User-Agent - DeviceInfo di = manager.GetDeviceInfo(ua, capabilities); - - // Write the detected Device Id - Console.WriteLine(di.Id); - - // Write static capabilities name/value - foreach (KeyValuePair entry in di.Capabilities) - { - Console.WriteLine(entry.Key + " " + entry.Value); - } - - Console.ReadKey(); - } + // The User-Agent to detect + var ua = "Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-US) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.466 Mobile Safari/534.8+"; + + // The WurflCloud configuration + var config = new DefaultCloudClientConfig + { + // Your API Key + ApiKey = "xxxxxx:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" + }; + + // Configure CloudClientManager with no cache + var cache = new NoWurflCloudCache(); + + var manager = new CloudClientManager(config, cache); + + // Get all static capability provided by your license + var capabilities = new string[0]; + + // Perform device detection using provided User-Agent + DeviceInfo di = manager.GetDeviceInfo(ua, capabilities); + + // Write the detected Device Id + Console.WriteLine(di.Id); + + // Write static capabilities name/value + foreach (KeyValuePair entry in di.Capabilities) + { + Console.WriteLine(entry.Key + " " + entry.Value); + } + + Console.ReadKey(); } + } } ``` From a6c9efcb92a4767c6f4958a4a0d6e68373a91070 Mon Sep 17 00:00:00 2001 From: mbellomi Date: Wed, 9 Aug 2017 10:14:31 +0200 Subject: [PATCH 5/7] DOC-16 : c# tag --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 344eed6..76c4544 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ In your Console Application project, add *ScientiaMobile.WurflCloud.dll* *Newton Add a new class to named *SimpleConsoleApplication* to your project with the following code. -``` +```c# using System; using System.Collections.Generic; using ScientiaMobile.WurflCloud; From 2b84da7f4e7494ea17a599c0a064bed1a860ba39 Mon Sep 17 00:00:00 2001 From: mbellomi Date: Mon, 18 Dec 2017 17:21:24 +0100 Subject: [PATCH 6/7] CLOUD-11 generate new dotNET Cloud Client API with updated Strong Signature --- Client/WurflCloud/ScientiaMobile.WurflCloud.csproj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Client/WurflCloud/ScientiaMobile.WurflCloud.csproj b/Client/WurflCloud/ScientiaMobile.WurflCloud.csproj index 7727df0..bdf3309 100644 --- a/Client/WurflCloud/ScientiaMobile.WurflCloud.csproj +++ b/Client/WurflCloud/ScientiaMobile.WurflCloud.csproj @@ -35,7 +35,7 @@ false - false + true scientiamobile.snk @@ -43,10 +43,13 @@ OnBuildSuccess + + false + False - lib\Newtonsoft.Json.dll + lib\Newtonsoft.Json.dll From 423030b7fedb21c066b98d0dd27c8fe70423749f Mon Sep 17 00:00:00 2001 From: mbellomi Date: Mon, 18 Dec 2017 17:29:27 +0100 Subject: [PATCH 7/7] CLOUD-11 generate new dotNET Cloud Client API with updated Strong Signature - Nuspec file --- nuget_package/Wurfl_Official_Cloud_API.nuspec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nuget_package/Wurfl_Official_Cloud_API.nuspec b/nuget_package/Wurfl_Official_Cloud_API.nuspec index 5c102f9..c3dfbfb 100644 --- a/nuget_package/Wurfl_Official_Cloud_API.nuspec +++ b/nuget_package/Wurfl_Official_Cloud_API.nuspec @@ -2,7 +2,7 @@ Wurfl_Official_Cloud_API - 1.3.0.1 + 1.3.0.2 The official WURFL Cloud API for .NET ScientiaMobile,Inc. https://github.com/WURFL/wurfl-cloud-client-dotnet/blob/master/COPYING.txt @@ -10,7 +10,9 @@ true The official ASP.NET WURFL Cloud API allows you to query the WURFL database without having to host the database in your applications. This is beneficial because it guarantees that your WURFL data are always up to date. In addition, you don’t need to be concerned about distributing and synchronizing your WURFL data around the world: the WURFL cloud does it for you. - WURFL Cloud Client 1.3.0.1: + WURFL Cloud Client 1.3.0.2: +v1.3.0.2: +- FIX: Strong-Named assembly v1.3.0.1: - FIX: syntax not backward compatible with VS2013 v1.3.0.0: