Skip to content

Commit

Permalink
Merge v3.2.12.3 to master
Browse files Browse the repository at this point in the history
 - DATA: Updated the Lite data files for September data
 - EXAMPLE/BUILD: Added all profiles example, and removed unnecessary
 - FEAT: WebProvider.Download now returns status code.
 - BUILD: Made sure every project in the solution is using x64 as the target
 - BUG/TEST: Changed the path which the auto update tests use.


Former-commit-id: 914443b86b5d1d13ac225aa4ce65413ed1c7ed54
  • Loading branch information
ben51degrees committed Sep 14, 2016
2 parents adf23cb + f1ddd8c commit 5a1120a
Show file tree
Hide file tree
Showing 14 changed files with 486 additions and 202 deletions.
239 changes: 53 additions & 186 deletions 51degrees 4.sln

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion Detector Web Site/Detector Web Site 4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<IISExpressUseClassicPipelineMode />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<UseGlobalApplicationHostFile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -194,7 +195,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MobileDevice.asmx.cs">
<DependentUpon>MobileDevice.asmx</DependentUpon>
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
Expand Down Expand Up @@ -271,6 +271,24 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE;DEBUG;</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE;</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
Expand Down
33 changes: 33 additions & 0 deletions Examples Tests/AllProfiles.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FiftyOne.Example.Illustration.AllProfiles;
using FiftyOne.Tests.Integration;

namespace FiftyOne.Tests.Example
{
[TestClass]
public class AllProfiles
{
[TestMethod]
[TestCategory("Example"), TestCategory("Unit")]
public void LiteExamples_All_Profiles()
{
Program.Run(
Utils.GetDataFile(Constants.LITE_PATTERN_V32));
}
[TestMethod]
[TestCategory("Example"), TestCategory("Unit")]
public void PremiumExamples_All_Profiles()
{
Program.Run(
Utils.GetDataFile(Constants.PREMIUM_PATTERN_V32));
}
[TestMethod]
[TestCategory("Example"), TestCategory("Unit")]
public void EnterpriseExamples_All_Profiles()
{
Program.Run(
Utils.GetDataFile(Constants.ENTERPRISE_PATTERN_V32));
}
}
}
5 changes: 5 additions & 0 deletions Examples Tests/Examples Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="AllProfiles.cs" />
<Compile Include="MatchForDeviceId.cs" />
<Compile Include="MatchMetrics.cs" />
<Compile Include="MetaData.cs" />
Expand All @@ -68,6 +69,10 @@
<Compile Include="StronglyTyped.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Examples\All Profiles\All Profiles.csproj">
<Project>{ea6a83fe-d698-4e4d-821e-1b5bcc22d501}</Project>
<Name>All Profiles</Name>
</ProjectReference>
<ProjectReference Include="..\Examples\Getting Started\Getting Started.csproj">
<Project>{091cbba9-94c4-486b-b630-6533e787a489}</Project>
<Name>Getting Started</Name>
Expand Down
87 changes: 87 additions & 0 deletions Examples/All Profiles/All Profiles.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?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>{EA6A83FE-D698-4E4D-821E-1B5BCC22D501}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>All_Profiles</RootNamespace>
<AssemblyName>All Profiles</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<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="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>
6 changes: 6 additions & 0 deletions Examples/All Profiles/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"/>
</startup>
</configuration>
189 changes: 189 additions & 0 deletions Examples/All Profiles/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/**
* 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.
*/

/*
<tutorial>
All profiles example of using 51Degrees device detection.
The example shows how to:
<ol>
<li>Initialise the 51Degrees data set
<p><pre class="prettyprint lang-cs">
string fileName = args[0];
DataSet dataSet = StreamFactory.Create(fileName, false);
</pre></p>
<li>Open an output file to write the results to
<p><pre class="prettyprint lang-cs">
StreamWriter fout = new StreamWriter(outputFile);
</pre></p>
<li>Write a header to the output file with the property names in
<p><pre class="prettyprint lang-cs">
fout.Write("Id");
foreach (Property property in hardwareProperties)
{
fout.Write("," + property.Name);
}
fout.Write("\n");
</pre></p>
<li>Get all hardware profiles as an array
<p><pre class="prettyprint lang-cs">
Profile[] hardwareProfiles = dataSet.Hardware.Profiles;
</pre></p>
<li>Get the values of a required property from a profile to write
to the CSV file
<p><pre class="prettyprint lang-cs">
foreach (Value value in profile.Values)
{
if (value.Property == property)
{
// Append this value to the string.
values += value.ToString();
}
}
</pre></p>
</ol>
This tutorial assumes you are building this from within the
51Degrees Visual Studio solution. Running the executable produced
inside Visual Studio will ensure all the command line arguments
are preset correctly. If you are running outside of Visual Studio,
make sure to add the path to a 51Degrees data file as an argument.
</tutorial>
*/
using System;
using System.Linq;
using FiftyOne.Foundation.Mobile.Detection.Entities;
using FiftyOne.Foundation.Mobile.Detection.Factories;
using System.IO;

namespace FiftyOne.Example.Illustration.AllProfiles
{
public class Program
{
// Snippet Start
public static void Run(string fileName)
{
// DataSet is the object used to interact with the data file.
// StreamFactory creates Dataset with pool of binary readers to
// perform device lookup using file on disk.
DataSet dataSet = StreamFactory.Create(fileName, false);

// Name of the output file results will be saved to.
string outputFile = "AllProfilesOutput.csv";

// Get all the hardware profiles from the hardware component.
Profile[] hardwareProfiles = dataSet.Hardware.Profiles;

// Get all the hardware properties from the hardware component.
// For the full list of properties see:
// https://51degrees.com/resources/property-dictionary
Property[] hardwareProperties = dataSet.Hardware.Properties;

// Opens and output file.
StreamWriter fout = new StreamWriter(outputFile);

Console.WriteLine("Starting All Profiles Example.");

// Print CSV headers to output file.
fout.Write("Id");
foreach (Property property in hardwareProperties)
{
fout.Write("," + property.Name);
}
fout.Write("\n");

// Loop over all devices.
foreach (Profile profile in hardwareProfiles)
{
// Write the device's profile id.
fout.Write(profile.ProfileId);

foreach (Property property in hardwareProperties)
{
// Print the profile's values for the property.
fout.Write(",");
fout.Write(getProfileValues(profile, property));
}
fout.Write("\n");
}

fout.Close();

Console.WriteLine("Output Written to " + outputFile);

// Finally close the dataset, releasing resources and file locks.
dataSet.Dispose();
}

/// <summary>
/// Constructs a "|" separated string of all the values the profile has
/// which relate to the supplied property.
/// </summary>
/// <param name="profile">Profile to get the values from.</param>
/// <param name="property">Property to get the values for.</param>
/// <returns>string of properties for the requested profile
/// and property.</returns>
static string getProfileValues(Profile profile, Property property)
{
string values = "";

if (property.Category == "Javascript")
{
// Prevents big chunks of javascript overrides from
// being writen.
return "N/A";
}

bool firstValue = true;

// Look though all the values in the profile and check if
// they relate to the requested property.
foreach (Value value in profile.Values)
{
if (value.Property == property)
{
if (!firstValue)
{
// There are multiple values, so separate them.
values += "|";
}
else
{
firstValue = false;
}
// Append this value to the string.
values += value.ToString();
}
}

// Return the values string.
return values;
}
// Snippet End

static void Main(string[] args)
{
string fileName = args.Length > 0 ? args[0] : "../../../../../data/51Degrees-LiteV3.2.dat";
Run(fileName);

// Waits for a character to be pressed.
Console.ReadKey();
}
}
}
Loading

0 comments on commit 5a1120a

Please sign in to comment.