diff --git a/51degrees 4.sln b/51degrees 4.sln new file mode 100644 index 0000000..168b4c0 --- /dev/null +++ b/51degrees 4.sln @@ -0,0 +1,62 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Detector Web Site 4", "Detector Web Site\Detector Web Site 4.csproj", "{A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FiftyOne.Foundation 4", "FoundationV3\FiftyOne.Foundation 4.csproj", "{9D658044-FB65-4939-8449-A3A1DEBBB31A}" +EndProject +Global + GlobalSection(TeamFoundationVersionControl) = preSolution + SccNumberOfProjects = 3 + SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} + SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs06 + SccLocalPath0 = . + SccProjectUniqueName1 = Detector\u0020Web\u0020Site\\Detector\u0020Web\u0020Site\u00204.csproj + SccProjectName1 = Detector\u0020Web\u0020Site + SccLocalPath1 = Detector\u0020Web\u0020Site + SccProjectUniqueName2 = FoundationV3\\FiftyOne.Foundation\u00204.csproj + SccProjectName2 = FoundationV3 + SccLocalPath2 = FoundationV3 + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Debug|x64.ActiveCfg = Debug|Any CPU + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Debug|x86.ActiveCfg = Debug|Any CPU + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Release|Any CPU.Build.0 = Release|Any CPU + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Release|x64.ActiveCfg = Release|Any CPU + {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69}.Release|x86.ActiveCfg = Release|Any CPU + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Debug|x64.ActiveCfg = Debug|x64 + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Debug|x64.Build.0 = Debug|x64 + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Debug|x86.ActiveCfg = Debug|x64 + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Release|Any CPU.Build.0 = Release|Any CPU + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Release|x64.ActiveCfg = Release|x64 + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Release|x64.Build.0 = Release|x64 + {9D658044-FB65-4939-8449-A3A1DEBBB31A}.Release|x86.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Detector Web Site/Detector Web Site 4.csproj.vspscc b/51degrees 4.vssscc similarity index 77% rename from Detector Web Site/Detector Web Site 4.csproj.vspscc rename to 51degrees 4.vssscc index feffdec..794f014 100644 --- a/Detector Web Site/Detector Web Site 4.csproj.vspscc +++ b/51degrees 4.vssscc @@ -6,5 +6,5 @@ "NUMBER_OF_EXCLUDED_FILES" = "0" "ORIGINAL_PROJECT_FILE_PATH" = "" "NUMBER_OF_NESTED_PROJECTS" = "0" -"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" } diff --git a/Detector Web Site/51Degrees.mobi.config b/Detector Web Site/51Degrees.mobi.config deleted file mode 100644 index 6692ea5..0000000 --- a/Detector Web Site/51Degrees.mobi.config +++ /dev/null @@ -1,108 +0,0 @@ - - - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Detector Web Site/Default.aspx b/Detector Web Site/Default.aspx deleted file mode 100644 index 7f6d327..0000000 --- a/Detector Web Site/Default.aspx +++ /dev/null @@ -1,17 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="True" MasterPageFile="~/Detector.Master" CodeBehind="Default.aspx.cs" Inherits="Detector._Default" EnableSessionState="True" EnableViewState="false" %> -<%@ OutputCache VaryByParam="*" VaryByHeader="User-Agent" Duration="240" Location="Any" %> -<%@ Register Src="~/DeviceProperties.ascx" TagPrefix="uc" TagName="DeviceProperties" %> - - - Desktop / Laptop - - - -
-
- " alt="Desktop / Laptop" style="vertical-align: middle;"/> - Desktop / Laptop -
-
- -
diff --git a/Detector Web Site/Default.aspx.cs b/Detector Web Site/Default.aspx.cs deleted file mode 100644 index fd158d9..0000000 --- a/Detector Web Site/Default.aspx.cs +++ /dev/null @@ -1,35 +0,0 @@ -/* ********************************************************************* - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. - * See the License for the specific language governing rights and - * limitations under the License. - * - * The Original Code is named .NET Mobile API, first released under - * this licence on 11th March 2009. - * - * The Initial Developer of the Original Code is owned by - * 51 Degrees Mobile Experts Limited. Portions created by 51 Degrees - * Mobile Experts Limited are Copyright (C) 2009 - 2013. All Rights Reserved. - * - * Contributor(s): - * James Rosewell - * - * ********************************************************************* */ - -using System; - -namespace Detector -{ - public partial class _Default : System.Web.UI.Page - { - protected override void OnInit(EventArgs e) - { - - } - } -} diff --git a/Detector Web Site/Default.aspx.designer.cs b/Detector Web Site/Default.aspx.designer.cs deleted file mode 100644 index c4ee7d0..0000000 --- a/Detector Web Site/Default.aspx.designer.cs +++ /dev/null @@ -1,24 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Detector { - - - public partial class _Default { - - /// - /// Device control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Detector.DeviceProperties Device; - } -} diff --git a/Detector Web Site/Desktop.png b/Detector Web Site/Desktop.png deleted file mode 100644 index 9cc666c..0000000 Binary files a/Detector Web Site/Desktop.png and /dev/null differ diff --git a/Detector Web Site/Detector Web Site 3.5.csproj b/Detector Web Site/Detector Web Site 3.5.csproj deleted file mode 100644 index f64d3c9..0000000 --- a/Detector Web Site/Detector Web Site 3.5.csproj +++ /dev/null @@ -1,214 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - Detector - Detector - v4.0 - - - - - - - - - - - 3.5 - - - false - - - true - full - false - bin\ - TRACE;DEBUG;VER35 - prompt - 4 - - - pdbonly - true - bin\ - TRACE;VER35 - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - Reference.map - - - MSDiscoCodeGenerator - Reference.cs - - - Designer - - - - - Default.aspx - ASPXCodeBehind - - - Default.aspx - - - Detector.Master - ASPXCodeBehind - - - Detector.Master - - - DeviceProperties.ascx - ASPXCodeBehind - - - DeviceProperties.ascx - - - Global.asax - - - Default.aspx - ASPXCodeBehind - - - Default.aspx - - - - MobileDevice.asmx - Component - - - True - True - Settings.settings - - - LogTable.aspx - ASPXCodeBehind - - - LogTable.aspx - - - Default.aspx - ASPXCodeBehind - - - Default.aspx - - - True - True - Reference.map - - - - - - - - Dynamic - Web References\WebService\ - http://localhost/Detector4/MobileDevice.asmx%3fWSDL - - - - - Settings - Detector_WebService_MobileDevice - - - - - {2C9B0E11-2654-49AF-855A-BFA629F302E8} - FiftyOne.Foundation 3.5 - - - - - - - - - - - - - False - False - 5151 - / - http://localhost/Detector4 - False - False - - - False - - - - - \ No newline at end of file diff --git a/Detector Web Site/Detector Web Site 4.csproj b/Detector Web Site/Detector Web Site 4.csproj deleted file mode 100644 index beb8438..0000000 --- a/Detector Web Site/Detector Web Site 4.csproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - Detector - Detector - v4.0 - SAK - SAK - SAK - SAK - - - 3.5 - - - false - - - true - full - false - bin\ - TRACE;DEBUG;VER4 - prompt - 4 - - - pdbonly - true - bin\ - TRACE;VER4 - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - Reference.map - - - MSDiscoCodeGenerator - Reference.cs - - - Designer - - - - - Default.aspx - ASPXCodeBehind - - - Default.aspx - - - Detector.Master - ASPXCodeBehind - - - Detector.Master - - - DeviceProperties.ascx - ASPXCodeBehind - - - DeviceProperties.ascx - - - Global.asax - - - Default.aspx - ASPXCodeBehind - - - Default.aspx - - - - MobileDevice.asmx - Component - - - True - True - Settings.settings - - - LogTable.aspx - ASPXCodeBehind - - - LogTable.aspx - - - Default.aspx - ASPXCodeBehind - - - Default.aspx - - - True - True - Reference.map - - - - - - - - Dynamic - Web References\WebService\ - http://localhost/Detector4/MobileDevice.asmx%3fWSDL - - - - - Settings - Detector_WebService_MobileDevice - - - - - {2C9B0E11-2654-49AF-855A-BFA629F302E8} - FiftyOne.Foundation 4 - - - - - - - - - - - - - False - False - 5151 - / - http://localhost/Detector4 - False - False - - - False - - - - - \ No newline at end of file diff --git a/Detector Web Site/Detector Web Site.csproj b/Detector Web Site/Detector Web Site.csproj deleted file mode 100644 index a6b0900..0000000 --- a/Detector Web Site/Detector Web Site.csproj +++ /dev/null @@ -1,182 +0,0 @@ - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {A0A7C5CE-1B06-4BB3-AB9D-DB055C6EDF69} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - Detector - Detector - v2.0 - - - - - - - - - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - AnyCPU - - - pdbonly - true - bin\ - TRACE;VER2 - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - MSDiscoCodeGenerator - Reference.cs - - - - - - Default.aspx - ASPXCodeBehind - - - Default.aspx - - - Detector.Master - ASPXCodeBehind - - - Detector.Master - - - Global.asax - - - Default.aspx - ASPXCodeBehind - - - Default.aspx - - - DeviceProperties.ascx - ASPXCodeBehind - - - DeviceProperties.ascx - - - - MobileDevice.asmx - Component - - - True - True - Settings.settings - - - Default.aspx - ASPXCodeBehind - - - Default.aspx - - - True - True - Reference.map - - - - - {2C9B0E11-2654-49AF-855A-BFA629F302E8} - FiftyOne.Foundation - - - - - - - - Dynamic - Web References\WebService\ - http://localhost/Detector/MobileDevice.asmx%3fWSDL - - - - - Settings - Detector_WebService_MobileDevice - - - - - - - - - - - - - False - False - 5151 - / - http://localhost/Detector - False - False - - - False - - - - - \ No newline at end of file diff --git a/Detector Web Site/Detector.Master b/Detector Web Site/Detector.Master deleted file mode 100644 index 201d538..0000000 --- a/Detector Web Site/Detector.Master +++ /dev/null @@ -1,34 +0,0 @@ -<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Detector.master.cs" Inherits="Detector.Detector" %> - - - - - - - - <% if (Request.Browser.IsMobileDevice) - { %> - - - <% } else { %> - - <% } %> - - - - - - -
- - -
- - diff --git a/Detector Web Site/Detector.Master.cs b/Detector Web Site/Detector.Master.cs deleted file mode 100644 index 7ff58c4..0000000 --- a/Detector Web Site/Detector.Master.cs +++ /dev/null @@ -1,35 +0,0 @@ -/* ********************************************************************* - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. - * See the License for the specific language governing rights and - * limitations under the License. - * - * The Original Code is named .NET Mobile API, first released under - * this licence on 11th March 2009. - * - * The Initial Developer of the Original Code is owned by - * 51 Degrees Mobile Experts Limited. Portions created by 51 Degrees - * Mobile Experts Limited are Copyright (C) 2009 - 2013. All Rights Reserved. - * - * Contributor(s): - * James Rosewell - * - * ********************************************************************* */ - -using System; - -namespace Detector -{ - public partial class Detector : System.Web.UI.MasterPage - { - protected void Page_Load(object sender, EventArgs e) - { - Response.Cache.SetCacheability(System.Web.HttpCacheability.Public); - } - } -} diff --git a/Detector Web Site/Detector.Master.designer.cs b/Detector Web Site/Detector.Master.designer.cs deleted file mode 100644 index 2b21a92..0000000 --- a/Detector Web Site/Detector.Master.designer.cs +++ /dev/null @@ -1,60 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Detector { - - - public partial class Detector { - - /// - /// LinkStyleMobile control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlLink LinkStyleMobile; - - /// - /// LinkStyleStandard control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlLink LinkStyleStandard; - - /// - /// head control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.ContentPlaceHolder head; - - /// - /// formMain control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlForm formMain; - - /// - /// body control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.ContentPlaceHolder body; - } -} diff --git a/Detector Web Site/DeviceProperties.ascx b/Detector Web Site/DeviceProperties.ascx deleted file mode 100644 index cd7bffa..0000000 --- a/Detector Web Site/DeviceProperties.ascx +++ /dev/null @@ -1,156 +0,0 @@ -<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="DeviceProperties.ascx.cs" Inherits="Detector.DeviceProperties" %> -<%@ Register Assembly="FiftyOne.Foundation" Namespace="FiftyOne.Foundation.UI.Web" TagPrefix="fiftyOne" %> - -
- - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - -

This page provides the values .NET will report for properties of the HttpBrowserCapabilities class. Many of these properties are no longer relevent but are provided here for convenience.

-

ActiveXControls <% =Request.Browser.ActiveXControls %>

-

Adapters <% =Request.Browser.Adapters %>

-

AOL <% =Request.Browser.AOL %>

-

BackgroundSounds <% =Request.Browser.BackgroundSounds %>

-

Beta <% =Request.Browser.Beta %>

-

Browser <% =Request.Browser.Browser %>

-

Browsers <% =Request.Browser.Browsers %>

-

CanCombineFormsInDeck <% =Request.Browser.CanCombineFormsInDeck %>

-

CanInitiateVoiceCall <% =Request.Browser.CanInitiateVoiceCall %>

-

CanRenderAfterInputOrSelectElement <% =Request.Browser.CanRenderAfterInputOrSelectElement %>

-

CanRenderEmptySelects <% =Request.Browser.CanRenderEmptySelects %>

-

CanRenderInputAndSelectElementsTogether <% =Request.Browser.CanRenderInputAndSelectElementsTogether %>

-

CanRenderMixedSelects <% =Request.Browser.CanRenderMixedSelects %>

-

CanRenderOneventAndPrevElementsTogether <% =Request.Browser.CanRenderOneventAndPrevElementsTogether %>

-

CanRenderPostBackCards <% =Request.Browser.CanRenderPostBackCards %>

-

CanRenderSetvarZeroWithMultiSelectionList <% =Request.Browser.CanRenderSetvarZeroWithMultiSelectionList %>

-

CanSendMail <% =Request.Browser.CanSendMail %>

-

Capabilities <% =Request.Browser.Capabilities %>

-

CDF <% =Request.Browser.CDF %>

-

ClrVersion <% =Request.Browser.ClrVersion %>

-

Cookies <% =Request.Browser.Cookies %>

-

Crawler <% =Request.Browser.Crawler %>

-

DefaultSubmitButtonLimit <% =Request.Browser.DefaultSubmitButtonLimit %>

-

EcmaScriptVersion <% =Request.Browser.EcmaScriptVersion %>

-

Frames <% =Request.Browser.Frames %>

-

GatewayMajorVersion <% =Request.Browser.GatewayMajorVersion %>

-

GatewayMinorVersion <% =Request.Browser.GatewayMinorVersion %>

-

GatewayVersion <% =Request.Browser.GatewayVersion %>

-

HasBackButton <% =Request.Browser.HasBackButton %>

-

HidesRightAlignedMultiselectScrollbars <% =Request.Browser.HidesRightAlignedMultiselectScrollbars %>

-

HtmlTextWriter <% =Request.Browser.HtmlTextWriter %>

-

Id <% =Request.Browser.Id %>

-

InputType <% =Request.Browser.InputType %>

-

IsColor <% =Request.Browser.IsColor %>

-

IsMobileDevice <% =Request.Browser.IsMobileDevice %>

-

JavaApplets <% =Request.Browser.JavaApplets %>

-

JavaScript <% =Request.Browser.JavaScript %>

-

JScriptVersion <% =Request.Browser.JScriptVersion %>

-

MajorVersion <% =Request.Browser.MajorVersion %>

-

MaximumHrefLength <% =Request.Browser.MaximumHrefLength %>

-

MaximumRenderedPageSize <% =Request.Browser.MaximumRenderedPageSize %>

-

MaximumSoftkeyLabelLength <% =Request.Browser.MaximumSoftkeyLabelLength %>

-

MinorVersion <% =Request.Browser.MinorVersion %>

-

MinorVersionString <% =Request.Browser.MinorVersionString %>

-

MobileDeviceManufacturer <% =Request.Browser.MobileDeviceManufacturer %>

-

MobileDeviceModel <% =Request.Browser.MobileDeviceModel %>

-

MSDomVersion <% =Request.Browser.MSDomVersion %>

-

NumberOfSoftkeys <% =Request.Browser.NumberOfSoftkeys %>

-

Platform <% =Request.Browser.Platform %>

-

PreferredImageMime <% =Request.Browser.PreferredImageMime %>

-

PreferredRenderingMime <% =Request.Browser.PreferredRenderingMime %>

-

PreferredRenderingType <% =Request.Browser.PreferredRenderingType %>

-

PreferredRequestEncoding <% =Request.Browser.PreferredRequestEncoding %>

-

PreferredResponseEncoding <% =Request.Browser.PreferredResponseEncoding %>

-

RendersBreakBeforeWmlSelectAndInput <% =Request.Browser.RendersBreakBeforeWmlSelectAndInput %>

-

RendersBreaksAfterHtmlLists <% =Request.Browser.RendersBreaksAfterHtmlLists %>

-

RendersBreaksAfterWmlAnchor <% =Request.Browser.RendersBreaksAfterWmlAnchor %>

-

RendersBreaksAfterWmlInput <% =Request.Browser.RendersBreaksAfterWmlInput %>

-

RendersWmlDoAcceptsInline <% =Request.Browser.RendersWmlDoAcceptsInline %>

-

RendersWmlSelectsAsMenuCards <% =Request.Browser.RendersWmlSelectsAsMenuCards %>

-

RequiredMetaTagNameValue <% =Request.Browser.RequiredMetaTagNameValue %>

-

RequiresAttributeColonSubstitution <% =Request.Browser.RequiresAttributeColonSubstitution %>

-

RequiresContentTypeMetaTag <% =Request.Browser.RequiresContentTypeMetaTag %>

-

RequiresControlStateInSession <% =Request.Browser.RequiresControlStateInSession %>

-

RequiresDBCSCharacter <% =Request.Browser.RequiresDBCSCharacter %>

-

RequiresHtmlAdaptiveErrorReporting <% =Request.Browser.RequiresHtmlAdaptiveErrorReporting %>

-

RequiresLeadingPageBreak <% =Request.Browser.RequiresLeadingPageBreak %>

-

RequiresNoBreakInFormatting <% =Request.Browser.RequiresNoBreakInFormatting %>

-

RequiresOutputOptimization <% =Request.Browser.RequiresOutputOptimization %>

-

RequiresPhoneNumbersAsPlainText <% =Request.Browser.RequiresPhoneNumbersAsPlainText %>

-

RequiresSpecialViewStateEncoding <% =Request.Browser.RequiresSpecialViewStateEncoding %>

-

RequiresUniqueFilePathSuffix <% =Request.Browser.RequiresUniqueFilePathSuffix %>

-

RequiresUniqueHtmlCheckboxNames <% =Request.Browser.RequiresUniqueHtmlCheckboxNames %>

-

RequiresUniqueHtmlInputNames <% =Request.Browser.RequiresUniqueHtmlInputNames %>

-

RequiresUrlEncodedPostfieldValues <% =Request.Browser.RequiresUrlEncodedPostfieldValues %>

-

ScreenBitDepth <% =Request.Browser.ScreenBitDepth %>

-

ScreenCharactersHeight <% =Request.Browser.ScreenCharactersHeight %>

-

ScreenCharactersWidth <% =Request.Browser.ScreenCharactersWidth %>

-

ScreenPixelsHeight <% =Request.Browser.ScreenPixelsHeight %>

-

ScreenPixelsWidth <% =Request.Browser.ScreenPixelsWidth %>

-

SupportsAccesskeyAttribute <% =Request.Browser.SupportsAccesskeyAttribute %>

-

SupportsBodyColor <% =Request.Browser.SupportsBodyColor %>

-

SupportsBold <% =Request.Browser.SupportsBold %>

-

SupportsCacheControlMetaTag <% =Request.Browser.SupportsCacheControlMetaTag %>

-

SupportsCallback <% =Request.Browser.SupportsCallback %>

-

SupportsCss <% =Request.Browser.SupportsCss %>

-

SupportsDivAlign <% =Request.Browser.SupportsDivAlign %>

-

SupportsDivNoWrap <% =Request.Browser.SupportsDivNoWrap %>

-

SupportsEmptyStringInCookieValue <% =Request.Browser.SupportsEmptyStringInCookieValue %>

-

SupportsFontColor <% =Request.Browser.SupportsFontColor %>

-

SupportsFontName <% =Request.Browser.SupportsFontName %>

-

SupportsFontSize <% =Request.Browser.SupportsFontSize %>

-

SupportsImageSubmit <% =Request.Browser.SupportsImageSubmit %>

-

SupportsIModeSymbols <% =Request.Browser.SupportsIModeSymbols %>

-

SupportsInputIStyle <% =Request.Browser.SupportsInputIStyle %>

-

SupportsInputMode <% =Request.Browser.SupportsInputMode %>

-

SupportsItalic <% =Request.Browser.SupportsItalic %>

-

SupportsJPhoneMultiMediaAttributes <% =Request.Browser.SupportsJPhoneMultiMediaAttributes %>

-

SupportsJPhoneSymbols <% =Request.Browser.SupportsJPhoneSymbols %>

-

SupportsQueryStringInFormAction <% =Request.Browser.SupportsQueryStringInFormAction %>

-

SupportsRedirectWithCookie <% =Request.Browser.SupportsRedirectWithCookie %>

-

SupportsSelectMultiple <% =Request.Browser.SupportsSelectMultiple %>

-

SupportsUncheck <% =Request.Browser.SupportsUncheck %>

-

SupportsXmlHttp <% =Request.Browser.SupportsXmlHttp %>

-

Tables <% =Request.Browser.Tables %>

-

TagWriter <% =Request.Browser.TagWriter %>

-

Type <% =Request.Browser.Type %>

-

UseOptimizedCacheKey <% =Request.Browser.UseOptimizedCacheKey %>

-

VBScript <% =Request.Browser.VBScript %>

-

Version <% =Request.Browser.Version %>

-

W3CDomVersion <% =Request.Browser.W3CDomVersion %>

-

Win16 <% =Request.Browser.Win16 %>

-

Win32 <% =Request.Browser.Win32 %>

-
-
-
\ No newline at end of file diff --git a/Detector Web Site/DeviceProperties.ascx.cs b/Detector Web Site/DeviceProperties.ascx.cs deleted file mode 100644 index aa99bb6..0000000 --- a/Detector Web Site/DeviceProperties.ascx.cs +++ /dev/null @@ -1,132 +0,0 @@ -/* ********************************************************************* - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. - * See the License for the specific language governing rights and - * limitations under the License. - * - * The Original Code is named .NET Mobile API, first released under - * this licence on 11th March 2009. - * - * The Initial Developer of the Original Code is owned by - * 51 Degrees Mobile Experts Limited. Portions created by 51 Degrees - * Mobile Experts Limited are Copyright (C) 2009 - 2013. All Rights Reserved. - * - * Contributor(s): - * James Rosewell - * - * ********************************************************************* */ - -using System; -using System.Web; -using System.Web.UI.WebControls; - -namespace Detector -{ - public partial class DeviceProperties : System.Web.UI.UserControl - { - /// - /// Sets the device Id to the current device. - /// - /// - protected override void OnInit(EventArgs e) - { - Current.DeviceID = Request.Browser["Id"]; - HttpCookie cookie; - try - { - cookie = Request.Cookies["tab"]; - } - catch - { - cookie = null; - } - if (cookie != null) - SetTab(cookie.Value); - else - SetTab(DictionaryView.ID); - base.OnLoad(e); - } - - protected override void OnPreRender(EventArgs e) - { - CurrentButton.CssClass = String.Join(" ", new[] { - "tab", Tabs.GetActiveView() == CurrentView ? "active" : String.Empty }); - ExplorerButton.CssClass = String.Join(" ", new[] { - "tab", Tabs.GetActiveView() == ExplorerView ? "active" : String.Empty }); - TopButton.CssClass = String.Join(" ", new[] { - "tab", Tabs.GetActiveView() == TopView ? "active" : String.Empty }); - DictionaryButton.CssClass = String.Join(" ", new[] { - "tab", Tabs.GetActiveView() == DictionaryView ? "active" : String.Empty }); - UserAgentTesterButton.CssClass = String.Join(" ", new[] { - "tab", Tabs.GetActiveView() == UserAgentTesterView ? "active" : String.Empty }); - RedirectButton.CssClass = String.Join(" ", new[] { - "tab", Tabs.GetActiveView() == RedirectView ? "active" : String.Empty }); - DetectionButton.CssClass = String.Join(" ", new[] { - "tab", Tabs.GetActiveView() == DetectionView ? "active" : String.Empty }); - StandardPropertiesButton.CssClass = String.Join(" ", new[] { - "tab", Tabs.GetActiveView() == StandardPropertiesView ? "active" : String.Empty }); - - HttpCookie cookie = Request.Cookies["tab"]; - if (cookie == null) - cookie = new HttpCookie("tab"); - cookie.Value = Tabs.GetActiveView().ID; - Response.Cookies.Add(cookie); - - base.OnPreRender(e); - } - - protected void TabChange(object sender, CommandEventArgs e) - { - SetTab(e.CommandArgument as string); - } - - private void SetTab(string name) - { - switch (name) - { - default: - case "CurrentView": - Tabs.SetActiveView(CurrentView); - CurrentButton.CssClass = "active"; - break; - case "ExplorerView": - Tabs.SetActiveView(ExplorerView); - ExplorerButton.CssClass = "active"; - break; - case "TopView": - { - if (TopDevices.SelectedDevice != null) - goto case "ExplorerView"; - Tabs.SetActiveView(TopView); - TopButton.CssClass = "active"; - break; - } - case "DictionaryView": - Tabs.SetActiveView(DictionaryView); - DictionaryButton.CssClass = "active"; - break; - case "UserAgentTesterView": - Tabs.SetActiveView(UserAgentTesterView); - UserAgentTesterButton.CssClass = "active"; - break; - case "RedirectView": - Tabs.SetActiveView(RedirectView); - RedirectButton.CssClass = "active"; - break; - case "DetectionView": - Tabs.SetActiveView(DetectionView); - DetectionButton.CssClass = "active"; - break; - case "StandardPropertiesView": - Tabs.SetActiveView(StandardPropertiesView); - StandardPropertiesButton.CssClass = "active"; - break; - } - } - } -} \ No newline at end of file diff --git a/Detector Web Site/DeviceProperties.ascx.designer.cs b/Detector Web Site/DeviceProperties.ascx.designer.cs deleted file mode 100644 index 567d5be..0000000 --- a/Detector Web Site/DeviceProperties.ascx.designer.cs +++ /dev/null @@ -1,241 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.5466 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Detector { - - - public partial class DeviceProperties { - - /// - /// CurrentButton control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button CurrentButton; - - /// - /// ExplorerButton control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button ExplorerButton; - - /// - /// TopButton control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button TopButton; - - /// - /// DictionaryButton control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button DictionaryButton; - - /// - /// UserAgentTesterButton control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button UserAgentTesterButton; - - /// - /// RedirectButton control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button RedirectButton; - - /// - /// DetectionButton control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button DetectionButton; - - /// - /// StandardPropertiesButton control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button StandardPropertiesButton; - - /// - /// Tabs control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.MultiView Tabs; - - /// - /// CurrentView control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.View CurrentView; - - /// - /// Current control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::FiftyOne.Foundation.UI.Web.DeviceExplorer Current; - - /// - /// ExplorerView control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.View ExplorerView; - - /// - /// Message1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::FiftyOne.Foundation.UI.Web.LiteMessage Message1; - - /// - /// Explorer control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::FiftyOne.Foundation.UI.Web.DeviceExplorer Explorer; - - /// - /// TopView control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.View TopView; - - /// - /// TopDevices control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::FiftyOne.Foundation.UI.Web.TopDevices TopDevices; - - /// - /// DictionaryView control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.View DictionaryView; - - /// - /// Dictionary control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::FiftyOne.Foundation.UI.Web.PropertyDictionary Dictionary; - - /// - /// UserAgentTesterView control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.View UserAgentTesterView; - - /// - /// UserAgentTester control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::FiftyOne.Foundation.UI.Web.UserAgentTester UserAgentTester; - - /// - /// RedirectView control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.View RedirectView; - - /// - /// Redirect control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::FiftyOne.Foundation.UI.Web.Redirect Redirect; - - /// - /// DetectionView control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.View DetectionView; - - /// - /// Detection control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::FiftyOne.Foundation.UI.Web.Detection Detection; - - /// - /// StandardPropertiesView control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.View StandardPropertiesView; - } -} diff --git a/Detector Web Site/Global.asax b/Detector Web Site/Global.asax deleted file mode 100644 index 11f9d2e..0000000 --- a/Detector Web Site/Global.asax +++ /dev/null @@ -1 +0,0 @@ -<%@ Application Codebehind="Global.asax.cs" Inherits="Detector.Global" Language="C#" %> diff --git a/Detector Web Site/Global.asax.cs b/Detector Web Site/Global.asax.cs deleted file mode 100644 index 4cf6b9a..0000000 --- a/Detector Web Site/Global.asax.cs +++ /dev/null @@ -1,53 +0,0 @@ -/* ********************************************************************* - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. - * See the License for the specific language governing rights and - * limitations under the License. - * - * The Original Code is named .NET Mobile API, first released under - * this licence on 11th March 2009. - * - * The Initial Developer of the Original Code is owned by - * 51 Degrees Mobile Experts Limited. Portions created by 51 Degrees - * Mobile Experts Limited are Copyright (C) 2009 - 2013. All Rights Reserved. - * - * Contributor(s): - * James Rosewell - * - * ********************************************************************* */ - -#if VER4 -using System; -using System.Web.Configuration; -#endif - -namespace Detector -{ - public class Global : System.Web.HttpApplication - { - // .NET v4 ONLY - // Uncomment the following code to use Global.asax rather than web.config HttpModules - // to invoke device detection and redirection functionality. Do not use both HttpModules - // and the following uncommented code. Unpredictable results may be experienced. - -#if VER4 - //protected void Application_Start(object sender, EventArgs e) - //{ - // // Enable the mobile detection provider. - // HttpCapabilitiesBase.BrowserCapabilitiesProvider = - // new FiftyOne.Foundation.Mobile.Detection.MobileCapabilitiesProvider(); - //} - - //protected void Application_AcquireRequestState(object sender, EventArgs e) - //{ - // // Check if a redirection is needed. - // FiftyOne.Foundation.Mobile.Redirection.RedirectModule.OnPostAcquireRequestState(sender, e); - //} -#endif - } -} \ No newline at end of file diff --git a/Detector Web Site/Licence.txt b/Detector Web Site/Licence.txt deleted file mode 100644 index ae0b1a2..0000000 --- a/Detector Web Site/Licence.txt +++ /dev/null @@ -1,19 +0,0 @@ -The contents of this file are subject to the Mozilla Public License -Version 1.1 (the "License"); you may not use this file except in -compliance with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. -See the License for the specific language governing rights and -limitations under the License. - -The Original Code is named .NET Mobile API, first released under -this licence on 11th March 2009. - -The Initial Developer of the Original Code is owned by -51 Degrees Mobile Experts Limited. Portions created by 51 Degrees -Mobile Experts Limited are Copyright (C) 2009 - 2013. All Rights Reserved. - -Contributor(s): - James Rosewell \ No newline at end of file diff --git a/Detector Web Site/LogTable.aspx b/Detector Web Site/LogTable.aspx deleted file mode 100644 index 32c7548..0000000 --- a/Detector Web Site/LogTable.aspx +++ /dev/null @@ -1,29 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LogTable.aspx.cs" Inherits="Detector.Table" ValidateRequest="false" %> - - - - - Log - - - -
-
-

51Degrees.mobi Foundation Log

- This page demonstrates how to view the Azure log table. To compile insert 'AZURE' as compilation symbol in the build tab of - the Detector and Foundation project properties. -
- - - - - -
- - - -
-
-
- - diff --git a/Detector Web Site/LogTable.aspx.cs b/Detector Web Site/LogTable.aspx.cs deleted file mode 100644 index 2e40eca..0000000 --- a/Detector Web Site/LogTable.aspx.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -#if AZURE -using Microsoft.WindowsAzure; -using Microsoft.WindowsAzure.StorageClient; -using Microsoft.WindowsAzure.ServiceRuntime; -#endif - -namespace Detector -{ - public partial class Table : System.Web.UI.Page - { - protected void Page_Load(object sender, EventArgs e) - { - Load_Data(); - } - - protected void Load_Data() - { -#if AZURE - //Access the storage account - var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("fiftyonedegrees")); - //Create the service context to access the table - var serviceContext = new TableServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials); - - //Getting the table entries - foreach (var row in serviceContext.CreateQuery("log")) //"log" - the name of the table you wish to see - { - OutBox.Text += row.Message; - } -#else - OutBox.Text = "This page will only work when compiled for use with Windows Azure"; -#endif - } - - protected void DelAllBut_Click(object sender, EventArgs e) - { -#if AZURE - var storageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue("fiftyonedegrees")); - var serviceContext = new TableServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials); - storageAccount.CreateCloudTableClient().CreateTableIfNotExist("log"); - - foreach (var row in serviceContext.CreateQuery("log")) - { - serviceContext.DeleteObject(row); - } - serviceContext.SaveChanges(); - - Page.Response.Redirect(Page.Request.Url.ToString(), true); -#endif - } - } -} \ No newline at end of file diff --git a/Detector Web Site/LogTable.aspx.designer.cs b/Detector Web Site/LogTable.aspx.designer.cs deleted file mode 100644 index 575561c..0000000 --- a/Detector Web Site/LogTable.aspx.designer.cs +++ /dev/null @@ -1,51 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Detector { - - - public partial class Table { - - /// - /// CSS control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlLink CSS; - - /// - /// form1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlForm form1; - - /// - /// OutBox control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox OutBox; - - /// - /// DelAllBut control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button DelAllBut; - } -} diff --git a/Detector Web Site/Mobile.css b/Detector Web Site/Mobile.css deleted file mode 100644 index 7960bb0..0000000 --- a/Detector Web Site/Mobile.css +++ /dev/null @@ -1,417 +0,0 @@ -/* ********************************************************************* - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. - * See the License for the specific language governing rights and - * limitations under the License. - * - * The Original Code is named .NET Mobile API, first released under - * this licence on 11th March 2009. - * - * The Initial Developer of the Original Code is owned by - * 51 Degrees Mobile Experts Limited. Portions created by 51 Degrees - * Mobile Experts Limited are Copyright (C) 2009 - 2013. All Rights Reserved. - * - * Contributor(s): - * James Rosewell - * - * ********************************************************************* */ - -body -{ - background: #FFFFFF; - font-size: 10pt; - font-family: "Segoe UI" , "Helvetica Neue" , "Lucida Grande" , Arial, Helvetica, Verdana, sans-serif; - padding: 0px; - color: #696969; - margin: 0px auto; -} - -table -{ - margin-bottom: 0px; -} - -td -{ - vertical-align: bottom; -} - -h1 -{ - margin: 0.5em; - font-size: 1.3em; - clear: both; -} - -h2 -{ - margin: 0.5em; - font-size: 1.1em; - clear: both; -} - -a:link, a:visited -{ - color: #696969; -} - -.menuLink -{ - width: 100%; - vertical-align: middle; - padding: 0.5em; - text-align: left; - border-bottom: 1px solid #FFFFFF; - background-color: #AAAAAA; - background-image: url('Images/ButtonBackground.svg'); -} - -.menuLink .text td -{ - width: 100%; -} - -.menuLink .text a -{ - display: block; - float: left; - width: 100%; - height: 100%; - color: #FFFFFF; - text-decoration: none; -} - -.menuLink .rightArrow -{ - width: 1em; -} - -.menuLink .rightArrow img -{ - float: right; - border: none; -} - -.menuLink .leftArrow -{ - width: 1em; -} - -.menuLink .leftArrow img -{ - float: left; -} - -.border -{ - border: 1px solid #CCCCCC; - padding: 0.5em; - margin: 0px; -} - -.deviceExplorerVendors .item -{ - margin: 0.5em; - height: 2.5em; - width: 100px; - float: left; - display: block; - overflow: hidden; - vertical-align: top; -} - -.deviceExplorerVendors .item .vendor -{ - text-align: center; - font-weight: bold; -} - -.deviceExplorerDevices .item -{ - background-color: #EEEEEE; - margin: 2px; - padding: 0.5em; - height: 3em; - width: 100px; - display: block; - float: left; - text-align: center; - vertical-align: top; - overflow: hidden; -} - -.deviceExplorerDevices .item .model -{ - font-weight: bold; -} - -.deviceExplorerDevices .item .model a -{ - text-decoration: none; - color: Red; -} - -.deviceExplorerDevices .item .name -{ - overflow: hidden; -} - -.deviceExplorerDevices .item .name a -{ - text-decoration: none; - color: #777777; - padding-top: 0.5em; -} - -.propertyDictionary .item table -{ - margin: 0.5em; -} - -.propertyDictionary .description -{ - margin: 0.5em; - display: inline-block; - color: #222222; -} - -.deviceExplorerDevice .cms, .propertyDictionary .cms -{ - color: #008500; -} - -.deviceExplorerDevice .premium, .propertyDictionary .premium -{ - color: #b22222; -} - -.deviceExplorerDevice .lite, .propertyDictionary .lite -{ - color: #777777; -} - -.deviceExplorerDevice .property, .propertyDictionary .property -{ - float: left; - margin: 0.5em; -} - -.deviceExplorerDevice .property a, .propertyDictionary .property a -{ - text-decoration: none; -} - -.propertyDictionary .value -{ - font-weight: bold; - display: block; - margin: 0.5em; - height: 100%; - vertical-align: middle; -} - -.deviceExplorerDevice -{ - display: block; - clear: both; - height: 100%; -} - -.deviceExplorerDevice .value -{ - font-weight: bold; - display: inline-block; - margin: 0.5em; -} - -.deviceExplorerDevice .wide -{ - vertical-align: top; - margin: 0.5em; -} - -.deviceExplorerDevice .item -{ - float: left; - vertical-align: top; - margin: 0.5em; -} - -.deviceExplorerDevice .back, .deviceExplorerDevices .back -{ - padding: 1em 0.5em 1em 0px; - clear: both; -} - -.deviceExplorerDevice .back a, .deviceExplorerDevices .back a -{ - padding: 0.5em; - border: 1px solid #DDDDDD; - background-color: #EEEEEE; - text-decoration: none; -} - -.tabs -{ - -} - -.tab -{ - display: inline-block; - vertical-align: bottom; - border: 1px solid #DDDDDD; - background-color: #EEEEEE; - color: #777777; - margin: 0px 1px; -} - -.active -{ - border: 1px solid #CCCCCC; - color: #000000; - font-weight: bold; - height: 2em; - background-color: #CCCCCC; -} - -.checkbox -{ - display: inline-block; -} - -.hyperlink -{ - display: inline-block; - margin-left: 1em; -} - -.textbox -{ - width: 100%; - margin: 0.5em 0px; - display: block; -} - -.button -{ - margin: 0.5em 0px; - display: block; -} - -.success -{ - margin: 0.5em 0px; - color: Green; - display: block; -} - -.error -{ - margin: 0.5em 0px; - color: Red; - display: block; -} - -.footer -{ - margin: 0.5em 0px; - padding: 0.5em 0px; - border-top: 1px solid #DDDDDD; -} - -.footer span -{ - margin-right: 3em; -} - -.redirect table -{ - border-collapse: collapse -} - -.redirect table tr td -{ - padding: 0.2em; -} - -.redirect table tr th -{ - font-weight: bold; -} - -.redirect .basic, .redirect .locations -{ - display: inline-block; -} - -.redirect .basic -{ - width: 200px; -} - -.redirect .locations -{ - margin-left: 1em; - padding-left: 1em; - border-left: 1px solid #DDDDDD; - clear:right; -} - -.redirect .buttons -{ - clear: both; -} - -.redirect .label -{ - color: #000000; -} - -.redirect .location -{ - background-color: #DDDDDD; -} - -.redirect .altlocation -{ - background-color: #EEEEEE; -} - -.redirect .locations .textbox -{ - width: 100px; -} - -.redirect .button -{ - display: inline; - margin: 0.5em; -} - -.redirect .ddl -{ - width: 150px; -} - -.match -{ - margin-left: 1em; -} - -.match th -{ - font-weight: bold; - text-align: left; -} - -.match td -{ - padding-left: 1em; - font-family: Courier; -} \ No newline at end of file diff --git a/Detector Web Site/Mobile.png b/Detector Web Site/Mobile.png deleted file mode 100644 index 2abef8a..0000000 Binary files a/Detector Web Site/Mobile.png and /dev/null differ diff --git a/Detector Web Site/Mobile/Default.aspx b/Detector Web Site/Mobile/Default.aspx deleted file mode 100644 index 0a74e2a..0000000 --- a/Detector Web Site/Mobile/Default.aspx +++ /dev/null @@ -1,17 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Detector.Master" CodeBehind="Default.aspx.cs" Inherits="Detector.Mobile.Default" EnableSessionState="True" EnableViewState="false" %> -<%@ OutputCache VaryByParam="*" VaryByHeader="User-Agent" Duration="240" Location="Any" %> -<%@ Register Src="~/DeviceProperties.ascx" TagPrefix="uc" TagName="DeviceProperties" %> - - - Mobile - - - -
-
- " alt="Mobile" style="vertical-align: middle;"/> - Mobile -
-
- -
diff --git a/Detector Web Site/Mobile/Default.aspx.cs b/Detector Web Site/Mobile/Default.aspx.cs deleted file mode 100644 index d35f507..0000000 --- a/Detector Web Site/Mobile/Default.aspx.cs +++ /dev/null @@ -1,29 +0,0 @@ -/* ********************************************************************* - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. - * See the License for the specific language governing rights and - * limitations under the License. - * - * The Original Code is named .NET Mobile API, first released under - * this licence on 11th March 2009. - * - * The Initial Developer of the Original Code is owned by - * 51 Degrees Mobile Experts Limited. Portions created by 51 Degrees - * Mobile Experts Limited are Copyright (C) 2009 - 2013. All Rights Reserved. - * - * Contributor(s): - * James Rosewell - * - * ********************************************************************* */ - -namespace Detector.Mobile -{ - public partial class Default : System.Web.UI.Page - { - } -} diff --git a/Detector Web Site/Mobile/Default.aspx.designer.cs b/Detector Web Site/Mobile/Default.aspx.designer.cs deleted file mode 100644 index 15c8ba5..0000000 --- a/Detector Web Site/Mobile/Default.aspx.designer.cs +++ /dev/null @@ -1,24 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Detector.Mobile { - - - public partial class Default { - - /// - /// Device control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Detector.DeviceProperties Device; - } -} diff --git a/Detector Web Site/MobileDevice.asmx b/Detector Web Site/MobileDevice.asmx deleted file mode 100644 index 64ca7ac..0000000 --- a/Detector Web Site/MobileDevice.asmx +++ /dev/null @@ -1 +0,0 @@ -<%@ WebService Language="C#" CodeBehind="MobileDevice.asmx.cs" Class="Detector.MobileDevice" %> diff --git a/Detector Web Site/MobileDevice.asmx.cs b/Detector Web Site/MobileDevice.asmx.cs deleted file mode 100644 index 34cc7e1..0000000 --- a/Detector Web Site/MobileDevice.asmx.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Web.Services; - -namespace Detector -{ - /// - /// Class used to provide properties and associated values. - /// - [Serializable] - public class Property - { - public string Name; - public string[] Values; - - public Property() { } - - public Property(string name, string[] values) - { - Name = name; - Values = values; - } - } - - /// - /// Example web server for returning 51Degrees.mobi properties. Session is disabled. - /// - [WebService(Namespace = "http://mobiledevice.51degrees.mobi/")] - [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] - [System.ComponentModel.ToolboxItem(false)] - public class MobileDevice : System.Web.Services.WebService - { - /// - /// Returns a property value based on the name. - /// Returns null if a property name match wasn't found. - /// - /// The name of a 51Degrees.mobi or .NET property. - /// - [WebMethod(false)] - public string GetProperty(string propertyName) - { - // First looks for a 51Degrees.mobi property name. - if (Context.Request.Browser[propertyName] != null) - return Context.Request.Browser[propertyName]; - - // Then looks for a .NET property name. - if (Context.Request.Browser.Capabilities[propertyName] != null) - return Context.Request.Browser.Capabilities[propertyName].ToString(); - - // No match found, return null. - return null; - } - - /// - /// Returns a list of properties in a string array in the same order they were given. - /// Any property not matched are set as null. - /// - /// An array of 51Degrees.mobi or .NET capability names. - /// - [WebMethod(false)] - public string[] GetProperties(string[] propertyNames) - { - // Checks if the array is populated. - if (propertyNames == null) - return null; - - // Cycles through the array and replaces the property string with the resulting property string. - for (int i = 0; i < propertyNames.Length; i++) - { - // First looks for a 51Degrees.mobi property name. - if (Context.Request.Browser[propertyNames[i]] != null) - propertyNames[i] = Context.Request.Browser[propertyNames[i]]; - - // Then tries a .NET property name. - else if (Context.Request.Browser.Capabilities[propertyNames[i]] != null) - propertyNames[i] = Context.Request.Browser.Capabilities[propertyNames[i]].ToString(); - - // Property name not found, give null instead. - else - propertyNames[i] = null; - } - return propertyNames; - } - - /// - /// Returns an array of property types containing the property names - /// and values for all properties associated with the device. - /// - /// Array of property types. - [WebMethod(false)] - public Property[] GetAllProperties() - { - List results = new List(); - - // Get all the properties and values for the device. - SortedList> allProperties = - Context.Request.Browser.Capabilities["51Degrees.mobi"] as SortedList>; - - // Check properties are available in case the device couldn't - // be determined. - if (allProperties != null) - { - // Copy all the properties and values to the return format. - allProperties.Capacity = allProperties.Count; - foreach (string key in allProperties.Keys) - if (allProperties[key].Count > 0) - results.Add(new Property(key, allProperties[key].ToArray())); - } - - return results.ToArray(); - } - } -} \ No newline at end of file diff --git a/Detector Web Site/Properties/AssemblyInfo.cs b/Detector Web Site/Properties/AssemblyInfo.cs deleted file mode 100644 index c497c33..0000000 --- a/Detector Web Site/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Detector")] -[assembly: AssemblyDescription("Mobile Device Detector Example")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("51 Degrees Mobile Experts Limited")] -[assembly: AssemblyProduct("Mobile Device Detector Example")] -[assembly: AssemblyCopyright("Copyright © 51 Degrees Mobile Experts Limited 2009 - 2013")] -[assembly: AssemblyTrademark("51degrees.mobi")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3d5900ae-111a-45be-96b3-d9e4606ca793")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("2.1.19.1")] -[assembly: AssemblyFileVersion("2.1.19.1")] -[assembly: NeutralResourcesLanguage("en-GB")] diff --git a/Detector Web Site/Properties/Settings.Designer.cs b/Detector Web Site/Properties/Settings.Designer.cs deleted file mode 100644 index a3463a0..0000000 --- a/Detector Web Site/Properties/Settings.Designer.cs +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.261 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Detector.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)] - [global::System.Configuration.DefaultSettingValueAttribute("http://localhost/Detector4/MobileDevice.asmx")] - public string Detector_WebService_MobileDevice { - get { - return ((string)(this["Detector_WebService_MobileDevice"])); - } - } - } -} diff --git a/Detector Web Site/Properties/Settings.settings b/Detector Web Site/Properties/Settings.settings deleted file mode 100644 index 4fc0058..0000000 --- a/Detector Web Site/Properties/Settings.settings +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - http://localhost/Detector4/MobileDevice.asmx - - - \ No newline at end of file diff --git a/Detector Web Site/Standard.css b/Detector Web Site/Standard.css deleted file mode 100644 index e2002b6..0000000 --- a/Detector Web Site/Standard.css +++ /dev/null @@ -1,496 +0,0 @@ -/* ********************************************************************* - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. - * See the License for the specific language governing rights and - * limitations under the License. - * - * The Original Code is named .NET Mobile API, first released under - * this licence on 11th March 2009. - * - * The Initial Developer of the Original Code is owned by - * 51 Degrees Mobile Experts Limited. Portions created by 51 Degrees - * Mobile Experts Limited are Copyright (C) 2009 - 2013. All Rights Reserved. - * - * Contributor(s): - * James Rosewell - * - * ********************************************************************* */ - -body -{ - background: #FFFFFF; - font-size: 10pt; - font-family: "Segoe UI" , "Helvetica Neue" , "Lucida Grande" , Arial, Helvetica, Verdana, sans-serif; - padding: 0px; - color: #696969; - margin: 0px auto; -} - -table -{ - margin: 0px; - padding: 0px; -} - -td -{ - margin: 0px; - padding: 0px; - vertical-align: middle; -} - -h1 -{ - margin: 0.5em 0px; - font-size: 1.3em; - clear: both; -} - -h2 -{ - margin: 0.5em 0px; - font-size: 1.1em; - clear: both; -} - -a:link, a:visited -{ - color: #696969; -} - -.menuLink -{ - width: 100%; - vertical-align: middle; - padding: 0.5em; - text-align: left; - border-bottom: 1px solid #FFFFFF; - background-color: #AAAAAA; - background-image: url('Images/ButtonBackground.svg'); -} - -.menuLink .text td -{ - width: 100%; -} - -.menuLink .text a -{ - display: block; - float: left; - width: 100%; - height: 100%; - color: #FFFFFF; - text-decoration: none; -} - -.menuLink .rightArrow -{ - width: 1em; -} - -.menuLink .rightArrow img -{ - float: right; - border: none; -} - -.menuLink .leftArrow -{ - width: 1em; -} - -.menuLink .leftArrow img -{ - float: left; -} - -.border -{ - border: 1px solid #CCCCCC; - padding: 0.5em; - margin: 0px; - clear: both; -} - -.deviceExplorerVendors .item -{ - margin: 0.5em; - height: 2.5em; - width: 100px; - float: left; - display: block; - overflow: hidden; - vertical-align: top; -} - -.deviceExplorerVendors .item .vendor -{ - text-align: center; - font-weight: bold; -} - -.deviceExplorerDevices .item -{ - background-color: #EEEEEE; - margin: 2px; - padding: 0.5em; - height: 15em; - width: 150px; - display: block; - float: left; - text-align: center; - vertical-align: top; - overflow: hidden; -} - -.deviceExplorerDevices .item .model -{ - font-weight: bold; -} - -.deviceExplorerDevices .item .model a -{ - text-decoration: none; - color: Red; -} - -.deviceExplorerDevices .item .name -{ - overflow: hidden; -} - -.deviceExplorerDevices .item .name a -{ - text-decoration: none; - color: #777777; - padding-top: 0.5em; -} - -.topDevices .item -{ - margin: 0.5em; - height: 2.5em; - width: 100px; - float: left; - display: block; - overflow: hidden; - vertical-align: top; -} - -.topDevices .item .vendor -{ - text-align: center; - font-weight: bold; -} - -.topDevices .item -{ - background-color: #EEEEEE; - margin: 2px; - padding: 0.5em; - height: 15em; - width: 150px; - display: block; - float: left; - text-align: center; - vertical-align: top; - overflow: hidden; -} - -.topDevices .item .model -{ - font-weight: bold; -} - -.topDevices .item .model a -{ - text-decoration: none; - color: Red; -} - -.topDevices .item .name -{ - overflow: hidden; -} - -.topDevices .item .name a -{ - text-decoration: none; - color: #777777; - padding-top: 0.5em; -} - -.propertyDictionary .item table -{ - margin: 0.5em; -} - -.propertyDictionary .description -{ - width: 590px; - margin: 0.5em; - color: #222222; - display: inline-block; -} - -.deviceExplorerDevice .cms, .propertyDictionary .cms -{ - color: #008500; -} - -.deviceExplorerDevice .premium, .propertyDictionary .premium -{ - color: #b22222; -} - -.deviceExplorerDevice .lite, .propertyDictionary .lite -{ - color: #777777; -} - -.deviceExplorerDevice .property, .propertyDictionary .property -{ - width: 220px; - float: left; - margin: 0.5em; -} - -.deviceExplorerDevice .property a, .propertyDictionary .property a -{ - text-decoration: none; -} - -.propertyDictionary .value -{ - font-weight: bold; - display: block; - margin: 0.5em 0px; - height: 100%; - vertical-align: middle; -} - -.deviceImageCaption -{ - text-align: center; -} - -.deviceExplorerDevice -{ - display: block; - clear: both; - height: 100%; -} - -.deviceExplorerDevice .value -{ - font-weight: bold; - display: inline-block; - margin: 0.5em; -} - -.deviceExplorerDevice .wide -{ - width: 800px; - vertical-align: top; - margin: 0.5em; -} - -.deviceExplorerDevice .item -{ - float: left; - vertical-align: top; - width: 450px; - margin: 0.5em; -} - -.deviceExplorerDevice .back, .deviceExplorerDevices .back -{ - padding: 1em 0.5em 1em 0px; - clear: both; -} - -.deviceExplorerDevice .back a, .deviceExplorerDevices .back a -{ - padding: 0.5em; - border: 1px solid #DDDDDD; - background-color: #EEEEEE; - text-decoration: none; -} - -.tabs -{ - -} - -.tab -{ - display: inline-block; - vertical-align: bottom; - border: 1px solid #DDDDDD; - background-color: #EEEEEE; - color: #777777; - margin: 0px 1px; -} - -.active -{ - border: 1px solid #CCCCCC; - color: #000000; - font-weight: bold; - height: 2em; - background-color: #CCCCCC; -} - -.checkbox -{ - display: inline-block; -} - -.hyperlink -{ - display: inline-block; - margin-left: 1em; -} - -.textbox -{ - width: 100%; - margin: 0.5em 0px; - display: block; -} - -.button -{ - margin: 0.5em 0px; - display: block; -} - -.success -{ - margin: 0.5em 0px; - color: Green; - background-color: #90EE90; - display: block; -} - -.error -{ - margin: 0.5em 0px; - color: Red; - background-color: #FFC0CB; - display: block; -} - -div.error, div.success -{ - padding: 1em; -} - -.footer -{ - margin: 0.5em 0px; - padding: 0.5em 0px; - border-top: 1px solid #DDDDDD; -} - -.footer span -{ - margin-right: 3em; -} - -.redirect -{ - vertical-align: top; -} - -.redirect table -{ - border-collapse: collapse -} - -.redirect table tr td -{ - padding: 0.2em; -} - -.redirect table tr th -{ - font-weight: bold; -} - -.redirect .basic, .redirect .locations -{ - display: inline-block; -} - -.redirect .basic -{ - width: 200px; -} - -.redirect .locations -{ - margin-left: 1em; - padding-left: 1em; - border-left: 1px solid #DDDDDD; - clear:right; -} - -.redirect .buttons -{ - clear: both; -} - -.redirect .label -{ - color: #000000; -} - -.redirect .location -{ - background-color: #DDDDDD; -} - -.redirect .altlocation -{ - background-color: #EEEEEE; -} - -.redirect .locations .textbox -{ - width: 100px; -} - -.redirect .button -{ - display: inline; - margin: 0.5em; -} - -.redirect .ddl -{ - width: 150px; -} - -.match -{ - margin-left: 1em; -} - -.match th -{ - font-weight: bold; - text-align: left; -} - -.match td -{ - padding-left: 1em; - font-family: Courier; -} \ No newline at end of file diff --git a/Detector Web Site/Tablet.png b/Detector Web Site/Tablet.png deleted file mode 100644 index ded7035..0000000 Binary files a/Detector Web Site/Tablet.png and /dev/null differ diff --git a/Detector Web Site/Tablet/Default.aspx b/Detector Web Site/Tablet/Default.aspx deleted file mode 100644 index c2ca780..0000000 --- a/Detector Web Site/Tablet/Default.aspx +++ /dev/null @@ -1,17 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="True" MasterPageFile="~/Detector.Master" CodeBehind="Default.aspx.cs" Inherits="Detector.Tablet.Default" EnableSessionState="True" EnableViewState="false" %> -<%@ OutputCache VaryByParam="*" VaryByHeader="User-Agent" Duration="240" Location="Any" %> -<%@ Register Src="~/DeviceProperties.ascx" TagPrefix="uc" TagName="DeviceProperties" %> - - - Tablet - - - -
-
- " alt="Tablet" style="vertical-align: middle;"/> - Tablet -
-
- -
diff --git a/Detector Web Site/Tablet/Default.aspx.cs b/Detector Web Site/Tablet/Default.aspx.cs deleted file mode 100644 index ae8d96d..0000000 --- a/Detector Web Site/Tablet/Default.aspx.cs +++ /dev/null @@ -1,29 +0,0 @@ -/* ********************************************************************* - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. - * See the License for the specific language governing rights and - * limitations under the License. - * - * The Original Code is named .NET Mobile API, first released under - * this licence on 11th March 2009. - * - * The Initial Developer of the Original Code is owned by - * 51 Degrees Mobile Experts Limited. Portions created by 51 Degrees - * Mobile Experts Limited are Copyright (C) 2009 - 2013. All Rights Reserved. - * - * Contributor(s): - * James Rosewell - * - * ********************************************************************* */ - -namespace Detector.Tablet -{ - public partial class Default : System.Web.UI.Page - { - } -} diff --git a/Detector Web Site/Tablet/Default.aspx.designer.cs b/Detector Web Site/Tablet/Default.aspx.designer.cs deleted file mode 100644 index 06fae5a..0000000 --- a/Detector Web Site/Tablet/Default.aspx.designer.cs +++ /dev/null @@ -1,24 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Detector.Tablet { - - - public partial class Default { - - /// - /// Device control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Detector.DeviceProperties Device; - } -} diff --git a/Detector Web Site/Web References/WebService/MobileDevice.wsdl b/Detector Web Site/Web References/WebService/MobileDevice.wsdl deleted file mode 100644 index a4e20bb..0000000 --- a/Detector Web Site/Web References/WebService/MobileDevice.wsdl +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Detector Web Site/Web References/WebService/Property.datasource b/Detector Web Site/Web References/WebService/Property.datasource deleted file mode 100644 index 1422e8f..0000000 --- a/Detector Web Site/Web References/WebService/Property.datasource +++ /dev/null @@ -1,10 +0,0 @@ - - - - Detector.WebService.Property, Web References.WebService.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - \ No newline at end of file diff --git a/Detector Web Site/Web References/WebService/Reference.cs b/Detector Web Site/Web References/WebService/Reference.cs deleted file mode 100644 index 67fac71..0000000 --- a/Detector Web Site/Web References/WebService/Reference.cs +++ /dev/null @@ -1,301 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.18047 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// -// This source code was auto-generated by Microsoft.VSDesigner, Version 4.0.30319.18047. -// -#pragma warning disable 1591 - -namespace Detector.WebService { - using System; - using System.Web.Services; - using System.Diagnostics; - using System.Web.Services.Protocols; - using System.Xml.Serialization; - using System.ComponentModel; - - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.17929")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Web.Services.WebServiceBindingAttribute(Name="MobileDeviceSoap", Namespace="http://mobiledevice.51degrees.mobi/")] - public partial class MobileDevice : System.Web.Services.Protocols.SoapHttpClientProtocol { - - private System.Threading.SendOrPostCallback GetPropertyOperationCompleted; - - private System.Threading.SendOrPostCallback GetPropertiesOperationCompleted; - - private System.Threading.SendOrPostCallback GetAllPropertiesOperationCompleted; - - private bool useDefaultCredentialsSetExplicitly; - - /// - public MobileDevice() { - this.Url = global::Detector.Properties.Settings.Default.Detector_WebService_MobileDevice; - if ((this.IsLocalFileSystemWebService(this.Url) == true)) { - this.UseDefaultCredentials = true; - this.useDefaultCredentialsSetExplicitly = false; - } - else { - this.useDefaultCredentialsSetExplicitly = true; - } - } - - public new string Url { - get { - return base.Url; - } - set { - if ((((this.IsLocalFileSystemWebService(base.Url) == true) - && (this.useDefaultCredentialsSetExplicitly == false)) - && (this.IsLocalFileSystemWebService(value) == false))) { - base.UseDefaultCredentials = false; - } - base.Url = value; - } - } - - public new bool UseDefaultCredentials { - get { - return base.UseDefaultCredentials; - } - set { - base.UseDefaultCredentials = value; - this.useDefaultCredentialsSetExplicitly = true; - } - } - - /// - public event GetPropertyCompletedEventHandler GetPropertyCompleted; - - /// - public event GetPropertiesCompletedEventHandler GetPropertiesCompleted; - - /// - public event GetAllPropertiesCompletedEventHandler GetAllPropertiesCompleted; - - /// - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://mobiledevice.51degrees.mobi/GetProperty", RequestNamespace="http://mobiledevice.51degrees.mobi/", ResponseNamespace="http://mobiledevice.51degrees.mobi/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public string GetProperty(string propertyName) { - object[] results = this.Invoke("GetProperty", new object[] { - propertyName}); - return ((string)(results[0])); - } - - /// - public void GetPropertyAsync(string propertyName) { - this.GetPropertyAsync(propertyName, null); - } - - /// - public void GetPropertyAsync(string propertyName, object userState) { - if ((this.GetPropertyOperationCompleted == null)) { - this.GetPropertyOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetPropertyOperationCompleted); - } - this.InvokeAsync("GetProperty", new object[] { - propertyName}, this.GetPropertyOperationCompleted, userState); - } - - private void OnGetPropertyOperationCompleted(object arg) { - if ((this.GetPropertyCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.GetPropertyCompleted(this, new GetPropertyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://mobiledevice.51degrees.mobi/GetProperties", RequestNamespace="http://mobiledevice.51degrees.mobi/", ResponseNamespace="http://mobiledevice.51degrees.mobi/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public string[] GetProperties(string[] propertyNames) { - object[] results = this.Invoke("GetProperties", new object[] { - propertyNames}); - return ((string[])(results[0])); - } - - /// - public void GetPropertiesAsync(string[] propertyNames) { - this.GetPropertiesAsync(propertyNames, null); - } - - /// - public void GetPropertiesAsync(string[] propertyNames, object userState) { - if ((this.GetPropertiesOperationCompleted == null)) { - this.GetPropertiesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetPropertiesOperationCompleted); - } - this.InvokeAsync("GetProperties", new object[] { - propertyNames}, this.GetPropertiesOperationCompleted, userState); - } - - private void OnGetPropertiesOperationCompleted(object arg) { - if ((this.GetPropertiesCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.GetPropertiesCompleted(this, new GetPropertiesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://mobiledevice.51degrees.mobi/GetAllProperties", RequestNamespace="http://mobiledevice.51degrees.mobi/", ResponseNamespace="http://mobiledevice.51degrees.mobi/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public Property[] GetAllProperties() { - object[] results = this.Invoke("GetAllProperties", new object[0]); - return ((Property[])(results[0])); - } - - /// - public void GetAllPropertiesAsync() { - this.GetAllPropertiesAsync(null); - } - - /// - public void GetAllPropertiesAsync(object userState) { - if ((this.GetAllPropertiesOperationCompleted == null)) { - this.GetAllPropertiesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetAllPropertiesOperationCompleted); - } - this.InvokeAsync("GetAllProperties", new object[0], this.GetAllPropertiesOperationCompleted, userState); - } - - private void OnGetAllPropertiesOperationCompleted(object arg) { - if ((this.GetAllPropertiesCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.GetAllPropertiesCompleted(this, new GetAllPropertiesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// - public new void CancelAsync(object userState) { - base.CancelAsync(userState); - } - - private bool IsLocalFileSystemWebService(string url) { - if (((url == null) - || (url == string.Empty))) { - return false; - } - System.Uri wsUri = new System.Uri(url); - if (((wsUri.Port >= 1024) - && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) { - return true; - } - return false; - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18047")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://mobiledevice.51degrees.mobi/")] - public partial class Property { - - private string nameField; - - private string[] valuesField; - - /// - public string Name { - get { - return this.nameField; - } - set { - this.nameField = value; - } - } - - /// - public string[] Values { - get { - return this.valuesField; - } - set { - this.valuesField = value; - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.17929")] - public delegate void GetPropertyCompletedEventHandler(object sender, GetPropertyCompletedEventArgs e); - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.17929")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetPropertyCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal GetPropertyCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// - public string Result { - get { - this.RaiseExceptionIfNecessary(); - return ((string)(this.results[0])); - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.17929")] - public delegate void GetPropertiesCompletedEventHandler(object sender, GetPropertiesCompletedEventArgs e); - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.17929")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetPropertiesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal GetPropertiesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// - public string[] Result { - get { - this.RaiseExceptionIfNecessary(); - return ((string[])(this.results[0])); - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.17929")] - public delegate void GetAllPropertiesCompletedEventHandler(object sender, GetAllPropertiesCompletedEventArgs e); - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.17929")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetAllPropertiesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal GetAllPropertiesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// - public Property[] Result { - get { - this.RaiseExceptionIfNecessary(); - return ((Property[])(this.results[0])); - } - } - } -} - -#pragma warning restore 1591 \ No newline at end of file diff --git a/Detector Web Site/Web References/WebService/Reference.map b/Detector Web Site/Web References/WebService/Reference.map deleted file mode 100644 index b02dc0e..0000000 --- a/Detector Web Site/Web References/WebService/Reference.map +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Detector Web Site/Web.config b/Detector Web Site/Web.config deleted file mode 100644 index 7d8d859..0000000 --- a/Detector Web Site/Web.config +++ /dev/null @@ -1,39 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - http://localhost/Detector4/MobileDevice.asmx - - - - \ No newline at end of file diff --git a/Detector Web Site/default.css b/Detector Web Site/default.css deleted file mode 100644 index 02f670c..0000000 --- a/Detector Web Site/default.css +++ /dev/null @@ -1,1072 +0,0 @@ -/* background color for the content part of the pages */ -Body -{ - background-color: white; - margin: 0px; -} - -.ControlPanel, .PagingTable -{ - width: 100%; - background-color: #FFFFFF; - border-right: #003366 1px solid; - border-top: #003366 1px solid; - border-left: #003366 1px solid; - border-bottom: #003366 1px solid; -} - -.SkinObject -{ - font-weight: bold; - font-size: 8.5pt; - color: #003366; - font-family: Tahoma, Arial, Helvetica; - text-decoration: none; -} - -A.SkinObject:link -{ - text-decoration: none; - color: #003366; -} - -A.SkinObject:visited -{ - text-decoration: none; - color: #003366; -} - -A.SkinObject:hover -{ - text-decoration: none; - color: #003366; -} - -A.SkinObject:active -{ - text-decoration: none; - color: #003366; -} - -/* styles for LANGUAGE skinobject */ -.Language -{ - vertical-align: middle; - margin: 0px; -} - -.Language img -{ - border: none; -} - - -/* style for module titles */ -.Head -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 20px; - font-weight: normal; - color: #333333; -} - -/* style of item titles on edit and admin pages */ -.SubHead -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: bold; - color: #003366; -} - -/* module title style used instead of Head for compact rendering by QuickLinks and Signin modules */ -.SubSubHead -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: bold; - color: black; -} - -/* text style used for most text rendered by modules */ -.Normal, .NormalDisabled -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: normal; -} - -/* text style used for rendered text which should appear disabled */ -.NormalDisabled -{ - color: Silver; -} - -/* text style used for rendered text which requires emphasis */ -.NormalBold -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: bold; -} - -/* text style used for error messages */ -.NormalRed -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 12px; - font-weight: bold; - color: #ff0000; -} - -/* text style used for textboxes in the admin and edit pages, for Nav compatibility */ -.NormalTextBox -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 12px; - font-weight: normal; -} - -/* styles used by Data Grids */ -.DataGrid_AlternatingItem -{ - background-color: White; - color: Red; - font-family: Tahoma, Arial, Helvetica; - font-size: 10px; - font-weight: normal; -} -.DataGrid_Container -{ - background-color: Transparent; -} -.DataGrid_Footer -{ - background-color: White; -} -.DataGrid_Header -{ - background-color: Transparent; - color: Black; - font-family: Tahoma, Arial, Helvetica; - font-size: 10px; - font-weight: bold; - text-align: center; -} -.DataGrid_Item -{ - background-color: Transparent; - color: Black; - font-family: Tahoma, Arial, Helvetica; - font-size: 10px; - font-weight: normal; -} -.DataGrid_SelectedItem -{ - background-color: Silver; - color: Blue; - font-family: Tahoma, Arial, Helvetica; - font-size: 10px; - font-weight: normal; -} - -/* styles used by TreeMenu Skin Object */ -.TreeMenu_Node -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 12px; - font-weight: normal; -} - -.TreeMenu_NodeSelected -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 12px; - font-weight: normal; - background-color: #dcdcdc; -} - -A.TreeMenu_Node:link, A.TreeMenu_NodeSelected:link -{ - text-decoration: none; - color: #003366; -} - -A.TreeMenu_Node:visited, A.TreeMenu_NodeSelected:visited -{ - text-decoration: none; - color: #003366; -} - -A.TreeMenu_Node:hover, A.TreeMenu_NodeSelected:hover -{ - text-decoration: none; - color: #ff0000; -} - -A.TreeMenu_Node:active, A.TreeMenu_NodeSelected:active -{ - text-decoration: none; - color: #003366; -} - -/* styles used in the FileManager */ -.FileManager -{ - border-right: black 1px solid; - border-top: black 1px solid; - border-left: black 1px solid; - border-bottom: black 1px solid; - height: 400px; -} -.FileManager_ToolBar -{ - border-bottom: black 1px solid; - height: 25px; -} -.FileManager_Explorer -{ - height: 100%; - border: #696969 1px solid; - background-color: White; - margin: 2px 2px 2px 2px; -} - -.FileManager_FileList -{ - height: 100%; - border: #696969 1px solid; - background-color: White; - margin: 2px 2px 2px 2px; - overflow: auto; -} - -.FileManager_MessageBox -{ - text-align: center; - vertical-align: middle; - background-color: White; - padding: 25px 25px 25px 25px; -} - -.FileManager_Header -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: bold; - color: #E7E7FF; - background-color: #9EBFF6; - border-bottom: #696969 1px solid; - height: 25px; -} - -.FileManager_Pager -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: bold; - background-color: #EEEEEE; - border-top: #696969 1px solid; - height: 25px; -} - -.FileManager_StatusBar -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: normal; - background-color: #dedfde; - height: 25px; - margin: 2px 2px 2px 2px; -} - -.FileManager_Item -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: normal; - color: Black; - background-color: #F8F8F8; - border-top: black 1px dashed; - border-bottom: black 1px dashed; -} - -.FileManager_AltItem -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: normal; - color: Black; - background-color: #EEEEEE; - border-style: none; -} -.FileManager_SelItem -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: bold; - color: White; - background-color: #99ffff; - border-style: none; -} - -.FileManagerTreeNode -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: normal; -} - -.FileManagerTreeNodeSelected -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: normal; - background-color: #dcdcdc; -} - -A.FileManagerTreeNode:link, A.FileManagerTreeNodeSelected:link -{ - text-decoration: none; - color: #003366; -} - -A.FileManagerTreeNode:visited, A.FileManagerTreeNodeSelected:visited -{ - text-decoration: none; - color: #003366; -} - -A.FileManagerTreeNode:hover, A.FileManagerTreeNodeSelected:hover -{ - text-decoration: none; - color: #ff0000; -} - -A.FileManagerTreeNode:active, A.FileManagerTreeNodeSelected:active -{ - text-decoration: none; - color: #003366; -} - -/* styles used in the Wizard Framework */ -.Wizard -{ - border-right: black 1px solid; - border-top: black 1px solid; - border-left: black 1px solid; - border-bottom: black 1px solid; - height: 400px; - width: 650px; -} -.WizardButton -{ - border-right: #696969 1px solid; - padding-right: 2px; - border-top: #696969 1px solid; - padding-left: 2px; - padding-bottom: 2px; - border-left: #696969 1px solid; - padding-top: 2px; - border-bottom: #696969 1px solid; - background-color: #dcdcdc; -} -.WizardHeader -{ - background: #ffffcc; - border-bottom: black 1px solid; - height: 40px; -} -.WizardFooter -{ - border-top: black 1px solid; - background: #ccffcc; - height: 25px; - text-align: right; -} -.WizardBody -{ - padding-right: 10px; - padding-left: 10px; - padding-bottom: 10px; - padding-top: 10px; - height: 325px; -} -.WizardHelp -{ - padding-right: 5px; - padding-left: 5px; - font-size: 9pt; - padding-bottom: 5px; - border-left: black 1px solid; - width: 180px; - padding-top: 5px; - background-color: #ccffff; -} -.WizardHelpText -{ - overflow: auto; - font-size: 8pt; - width: 180px; - color: black; - font-family: Tahoma, Verdana, Arial, Sans-Serif; - height: 300px; -} -.WizardText -{ - font-size: 9pt; - color: black; - font-family: Tahoma, Verdana, Arial, Sans-Serif; -} - - -/* text style used for help text rendered by modules */ -.Help -{ - border-right: black 1px solid; - padding-right: 2px; - border-top: black 1px solid; - padding-left: 2px; - font-weight: normal; - font-size: 11px; - padding-bottom: 2px; - border-left: black 1px solid; - color: black; - padding-top: 2px; - border-bottom: black 1px solid; - font-family: Tahoma, Arial, Helvetica; - background-color: #ffff99; -} - -/* text style for buttons and link buttons used in the portal admin pages */ -.CommandButton -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: normal; -} - -/* hyperlink style for buttons and link buttons used in the portal admin pages */ -A.CommandButton:link -{ - text-decoration: underline; - color: #003366; -} - -A.CommandButton:visited -{ - text-decoration: underline; - color: #003366; -} - -A.CommandButton:hover -{ - text-decoration: underline; - color: #ff0000; -} - -A.CommandButton:active -{ - text-decoration: underline; - color: #003366; -} - -/* button style for standard HTML buttons */ -.StandardButton -{ - padding-right: 5px; - padding-left: 5px; - font-weight: normal; - font-size: 11px; - background: #dddddd; - color: #000000; - font-family: Verdana, sans-serif; -} - - -/* GENERIC */ -H1 -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 20px; - font-weight: normal; - color: #666644; -} - -H2 -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 20px; - font-weight: normal; - color: #666644; -} - -H3 -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 12px; - font-weight: normal; - color: #003366; -} - -H4 -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 12px; - font-weight: normal; - color: #003366; -} - -H5, DT -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: bold; - color: #003366; -} - -H6 -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 11px; - font-weight: bold; - color: #003366; -} - -TFOOT, THEAD -{ - font-family: Tahoma, Arial, Helvetica; - font-size: 12px; - color: #003366; -} - -TH -{ - vertical-align: baseline; - font-family: Tahoma, Arial, Helvetica; - font-size: 12px; - font-weight: bold; - color: #003366; -} - -A:link -{ - text-decoration: none; - color: #003366; -} - -A:visited -{ - text-decoration: none; - color: #003366; -} - -A:hover -{ - text-decoration: underline; - color: #ff0000; -} - -A:active -{ - text-decoration: none; - color: #003366; -} - -SMALL -{ - font-size: 8px; -} - -BIG -{ - font-size: 14px; -} - -BLOCKQUOTE, PRE -{ - font-family: Lucida Console, monospace; -} - - -UL LI -{ - list-style-type: square; -} - -UL LI LI -{ - list-style-type: disc; -} - -UL LI LI LI -{ - list-style-type: circle; -} - -OL LI -{ - list-style-type: decimal; -} - -OL OL LI -{ - list-style-type: lower-alpha; -} - -OL OL OL LI -{ - list-style-type: lower-roman; -} -OL UL LI -{ - list-style-type: disc; -} - -HR -{ - color: #696969; - height: 1pt; - text-align: left; -} - -/* Module Title Menu */ -.ModuleTitle_MenuContainer -{ - border-bottom: blue 0px solid; - border-left: blue 0px solid; - border-top: blue 0px solid; - border-right: blue 0px solid; -} - -.ModuleTitle_MenuBar -{ - cursor: pointer; - height: 16px; - background-color: Transparent; -} - -.ModuleTitle_MenuItem -{ - cursor: pointer; - color: black; - font-family: Tahoma, Arial, Helvetica; - font-size: 9pt; - font-weight: bold; - font-style: normal; - border-left: white 0px solid; - border-bottom: white 1px solid; - border-top: white 1px solid; - border-right: white 0px solid; - background-color: Transparent; -} - -.ModuleTitle_MenuIcon -{ - cursor: pointer; - background-color: #EEEEEE; - border-left: #EEEEEE 1px solid; - border-bottom: #EEEEEE 1px solid; - border-top: #EEEEEE 1px solid; - text-align: center; - width: 15px; - height: 21px; -} - -.ModuleTitle_SubMenu -{ - z-index: 1000; - cursor: pointer; - background-color: #FFFFFF; - border-bottom: #FFFFFF 0px solid; - border-left: #FFFFFF 0px solid; - border-top: #FFFFFF 0px solid; - border-right: #FFFFFF 0px solid; -} - -.ModuleTitle_MenuBreak -{ - border-bottom: #EEEEEE 1px solid; - border-left: #EEEEEE 0px solid; - border-top: #EEEEEE 1px solid; - border-right: #EEEEEE 0px solid; - background-color: #EEEEEE; - height: 1px; -} - -.ModuleTitle_MenuItemSel -{ - cursor: pointer; - color: black; - font-family: Tahoma, Arial, Helvetica; - font-size: 9pt; - font-weight: bold; - font-style: normal; - background-color: #C1D2EE; -} - -.ModuleTitle_MenuArrow -{ - font-family: webdings; - font-size: 10pt; - cursor: pointer; - border-right: #FFFFFF 1px solid; - border-bottom: #FFFFFF 1px solid; - border-top: #FFFFFF 0px solid; -} - -.ModuleTitle_RootMenuArrow -{ - font-family: webdings; - font-size: 10pt; - cursor: pointer; -} - -/* Main Menu */ -.MainMenu_MenuContainer -{ - background-color: transparent; -} -.MainMenu_MenuBar -{ - cursor: pointer; - height: 16px; - background-color: Transparent; -} -.MainMenu_MenuItem -{ - cursor: pointer; - color: black; - font-family: Tahoma, Arial, Helvetica; - font-size: 9pt; - font-weight: bold; - font-style: normal; - border-left: white 0px solid; - border-bottom: white 1px solid; - border-top: white 1px solid; - border-right: white 0px solid; - background-color: Transparent; -} -.MainMenu_MenuIcon -{ - cursor: pointer; - background-color: #EEEEEE; - border-left: #EEEEEE 1px solid; - border-bottom: #EEEEEE 1px solid; - border-top: #EEEEEE 1px solid; - text-align: center; - width: 15px; - height: 21px; -} -.MainMenu_SubMenu -{ - z-index: 1000; - cursor: pointer; - background-color: #FFFFFF; - border-bottom: #FFFFFF 0px solid; - border-left: #FFFFFF 0px solid; - border-top: #FFFFFF 0px solid; - border-right: #FFFFFF 0px solid; -} -.MainMenu_MenuBreak -{ - border-bottom: #EEEEEE 1px solid; - border-left: #EEEEEE 0px solid; - border-top: #EEEEEE 1px solid; - border-right: #EEEEEE 0px solid; - background-color: #EEEEEE; - height: 1px; -} -.MainMenu_MenuItemSel -{ - cursor: pointer; - color: black; - font-family: Tahoma, Arial, Helvetica; - font-size: 9pt; - font-weight: bold; - font-style: normal; - background-color: #C1D2EE; -} -.MainMenu_MenuArrow -{ - font-family: webdings; - font-size: 10pt; - cursor: pointer; - border-right: #FFFFFF 1px solid; - border-bottom: #FFFFFF 1px solid; - border-top: #FFFFFF 0px solid; -} -.MainMenu_RootMenuArrow -{ - font-family: webdings; - font-size: 10pt; - cursor: pointer; -} - -/* LEGACY STYLES from DNN 1-2 */ -.HeadBg -{ - background-color: #CCCCCC; -} - -.TabBg -{ - background-color: black; -} - -.SelectedTab -{ - font-weight: bold; - font-size: 8.5pt; - color: #FFFFFF; - font-family: Tahoma, Arial, Helvetica; - text-decoration: none; -} - -A.SelectedTab:link -{ - text-decoration: none; - color: white; -} - -A.SelectedTab:visited -{ - text-decoration: none; - color: #eeeeee; -} - -A.SelectedTab:hover -{ - text-decoration: none; - color: #cccccc; -} - -A.SelectedTab:active -{ - text-decoration: none; - color: #eeeeee; -} - -.OtherTabs -{ - font-weight: bold; - font-size: 8.5pt; - color: white; - font-family: Tahoma, Arial, Helvetica; - text-decoration: none; -} - -A.OtherTabs:link -{ - text-decoration: none; - color: white; -} - -A.OtherTabs:visited -{ - text-decoration: none; - color: #eeeeee; -} - -A.OtherTabs:hover -{ - text-decoration: none; - color: #cccccc; -} - -A.OtherTabs:active -{ - text-decoration: none; - color: #eeeeee; -} - -.PagingTable -{ - height: 33px; -} - -/* -.LabelEditOverClass -{ - cursor: pointer; - text-decoration: underline overline; -} -*/ - -.LabelEditTextClass -{ - border: solid 1px red; - background-color: Transparent; -} - -.LabelEditWorkClass -{ - /*background: url(/DotNetNuke/images/dnnanim.gif) no-repeat right;*/ - border: solid 0px red; - background-color: Transparent; -} - -/* style for the DNNTextSuggest control select menu */ -.SuggestTextMenu -{ - border: solid 1px black; - white-space: nowrap; - background: white; -} -/* style for the DNNTextSuggest control selected menu node */ -.SuggestNodeOver -{ - background-color: navy; - color: White; -} - - -/*Edit In Place Tool Bar Classes*/ -.eipbackimg -{ - border: outset 1px; /*give toolbar a 3D look*/ - position: absolute; /*needed so it doesn't take up space */ - margin-top: -22px; /*specify toolbar to be just above text */ - white-space: nowrap; /* makes toolbar horizontal */ - background: url(../../images/eip_toolbar.gif); - background-color: #99cccc; - height: 22px; -} - -.eipbuttonbackimg -{ - width: 21px; - height: 21px; - cursor: pointer; /*change mouse to pointer when hover over button*/ - display: -moz-inline-box; /* Gecko proprietary (ORDER IS IMPORTANT HERE!)*/ - display: inline-block; /* supported by Opera and ? */ -} - -.eipbutton_edit -{ - background: url(../../images/eip_edit.gif) no-repeat 100% center; -} -.eipbutton_save -{ - background: url(../../images/eip_save.gif) no-repeat 100% center; -} -.eipborderhover -{ - border: outset 1px; -} - -/* used to collapse panes without any content in them */ -.DNNEmptyPane -{ - width: 0px; -} - -/* used to set the different module align options - from module settings */ -.DNNAlignleft -{ - text-align: left; -} -.DNNAlignright -{ - text-align: right; -} -.DNNAligncenter -{ - text-align: center; -} - -/* Login Styles */ -.LoginPanel -{ - -} - -.LoginTabGroup -{ - -} - -.LoginTab { - float: left; - background: url("../../images/tablogin_gray.gif") left top; - margin: 0 3px 3px 0; - padding: 5px 5px 4px 5px; - text-decoration: none; - color: #FFF; - border: 1px #25569a solid; -} - -.LoginTabSelected{ - float: left; - background: url("../../images/tablogin_gray.gif") left top; - margin: 0 3px 3px 0; - padding: 5px 5px 4px 5px; - text-decoration: none; - color: #FFF; - background-position: 0% -41px; - border: 1px #25569a solid; -} - -.LoginTabHover -{ - float: left; - background: url("../../images/tablogin_gray.gif") left top; - margin: 0 3px 3px 0; - padding: 5px 5px 4px 5px; - text-decoration: none; - color: #555; - border: 1px #C00 solid; - cursor:pointer; -} - -.LoginContainerGroup -{ - clear: both; - padding-top: 5px; -} - -.LoginContainer -{ - -} - -#tablist -{ - width: 120px; - margin: 0; - border-right: 1px solid black; - padding-bottom: 10px; - float:left; -} - -.dashboardPanel -{ - margin-left: 120px; - padding: 0 10px 10px 10px; - -} - -.dashboardPanel table td -{ - padding: 2px 4px; -} - -.dashboardPanel table th -{ - padding: 2px 4px; - font-size: 1em; - font-weight: bold; - color: #036; - border-bottom: 1px solid #9FB1BC; -} - -.dashboardTableAlt -{ - background-color: #eee; -} - -.dashboardGrid -{ - margin: 10px; -} - diff --git a/Detector Web Site/skin.css b/Detector Web Site/skin.css deleted file mode 100644 index 9043008..0000000 --- a/Detector Web Site/skin.css +++ /dev/null @@ -1,129 +0,0 @@ -/*========================================================*/ -/* CSS for DotNetNuke Skin - Minimalist */ -/* by Evan O'Neil */ -/* http://www.NukeVille.com */ -/*========================================================*/ - -/*========================================================*/ -/* Universal */ -/*========================================================*/ - -/* Style For HTML PAGE */ html { height: 100%; } -/* Style For HTML BODY ID */ #body { margin: 0; background: #FFFFFF; margin: 0 0 0 0; height: 100%; } -/* Style For HTML BODY */ body {height:100%} -/* Setting Text Throughout the skin */ table, tr, td {font-family: tahoma; font-size: 12px; color: #555555; margin: 0;} - p, li {font-family: tahoma; font-size: 12px; color: #555555;} -/* Setting Heading 01 */ h1 { font-family: tahoma; font-weight: bold; color: #70c819; font-size:32pt; margin:0;} -/* Setting Heading 02 */ h2 { font-family: tahoma; font-weight: bold; color: #555555; font-size:24pt; margin:0;} -/* Setting Heading 03 */ h3 { font-family: tahoma; font-weight: bold; color: #70c819; font-size:18pt; margin:0; } -/* Setting Heading 04 */ h4 { font-family: tahoma; font-weight: bold; color: #555555; font-size:16pt; margin:0;} -/* Setting Heading 05 */ h5 { font-family: tahoma; font-weight: bold; color: #70c819; font-size:14pt; margin:0;} -/* Setting Heading 06 */ h6 { font-family: tahoma; font-weight: bold; color: #70c819; font-size:12pt; margin:0;} - -/*========================================================*/ -/* Design Elements */ -/*========================================================*/ - -/*-- width setting on skins --*/ .StandardWidth { width:960px; } -/*-- 100 percent height where req --*/ .FullHeight { height:100%; } -/*-- 100 percent width where req --*/ .FullWidth { width:100%; } -/*-- outer table on skins --*/ .OuterTable { width:100%; height:100%; } -/*-- cell containing content panes --*/ .ContentPanesTD { width:auto; height:100%; vertical-align: top; padding: 0 0 0 0; } -/*-- dotted background --*/ .Dotted { background: url(dotted2.gif) repeat top left; } -/*-- row containing logo area --*/ .LogoRow { height:1px; padding: 0 10px 0 7px; } -/*-- cell containing logo --*/ .LogoTD { width:1px; padding: 0 0 0 0; } -/*-- row containing breadcrumbs --*/ .BreadcrumbsRow { height:41px; background: url(bread-bg.gif) repeat top left; padding: 0 0 0 0; } -/*-- row for space between areas --*/ .SpaceBar { height:10px; padding: 0 0 0 0; } -/*-- cell containing breadcrumbs --*/ .BreadcrumbsTD { height: 41px; width: 100%; background: url(bread-bg-l.gif) no-repeat top left; color:#a1a1a1; vertical-align: middle; padding: 0 20px 0 17px; } -/*-- cell containing search --*/ .SearchTD { width:215px; vertical-align: top; text-align: right; height: 41px; background: url(search-bg.gif) no-repeat top right; padding: 10px 7px 0 0; } -/*-- cell containing privacy --*/ .PrivacyTD { text-align: left; padding: 0 0 0 0; } -/*-- cell containing copyright --*/ .CopyrightTD { text-align: right; padding: 0 0 0 0; } -/*-- cell containing flash h --*/ .FlashTD { padding: 9px 7px 0 7px; } -/*-- cell containing flash v --*/ .FlashTDV { padding: 4px 7px 0 7px; } -/*-- used for setting attribute --*/ .SkinBox, .BackgroundTile, .BackgroundTopStretch, .BackgroundImage { height:100%; } -/*-- various common properties --*/ .PanePad { padding: 0 7px 0 7px; } .Width100p { width: 100%; } .Width50p { width: 50%; } .Width25p { width: 25%; } .Width33p { width: 33%; } .Height1px { height: 1px; } - -/*========================================================*/ -/* Footer Box Elements */ -/*========================================================*/ - -/*-- footer area --*/ .FooterBox { background: url(footer-bg.gif) repeat top left; } -/*-- row containing footer area --*/ .FooterRow { height:36px; padding: 0 7px 0 7px; } -/*-- table within footer - rounded --*/ .FooterTable { height:36px; background: url(footer-bg-b.gif) repeat-x bottom left; } -/*-- rounded top-left corner --*/ .FooterTL { height:29px; width:6px; background: url(footer-bg-tl.gif) no-repeat top left; } -/*-- rounded top-right corner --*/ .FooterTR { height:29px; width:6px; background: url(footer-bg-tr.gif) no-repeat top right; } -/*-- left side --*/ .FooterL { width:6px; background: url(footer-bg-l.gif) repeat-y top left; } -/*-- right side --*/ .FooterR { width:6px; background: url(footer-bg-r.gif) repeat-y top right; } -/*-- rounded bottom left corner --*/ .FooterBL { height:6px; width:6px; background: url(footer-bg-bl.gif) no-repeat bottom left; } -/*-- rounded bottom right corner --*/ .FooterBR { height:6px; width:6px; background: url(footer-bg-br.gif) no-repeat bottom right; } - -/*========================================================*/ -/* Content Panes */ -/*========================================================*/ - -/*-- image content pane 1 horiz --*/ .ImagePane01 { padding: 0 7px 9px 7px; } -/*-- image content pane 2 --*/ .ImagePane02 { padding: 9px 7px 0 7px; } -/*-- image content pane 2 vertical --*/ .ImagePane02V { padding: 4px 7px 0 7px; } -/*-- image content pane 3 --*/ .ImagePane03 { padding: 0 7px 9px 7px; } -/*-- footer content pane --*/ .FooterPane { padding: 6px 7px 6px 7px; vertical-align:middle; background: url(footer-bg-grad.gif) repeat-x top left; } - -/*========================================================*/ -/* Tokens */ -/*========================================================*/ - -/*-- login token idle --*/ .LOGIN_object, a.LOGIN_object:link, a.LOGIN_object:visited, a.LOGIN_object:active { color: #939393; background: url(ico-login.gif) no-repeat bottom left; font-family: tahoma; font-size: 11px; font-weight:bold; text-decoration: none; height:17px; float:right; padding: 2px 0 0 25px; margin: 0 0px 0 16px; } -/*-- login token hover --*/ a.LOGIN_object:hover { background: url(ico-login-over.gif) no-repeat bottom left; color: #444444; font-family: tahoma; font-weight:bold; font-size: 11px; text-decoration: none; } -/*-- user token idle --*/ .USER_object, a.USER_object:link, a.USER_object:visited, a.USER_object:active { color: #939393; background: url(ico-register.gif) no-repeat bottom left; font-family: tahoma; font-size: 11px; font-weight:bold; text-decoration: none; height:17px; float:right; padding: 2px 0 0 25px; margin: 0 0px 0 16px; } -/*-- user token hover --*/ a.USER_object:hover { background: url(ico-register-over.gif) no-repeat bottom left; color: #444444; font-family: tahoma; font-weight:bold; font-size: 11px; text-decoration: none; } -/*-- date token idle --*/ .DATE_object, a.DATE_object:link, a.DATE_object:visited, a.DATE_object:active { color: #939393; font-family: tahoma; font-size: 11px; text-decoration: none; } -/*-- date token hover --*/ a.DATE_object:hover { color: #c1c1c1; font-family: tahoma; font-size: 11px; text-decoration: none; } -/*-- breadcrumbs token idle --*/ .BREADCRUMBS_object, a.BREADCRUMBS_object:link, a.BREADCRUMBS_object:visited, a.BREADCRUMBS_object:active { color: #8f8f8f; font-family: tahoma; font-size: 11px; text-decoration: none; font-weight:bold;} -/*-- breadcrumbs token hover --*/ a.BREADCRUMBS_object:hover { color: #666; font-family: tahoma; font-size: 11px; text-decoration: none; font-weight:bold; } -/*-- terms privacy and copyright --*/ .FOOTER_objects { color:#aaa; font-size: 11px; } -/*-- terms privacy and copyright links --*/ a.FOOTER_objects:link, a.FOOTER_objects:visited, a.FOOTER_objects:active { font-size: 11px; color:#aaa; font-weight:bold; text-decoration:none; } -/*-- terms privacy and copyright hover --*/ a.FOOTER_objects:hover { font-size: 11px; color:#777; font-weight:bold; text-decoration:none; } -/*-- language selector dropdown --*/ .Language_object { font-family: tahoma; font-size: 11px; text-decoration: none; } - -/*========================================================*/ -/* Text */ -/*========================================================*/ - -/*-- most of the text on site --*/ .normal, .Normal { font-family: tahoma; font-size: 11px; color: #555; } -/*-- most of the bold text on site --*/ .NormalBold { font-family: tahoma; font-size: 11px; font-weight: bold; color: #555; } -/*-- red text on site for errors --*/ .NormalRed { color: #C50000; font-family: tahoma; font-weight: bold; font-size: 11px; } -/*-- subheadings - mostly in admin --*/ .SubHead { font-family: tahoma; font-size: 11px; font-weight: bold; color: #777; padding: 0; } -/*-- headings - mostly in admin --*/ .Head { font-size: 11px; color: #777; background: transparent; font-weight: bold; padding: 0;} - -/*========================================================*/ -/* Links */ -/*========================================================*/ - -/*-- default links visited and active --*/ a:link, a:visited, a:active { color: #666; font-family: tahoma; font-weight: bold; font-size: 12px; text-decoration: underline; } -/*-- default links hover --*/ a:hover { color: #444; font-family: tahoma; font-size: 12px; text-decoration: underline; } -/*-- normal links visited and active --*/ a.Normal:link, a.Normal:visited { color: #666; font-family: tahoma; font-weight: bold; font-size: 12px; text-decoration: none; } -/*-- normal links hover --*/ a.Normal:hover { color: #444; font-family: tahoma; font-size: 12px; text-decoration: none; } -/*-- search button in search form --*/ .SearchButton { background: transparent; padding: 15px 12px 7px 12px; cursor: hand; font-size:1px; margin: 0 0 0 0;} -/*-- footer links --*/ .Footer_Links, a.Footer_Links:link, a.Footer_Links:visited, a.Footer_Links:active { color: #FFF; font-family: tahoma; font-size: 11px; font-weight:bold; text-decoration: none; } -/*-- footer links hover --*/ a.Footer_Links:hover { color: #EEE; font-family: tahoma; font-weight:bold; font-size: 11px; text-decoration: none; } - -/*========================================================*/ -/* Forms */ -/*========================================================*/ - -/*-- default form elements --*/ select, input { font-family: tahoma; font-size: 11px; color: #333; } -/*-- textbox --*/ .NormalTextBox { color: #333; padding-left: 4px; line-height: 12px; font-family: tahoma; font-weight: normal; font-size: 11px; } -/*-- textbox container --*/ td.NormalTextBox { padding: 0; margin: 0; background: transparent; display: none; border: 0; } -/*-- textbox used for search --*/ #dnn_dnnSEARCH_txtSearch.NormalTextBox { height:21px; background: transparent; width: 174px; color: #666; padding: 4px 4px 0px 4px; border: 0px solid #FFFFFF; cursor:text;} - -/*========================================================*/ -/* Sub Menus and Module Menus */ -/*========================================================*/ - -/*-- submenu container --*/ .MainMenu_SubMenu, .ModuleTitle_SubMenu { background: #FFF; padding: 0px; border: 1px solid #ccc; z-index: 1000; cursor: pointer; cursor: hand; font-weight: normal;} -/*-- submenu items idle --*/ .MainMenu_MenuItem, .ModuleTitle_MenuItem { background: #FFF; color: #666; font-family: tahoma; font-size: 8pt; font-weight: bold; font-style: normal; padding: 0px 30px 0px 16px; height: 28px; border-left:0px; border-right:0px; border-top:0px; border-bottom: 1px solid #ccc; margin:0 0 0 0;} -/*-- submenu items hover --*/ .MainMenu_MenuItemSel, .ModuleTitle_MenuItemSel { background: #eee; color: #70c819; font-family: tahoma; font-size: 8pt; font-weight: bold; cursor: pointer; cursor: hand; padding: 0px 30px 0px 16px; height: 28px; border-left:0px; border-right:0px; border-top:0px; border-bottom: 1px solid #ccc; margin:0 0 0 0;} - -/*==========================================================*/ -/* End Style Sheet */ -/*==========================================================*/ - diff --git a/Foundation/Activator.cs b/Foundation/Activator.cs deleted file mode 100644 index 949ec87..0000000 --- a/Foundation/Activator.cs +++ /dev/null @@ -1,74 +0,0 @@ -/* ********************************************************************* - * 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 System.Web; -using System.Web.Configuration; -using System; - -// The following assembly attribute make the static method run on app start. -[assembly: PreApplicationStartMethod(typeof(FiftyOne.Foundation.PreApplicationStart), "Start")] - -namespace FiftyOne.Foundation -{ - /// - /// Classed used by ASP.NET v4 to activate 51Degrees.mobi Foundation removing - /// the need to activate from the web.config file. - /// - public static class PreApplicationStart - { - /// - /// Flag to indicate if the method has already been called. - /// - private static bool _initialised = false; - - /// - /// Method called with the worker process starts to activate the - /// mobile capabilities of the DLL without requiring web.config - /// entries. - /// - public static void Start() - { - if (_initialised == false) - { - // Replace the browser capabilities provider with one that is 51Degrees.mobi - // enabled. - if (HttpCapabilitiesBase.BrowserCapabilitiesProvider is FiftyOne.Foundation.Mobile.Detection.MobileCapabilitiesProvider == false) - HttpCapabilitiesBase.BrowserCapabilitiesProvider = new FiftyOne.Foundation.Mobile.Detection.MobileCapabilitiesProvider(); - - // Include the redirection module if the Microsoft.Web.Infrastructure assembly is - // available. - try - { - RegisterModule(); - } - catch (Exception ex) - { - EventLog.Warn("Redirection module could not automatically be registered. " + - "Redirection services will not be available unless the HttpModule is " + - "included explicitly in the web.config file or Microsoft.Web.Infrastructure " + - "is installed."); - if (EventLog.IsDebug) - EventLog.Debug(ex); - } - _initialised = true; - } - } - - /// - /// Registers the HttpModule for redirection. - /// - private static void RegisterModule() - { - Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule( - typeof(FiftyOne.Foundation.Mobile.Redirection.RedirectModule)); - } - } -} diff --git a/Foundation/Cache.cs b/Foundation/Cache.cs deleted file mode 100644 index d71ef81..0000000 --- a/Foundation/Cache.cs +++ /dev/null @@ -1,261 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections.Generic; -using System.Threading; - -#if VER4 - -using System.Linq; -using System.Threading.Tasks; - -#elif VER35 - -using System.Linq; - -#endif - -#endregion - -namespace FiftyOne -{ - /// - /// Used to create a cache object of type Value with a string key. - /// - /// Type of object to hold in the cache. - public class Cache : Cache - { - /// - /// Constructs a class of the type Cache<Value> using the - /// timeout value in minutes provided. - /// - /// Minimum number of minutes to hold items in the cache for. - public Cache(int timeout) : base(timeout) - { - } - } - - /// - /// A cache object used to store key value pairs until a timeout has expired. - /// - /// Type of the key for the class. - /// Type of the value for the class. - public class Cache - { - #region Fields - - private DateTime _nextServiceTime = DateTime.MinValue; - private readonly Dictionary _internalCache; - private readonly Dictionary _lastAccessed; - - // The last time this process serviced the cache file. - private readonly int _timeout; - - #endregion - - #region Constructor - - /// - /// Constructs the cache clearing key value pairs after the timeout period - /// specified in minutes. - /// - /// Number of minutes to hold items in the cache for. - public Cache(int timeout) - { - _internalCache = new Dictionary(); - _lastAccessed = new Dictionary(); - _timeout = timeout; - } - - #endregion - - #region Internal Members - - /// - /// Clears everything from the cache. - /// - internal void Clear() - { - _internalCache.Clear(); - _lastAccessed.Clear(); - } - - /// - /// Removes the specified key from the cache. - /// - /// Key to be removed. - protected internal void Remove(Key key) - { - if (_internalCache.ContainsKey(key)) - _internalCache.Remove(key); - } - - /// - /// Returns the value associated with the key. - /// - /// Key of the value being requested. - /// Value or null if not found. - public Value this[Key key] - { - get - { - Value value; - lock (this) - { - if (_internalCache.TryGetValue(key, out value)) - _lastAccessed[key] = DateTime.UtcNow; - } - CheckIfServiceRequired(); - return value; - } - set - { - lock (this) - { - if (Contains(key)) - { - _internalCache[key] = value; - } - else - { - _internalCache.Add(key, value); - _lastAccessed[key] = DateTime.UtcNow; - } - } - } - } - - /// - /// If the key exists in the cache then provide the value in the - /// value parameter. - /// - /// Key of the value to be retrieved. - /// Set to the associated value if found. - /// True if the key was found in the list, otherwise false. - public bool GetTryParse(Key key, out Value value) - { - bool result = false; - if (key != null) - { - lock (this) - { - result = _internalCache.TryGetValue(key, out value); - if (result) - _lastAccessed[key] = DateTime.UtcNow; - } - } - else - { - value = default(Value); - } - CheckIfServiceRequired(); - return result; - } - - /// - /// Determines if the key is available in the cache. - /// - /// Key to be checked. - /// True if the key is found, otherwise false. - protected internal bool Contains(Key key) - { - bool result = false; - if (key != null) - { - lock (this) - { - result = _internalCache.ContainsKey(key); - if (result) - _lastAccessed[key] = DateTime.UtcNow; - } - } - return result; - } - - #endregion - - #region Private Members - - /// - /// If the time has passed the point another check of the cache is needed - /// start a thread to check the cache. - /// - private void CheckIfServiceRequired() - { - if (_nextServiceTime >= DateTime.UtcNow || _internalCache.Count <= 0) return; - - // Set the next service time to a date far in the future - // to prevent another thread being started. - _nextServiceTime = DateTime.MaxValue; -#if VER4 - Task.Factory.StartNew(() => ServiceCache(DateTime.UtcNow.AddMinutes(-_timeout))); -#else - ThreadPool.QueueUserWorkItem(ServiceCache, DateTime.UtcNow.AddMinutes(-_timeout)); -#endif - } - - /// - /// The main method of the thread to service the cache. Checks for old items - /// and removes them. - /// - /// The date before which items should be removed. - private void ServiceCache(object purgeDate) - { - Queue purgeKeys = new Queue(); - - // Obtain a list of the keys to be purged. - lock (this) - { -#if VER4 || VER35 - foreach (Key key in - _lastAccessed.Keys.Where(key => (DateTime) _lastAccessed[key] < (DateTime) purgeDate)) - { - purgeKeys.Enqueue(key); - } -#else - foreach (Key key in _lastAccessed.Keys) - { - if (_lastAccessed[key] < (DateTime) purgeDate) - purgeKeys.Enqueue(key); - } -#endif - } - - // Remove the keys from the lists. - if (purgeKeys.Count > 0) - { - while (purgeKeys.Count > 0) - { - Key key = purgeKeys.Dequeue(); - if (key != null) - { - lock (this) - { - if (_lastAccessed[key] < (DateTime) purgeDate) - { - _lastAccessed.Remove(key); - _internalCache.Remove(key); - } - } - } - } - } - - // Set the next service time to one minute from now. - _nextServiceTime = DateTime.UtcNow.AddMinutes(1); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Constants.cs b/Foundation/Constants.cs deleted file mode 100644 index b6c0877..0000000 --- a/Foundation/Constants.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* ********************************************************************* - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. - * See the License for the specific language governing rights and - * limitations under the License. - * - * The Original Code is named .NET Mobile API, first released under - * this licence on 11th March 2009. - * - * The Initial Developer of the Original Code is owned by - * 51 Degrees Mobile Experts Limited. Portions created by 51 Degrees - * Mobile Experts Limited are Copyright (C) 2009 - 2011. All Rights Reserved. - * - * Contributor(s): - * James Rosewell - * - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile -{ - internal static class Constants - { - /// - /// Alternative configuration file name - /// - internal const string CONFIG_FILENAME = "~/App_Data/51Degrees.mobi.config"; - - } -} diff --git a/Foundation/EventLog.cs b/Foundation/EventLog.cs deleted file mode 100644 index bfe2587..0000000 --- a/Foundation/EventLog.cs +++ /dev/null @@ -1,297 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Diagnostics; -using System.Security; -using FiftyOne.Foundation.Mobile.Configuration; - -#endregion - -namespace FiftyOne -{ - /// - /// Utility class, contains implementation for logging support. - /// - /// - /// This class should not be used in developers code. - /// - public class EventLog : Log - { - /// - /// Used to lock during the creation of the log level parameter and instance. - /// - private static readonly object _sync = new object(); - - /// - /// An instance of the event log. - /// - private static EventLog _instance; - - /// - /// Set to minus 1 to ensure value loaded correctly from web.config - /// file when the application starts. - /// - private static int _logLevel = -1; - - /// - /// The process id for the application. - /// - private static int _processId = -1; - - /// - /// The file name for the log file. - /// - private string _logFile; - - /// - /// An internal reference to the current static instance of the class. - /// - protected internal static EventLog Instance - { - get - { - if (_instance == null) - lock (_sync) - if (_instance == null) - _instance = new EventLog(); - return _instance; - } - } - - /// - /// If a log file section has been added to the web.config - /// then return the log file path specified. - /// - protected override string LogFile - { - get - { - if (_logFile == null) - { - lock (_sync) - { - if (_logFile == null) - { - if (Manager.Log != null && Manager.Log.Enabled) - { - _logFile = Support.GetFilePath(Manager.Log.LogFile); - } - } - } - } - return _logFile; - } - } - - private static int LogLevel - { - get - { - if (_logLevel == -1) - { - lock (_sync) - { - if (_logLevel == -1 && Manager.Log != null && Manager.Log.Enabled) - { - switch (Manager.Log.LogLevel) - { - case "Debug": - _logLevel = 4; - break; - case "Info": - _logLevel = 3; - break; - case "Warn": - _logLevel = 2; - break; - case "Fatal": - _logLevel = 1; - break; - default: - _logLevel = 0; - break; - } - } - } - } - // Not specified so return 0. - return _logLevel; - } - } - - internal static bool IsDebug - { - get { return LogLevel >= 4; } - } - - internal static bool IsInfo - { - get { return LogLevel >= 3; } - } - - internal static bool IsWarn - { - get { return LogLevel >= 2; } - } - - internal static bool IsFatal - { - get { return LogLevel >= 1; } - } - - private static int ProcessId - { - get - { - if (_processId == -1) - { - lock (_sync) - { - if (_processId == -1) - { - try - { - _processId = GetProcessId(); - } - catch (SecurityException) - { - _processId = 0; - } - } - } - } - return _processId; - } - } - - /// - /// Records a debug exception in the log file if debug logging is enabled. - /// - /// The exception to be recorded in the log file. - public static void Debug(Exception ex) - { - if (IsDebug) - { - Write("Debug", ex.Message); - Write("Debug", ex.StackTrace); - if (ex.InnerException != null) - Debug(ex.InnerException); - } - } - - /// - /// Records an info exception in the log file if info logging is enabled. - /// - /// The exception to be recorded in the log file. - public static void Info(Exception ex) - { - if (IsInfo) - { - Write("Info", ex.Message); - Write("Info", ex.StackTrace); - if (ex.InnerException != null) - Info(ex.InnerException); - } - } - - /// - /// Records a warn exception in the log file if warn logging is enabled. - /// - /// The exception to be recorded in the log file. - public static void Warn(Exception ex) - { - if (IsWarn) - { - Write("Warn", ex.Message); - Write("Warn", ex.StackTrace); - if (ex.InnerException != null) - Warn(ex.InnerException); - } - } - - /// - /// Records a fatal exception in the log file if fatal logging is enabled. - /// - /// The exception to be recorded in the log file. - public static void Fatal(Exception ex) - { - if (IsFatal) - { - Write("Fatal", ex.Message); - Write("Fatal", ex.StackTrace); - if (ex.InnerException != null) - Fatal(ex.InnerException); - } - } - - /// - /// Records the message in the log file if debug logging is enabled. - /// - /// The text message to record in the log file. - public static void Debug(string message) - { - if (IsDebug) - Write("Debug", message); - } - - /// - /// Records the message in the log file if info logging is enabled. - /// - /// The text message to record in the log file. - public static void Info(string message) - { - if (IsInfo) - Write("Info", message); - } - - /// - /// Records the message in the log file if warn logging is enabled. - /// - /// The text message to record in the log file. - public static void Warn(string message) - { - if (IsWarn) - Write("Warn", message); - } - - /// - /// Records the message in the log file if fatal logging is enabled. - /// - /// The text message to record in the log file. - public static void Fatal(string message) - { - if (IsFatal) - Write("Fatal", message); - } - - private static int GetProcessId() - { - return Process.GetCurrentProcess().Id; - } - - /// - /// Writes the level and message to the log file including the current time and process id. - /// - /// The level of the message. Values include debug, info, warn and fatal. - /// The message string to be written. - protected internal static void Write(string level, string message) - { - Instance.Write(String.Format("{0:o} - {1} - {2} - {3}", - DateTime.UtcNow, - ProcessId, - level, - message)); - } - } -} \ No newline at end of file diff --git a/Foundation/FiftyOne.Foundation 3.5.csproj b/Foundation/FiftyOne.Foundation 3.5.csproj deleted file mode 100644 index b0cbfe2..0000000 --- a/Foundation/FiftyOne.Foundation 3.5.csproj +++ /dev/null @@ -1,247 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {2C9B0E11-2654-49AF-855A-BFA629F302E8} - Library - Properties - FiftyOne.Foundation - FiftyOne.Foundation - v3.5 - 512 - - - - - - - - - PDA.ico - false - - - - - 3.5 - - false - false - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - - - true - full - false - bin\Debug35\ - TRACE;DEBUG;VER35 - prompt - 4 - - - - - pdbonly - true - bin\Release35\ - TRACE;VER35 - prompt - 4 - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - ASPXCodeBehind - - - - ASPXCodeBehind - - - ASPXCodeBehind - - - - - - ASPXCodeBehind - - - ASPXCodeBehind - - - - - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - \ No newline at end of file diff --git a/Foundation/FiftyOne.Foundation 4.csproj b/Foundation/FiftyOne.Foundation 4.csproj deleted file mode 100644 index 9e9ea7c..0000000 --- a/Foundation/FiftyOne.Foundation 4.csproj +++ /dev/null @@ -1,261 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {2C9B0E11-2654-49AF-855A-BFA629F302E8} - Library - Properties - FiftyOne.Foundation - FiftyOne.Foundation - v4.0 - 512 - SAK - SAK - SAK - SAK - PDA.ico - false - - - - - 3.5 - - false - false - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - - - true - full - false - bin\Debug4\ - TRACE;DEBUG;VER4 - prompt - 4 - bin\Debug4\FiftyOne.Foundation.xml - false - - - pdbonly - false - bin\Release4\ - TRACE;VER4 - prompt - 4 - bin\Release4\FiftyOne.Foundation.xml - true - - - - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - - ASPXCodeBehind - - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - - - ASPXCodeBehind - - - ASPXCodeBehind - - - - ASPXCodeBehind - - - - - ASPXCodeBehind - - - ASPXCodeBehind - - - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - - - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - - \ No newline at end of file diff --git a/Foundation/FiftyOne.Foundation 4.csproj.vspscc b/Foundation/FiftyOne.Foundation 4.csproj.vspscc deleted file mode 100644 index feffdec..0000000 --- a/Foundation/FiftyOne.Foundation 4.csproj.vspscc +++ /dev/null @@ -1,10 +0,0 @@ -"" -{ -"FILE_VERSION" = "9237" -"ENLISTMENT_CHOICE" = "NEVER" -"PROJECT_FILE_RELATIVE_PATH" = "" -"NUMBER_OF_EXCLUDED_FILES" = "0" -"ORIGINAL_PROJECT_FILE_PATH" = "" -"NUMBER_OF_NESTED_PROJECTS" = "0" -"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" -} diff --git a/Foundation/FiftyOne.Foundation.csproj b/Foundation/FiftyOne.Foundation.csproj deleted file mode 100644 index eadb3df..0000000 --- a/Foundation/FiftyOne.Foundation.csproj +++ /dev/null @@ -1,234 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {2C9B0E11-2654-49AF-855A-BFA629F302E8} - Library - Properties - FiftyOne.Foundation - FiftyOne.Foundation - v2.0 - 512 - - - - - - - - - PDA.ico - false - - - - - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - false - - - true - full - false - bin\Debug\ - TRACE;DEBUG;VER2 - prompt - 4 - bin\Debug\FiftyOne.Foundation.XML - AnyCPU - - - pdbonly - true - bin\Release\ - TRACE;VER2 - prompt - 4 - bin\Release\FiftyOne.Foundation.XML - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - - - ASPXCodeBehind - - - ASPXCodeBehind - - - - ASPXCodeBehind - - - - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - - - - - - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - \ No newline at end of file diff --git a/Foundation/Image/Support.cs b/Foundation/Image/Support.cs deleted file mode 100644 index fea4855..0000000 --- a/Foundation/Image/Support.cs +++ /dev/null @@ -1,141 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Collections.Generic; -using System.Drawing.Imaging; - -#endregion - -namespace FiftyOne.Foundation.Image -{ - /// - /// Class contains static methods to support image management. - /// - internal static class Support - { - #region Private Classes - - /// - /// Used to convert colors to bits per pixel. - /// - private class ColorsToBitsPerPixel - { - private readonly int _bitsPerPixel; - private readonly long _colors; - - protected internal ColorsToBitsPerPixel(int bitsPerPixel, long colors) - { - _bitsPerPixel = bitsPerPixel; - _colors = colors; - } - - protected internal int BitsPerPixel - { - get { return _bitsPerPixel; } - } - - protected internal long Colors - { - get { return _colors; } - } - } - - #endregion - - #region Fields - - private static List _colorTable; - private static Dictionary _contentTypes; - - #endregion - - #region Static Constructor & Support Methods - - static Support() - { - InitColorTable(); - InitContentTypes(); - } - - /// - /// Initialises the colours lookup table. - /// - private static void InitColorTable() - { - _colorTable = new List(); - AddPair(_colorTable, 1, 2); - AddPair(_colorTable, 2, 4); - AddPair(_colorTable, 3, 8); - AddPair(_colorTable, 4, 16); - AddPair(_colorTable, 5, 32); - AddPair(_colorTable, 6, 64); - AddPair(_colorTable, 7, 128); - AddPair(_colorTable, 8, 256); - AddPair(_colorTable, 9, 512); - AddPair(_colorTable, 10, 1024); - AddPair(_colorTable, 11, 2048); - AddPair(_colorTable, 12, 4096); - AddPair(_colorTable, 13, 8192); - AddPair(_colorTable, 14, 16384); - AddPair(_colorTable, 15, 32768); - AddPair(_colorTable, 16, 65536); - AddPair(_colorTable, 17, 131072); - AddPair(_colorTable, 18, 262144); - AddPair(_colorTable, 19, 524288); - AddPair(_colorTable, 20, 1048576); - AddPair(_colorTable, 21, 2097152); - AddPair(_colorTable, 22, 4194304); - AddPair(_colorTable, 23, 8388608); - AddPair(_colorTable, 24, 16777216); - AddPair(_colorTable, 25, 33554432); - AddPair(_colorTable, 26, 67108864); - AddPair(_colorTable, 27, 134217728); - AddPair(_colorTable, 28, 268435456); - AddPair(_colorTable, 29, 536870912); - AddPair(_colorTable, 30, 1073741824); - AddPair(_colorTable, 31, 2147483648); - AddPair(_colorTable, 32, 4294967296); - } - - /// - /// Populates the lookup table with context types. - /// - internal static void InitContentTypes() - { - _contentTypes = new Dictionary(); - _contentTypes.Add(ImageFormat.Png, "image/png"); - _contentTypes.Add(ImageFormat.Gif, "image/gif"); - _contentTypes.Add(ImageFormat.Jpeg, "image/jpeg"); - _contentTypes.Add(ImageFormat.Bmp, "image/bmp"); - _contentTypes.Add(ImageFormat.Tiff, "image/tiff"); - } - - private static void AddPair(List colorTable, int bitsPerPixel, long colors) - { - colorTable.Add(new ColorsToBitsPerPixel(bitsPerPixel, colors)); - } - - #endregion - - #region Static Methods - - internal static string GetContentType(ImageFormat format) - { - if (format != null && _contentTypes.ContainsKey(format)) - return _contentTypes[format]; - return null; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Licence.txt b/Foundation/Licence.txt deleted file mode 100644 index 14e2f77..0000000 --- a/Foundation/Licence.txt +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - 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/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/Foundation/Log.cs b/Foundation/Log.cs deleted file mode 100644 index 929307e..0000000 --- a/Foundation/Log.cs +++ /dev/null @@ -1,259 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading; - -#endregion - -#if VER4 - -using System.Threading.Tasks; - -#endif - -#if AZURE - -using Microsoft.WindowsAzure; -using Microsoft.WindowsAzure.StorageClient; -using System.Text.RegularExpressions; - -#endif - -namespace FiftyOne -{ - /// - /// This is the base class for recording messages in text files. The write operation to - /// file occurs outside of the current thread ensuring minimal impact on performance. - /// If the process completes before the thread has finished writing it is possible that - /// some messages will not be written. This is by design. - /// - /// - /// This class should not be used in developers code. - /// - public abstract class Log - { - #region Fields - - /// - /// An internal object used for synchronising access to the message queue. - /// - protected internal static object _syncQueue = new object(); - - /// - /// An internal object used to synchronising access to the log file. - /// - protected internal static object _syncWait = new object(); - - /// - /// The message queue to use to record log entries. - /// - private readonly Queue _queue = new Queue(); - - /// - /// Set to true if the message writing thread is running. - /// - private bool _running; - - #endregion - - #region Abstract Methods - - /// - /// Returns the full path to the file to be written to. - /// - protected abstract string LogFile { get; } - - #endregion - - #region Methods - -#if AZURE - - /// - /// The main loop for the log table service thread. - /// - protected void Run(Object stateInfo) - { - // Initialise the Azure table service creating the table if it does not exist. - var storageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(FiftyOne.Foundation.Mobile.Constants.AZURE_STORAGE_NAME)); - var serviceContext = new TableServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials); - var tableName = Regex.Replace(LogFile, "[^A-Za-z]+", String.Empty); - storageAccount.CreateCloudTableClient().CreateTableIfNotExist(tableName); - - while (IsQueueEmpty() == false) - { - try - { - while (IsQueueEmpty() == false) - { - lock (_syncQueue) - { - string message = _queue.Peek(); - if (message != null) - { - var entity = new LogMessageEntity(message); - serviceContext.AddObject(tableName, entity); - _queue.Dequeue(); - } - } - } - // Commit the new log entries to the database. - serviceContext.SaveChanges(); - } - catch - { - // End the thread and wait until another message comes - // arrives to resume writing. - _running = false; - return; - } - - // Sleep for 50ms incase any new messages come in. - Thread.Sleep(50); - } - _running = false; - } - -#else - - /// - /// The main loop for the log file thread. - /// - protected void Run(Object stateInfo) - { - while (IsQueueEmpty() == false) - { - FileStream stream = null; - try - { - if (String.IsNullOrEmpty(LogFile) == false) - { - stream = File.Open(LogFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite); - StreamWriter writer = null; - try - { - writer = new StreamWriter(stream); - while (IsQueueEmpty() == false) - { - lock (_syncQueue) - { - string message = _queue.Peek(); - if (message != null) - { - writer.WriteLine(message); - _queue.Dequeue(); - } - } - } - writer.Flush(); - } - catch - { - // End the thread and wait until another message - // arrives to resume writing. - _running = false; - return; - } - finally - { - if (writer != null) - { - writer.Close(); - writer.Dispose(); - } - } - } - } - catch - { - // End the thread and wait until another message comes - // arrives to resume writing. - _running = false; - return; - } - finally - { - if (stream != null) - { - stream.Close(); - stream.Dispose(); - } - } - // Sleep for 50ms incase any new messages come in. - Thread.Sleep(50); - } - _running = false; - } - -#endif - - /// - /// Returns true if the message queue is empty. - /// - /// - private bool IsQueueEmpty() - { - return (_queue.Count == 0); - } - - /// - /// Makes sure the logging thread is running and then writes the message - /// to the queue of messages to be serviced. - /// - /// The message to be written to the log file. - protected internal void Write(string message) - { - // If the queue is very large sleep for 10ms and - // give it time to reduce. - // This should never happen if debug is disabled. - if (_queue.Count > 100 && _running) - { - lock (_syncWait) - { - if (_queue.Count > 100 && _running) - { - Thread.Sleep(10); - } - } - } - - // Add this entry to the queue for writing. - lock (_syncQueue) - { - _queue.Enqueue(message); - } - - // Check the thread is running. - if (_running == false) - { - lock (_syncQueue) - { - if (_running == false) - { - _running = true; -#if VER4 - Task.Factory.StartNew(() => Run(null)); -#else - ThreadPool.QueueUserWorkItem(Run); -#endif - } - } - } - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/LogMessageEntity.cs b/Foundation/LogMessageEntity.cs deleted file mode 100644 index b00d538..0000000 --- a/Foundation/LogMessageEntity.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ -#if AZURE - -using Microsoft.WindowsAzure.StorageClient; -using System; - -namespace FiftyOne -{ - /// - /// Class used to encapsulate a message to be written to the log table service. - /// - public class LogMessageEntity : TableServiceEntity - { - /// - /// Creates a new instance of LogMessageEntity. - /// - public LogMessageEntity() { } - - /// - /// Creates a new instance of LogMessageEntity initialised - /// with the message provided. - /// - /// The message to be associated with the entity. - public LogMessageEntity(string message) : - base(DateTime.UtcNow.Hour.ToString(), Guid.NewGuid().ToString()) - { - Message = message; - } - - /// - /// The log message. - /// - public string Message { get; set; } - } -} - -#endif \ No newline at end of file diff --git a/Foundation/Mobile/Configuration/FilterElement.cs b/Foundation/Mobile/Configuration/FilterElement.cs deleted file mode 100644 index bbac1c9..0000000 --- a/Foundation/Mobile/Configuration/FilterElement.cs +++ /dev/null @@ -1,75 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Configuration -{ - /// - /// Contains information for all filters of a location element in the - /// web.config file. - /// - public sealed class FilterElement : ConfigurationElement - { - #region Fields - - private readonly Guid _uniqueId = Guid.NewGuid(); - - #endregion - - #region Properties - - /// - /// Used as the internal unique key when the property is empty or null. - /// - internal Guid UniqueId - { - get { return _uniqueId; } - } - - /// - /// Gets or sets the name of the property. - /// - [ConfigurationProperty("property", IsRequired = true, IsKey = true)] - public string Property - { - get { return (string)this["property"]; } - set { this["property"] = value; } - } - - /// - /// Gets or sets the expression to be used to determine a match. - /// - [ConfigurationProperty("matchExpression", IsRequired = true)] - public string MatchExpression - { - get { return (string)this["matchExpression"]; } - set { this["matchExpression"] = value; } - } - - /// - /// Gets or sets a value indicating whether this filter should be used. - /// - [ConfigurationProperty("enabled", IsRequired = false, DefaultValue = true)] - public bool Enabled - { - get { return (bool)this["enabled"]; } - set { this["enabled"] = value; } - } - - #endregion - } -} diff --git a/Foundation/Mobile/Configuration/LocationElement.cs b/Foundation/Mobile/Configuration/LocationElement.cs deleted file mode 100644 index 2881663..0000000 --- a/Foundation/Mobile/Configuration/LocationElement.cs +++ /dev/null @@ -1,145 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Configuration -{ - /// - /// Contains information for all location specified in the web.config file. - /// - public sealed class LocationElement : ConfigurationElementCollection - { - #region Fields - - private readonly Guid _uniqueId = Guid.NewGuid(); - - #endregion - - #region Properties - - /// - /// Used as the internal unique key when the name is empty or null. - /// - internal Guid UniqueId - { - get { return _uniqueId; } - } - - /// - /// Gets or sets the unique name of the redirection element. - /// - [ConfigurationProperty("name", IsRequired = true, IsKey = true)] - public string Name - { - get - { - return (string) this["name"]; - } - set - { - this["name"] = value; - } - } - - /// - /// Gets or sets the url of the webpage - /// - [ConfigurationProperty("url", IsRequired = true, IsKey = false)] - public string Url - { - get - { - return (string)this["url"]; - } - set - { - this["url"] = value; - } - } - - /// - /// A regular expression used to find macthing elements of the - /// original URL associated with the request. - /// - [ConfigurationProperty("matchExpression", IsRequired = false)] - public string MatchExpression - { - get - { - return (string)this["matchExpression"]; - } - set - { - this["matchExpression"] = value; - } - } - - /// - /// Gets or sets a value indicating whether this homepage should be used. - /// - [ConfigurationProperty("enabled", IsRequired = false, DefaultValue = true)] - public bool Enabled - { - get - { - return (bool)this["enabled"]; - } - set - { - this["enabled"] = value; - } - } - - #endregion - - #region ConfigurationElementCollection Members - - /// - /// Creates a new instance of . - /// - protected override ConfigurationElement CreateNewElement() - { - return new FilterElement(); - } - - /// - /// Get the element key. Check for empty strings and return null - /// to avoid a problem with the defaultvalue property of the key - /// element becoming an empty string and causing a duplicate key - /// exception within .NET. - /// - protected override object GetElementKey(ConfigurationElement element) - { - return element.GetHashCode(); - } - - #endregion - - #region Internal Members - - /// - /// Adds a new filter to the location collection. - /// - /// - internal void Add(FilterElement element) - { - BaseAdd(element); - } - - #endregion - } -} diff --git a/Foundation/Mobile/Configuration/LocationsCollection.cs b/Foundation/Mobile/Configuration/LocationsCollection.cs deleted file mode 100644 index 6923b8b..0000000 --- a/Foundation/Mobile/Configuration/LocationsCollection.cs +++ /dev/null @@ -1,71 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Configuration -{ - /// - /// A collection of objects. This class cannot be inherited. - /// - public sealed class LocationsCollection : ConfigurationElementCollection - { - #region Methods - - /// - /// Creates a new for the collection - /// - protected override ConfigurationElement CreateNewElement() - { - return new LocationElement(); - } - - /// - /// Get the element key. Check for empty strings and return null - /// to avoid a problem with the defaultvalue property of the key - /// element becoming an empty string and causing a duplicate key - /// exception within .NET. - /// - protected override object GetElementKey(ConfigurationElement element) - { - return element.GetHashCode(); - } - - #endregion - - #region Internal Methods - - /// - /// Adds a new element to the collection. - /// - /// Element to be added. - internal void Add(LocationElement element) - { - base.BaseAdd(element); - } - - /// - /// Removes all elements from the configuration. - /// - internal void Clear() - { - base.BaseClear(); - } - - #endregion - } -} - diff --git a/Foundation/Mobile/Configuration/LogSection.cs b/Foundation/Mobile/Configuration/LogSection.cs deleted file mode 100644 index 38a7b14..0000000 --- a/Foundation/Mobile/Configuration/LogSection.cs +++ /dev/null @@ -1,84 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Configuration -{ - /// - /// Configuration settings for the log file creation and detail. - /// - public class LogSection : ConfigurationSection - { - #region Constructors - - #endregion - - #region Properties - - /// - /// Returns true if the functionality of is enabled. - /// - internal bool Enabled - { - get { return ElementInformation.IsPresent; } - } - - /// - /// Log file used by Log class to record events. If not provided no logging will occur. - /// - [ConfigurationProperty("logFile", IsRequired = false)] - [StringValidator(InvalidCharacters = "!@#$%^&*()[]{};'\"|", MaxLength = 255)] - public string LogFile - { - get { return (string) this["logFile"]; } - } - - /// - /// The level to use when writing log entries. Valid values are: - /// Debug - /// Info - /// Warn - /// Fatal - /// - [ConfigurationProperty("logLevel", IsRequired = false)] - [StringValidator(InvalidCharacters = "!@#$%^&*()[]{};'\"|", MaxLength = 5)] - public string LogLevel - { - get { return (string) this["logLevel"]; } - } - - /// - /// - /// Optional attribute activityLogDirectory. - /// - /// - /// - /// If specified log files for page activity will be output to this directory. Unlike - /// IIS log files the mobile number and mobile device information will also be included. - /// - /// - /// Files will be written for each UTC day in the format YYYYMMDD.txt. - /// - [ConfigurationProperty("pageLogDirectory", IsRequired = false)] - [StringValidator(InvalidCharacters = "!@#$%^&*()[]{};'\"|", MaxLength = 255)] - public string PageLogDirectory - { - get { return Support.GetFilePath((string) this["pageLogDirectory"]); } - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Configuration/Manager.cs b/Foundation/Mobile/Configuration/Manager.cs deleted file mode 100644 index 6c4fe2f..0000000 --- a/Foundation/Mobile/Configuration/Manager.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Configuration -{ - internal static class Manager - { - #region Fields - - internal static LogSection Log; - internal static RedirectSection Redirect; - - #endregion - - #region Constructor - - static Manager() - { - Log = (LogSection)Support.GetWebApplicationSection("fiftyOne/log", false); - Redirect = (RedirectSection)Support.GetWebApplicationSection("fiftyOne/redirect", false); - - if (Redirect == null) - Redirect = new RedirectSection(); - } - - #endregion - - #region Manager - - /// - /// Creates a new configuration instance checking for - /// fresh data. - /// - internal static void Refresh() - { - // Ensure the managers detection section is refreshed in case the - // process is not going to restart as a result of the change. - ConfigurationManager.RefreshSection("fiftyOne/redirect"); - - Redirect = Support.GetWebApplicationSection("fiftyOne/redirect", false) as RedirectSection; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Configuration/RedirectSection.cs b/Foundation/Mobile/Configuration/RedirectSection.cs deleted file mode 100644 index bca8448..0000000 --- a/Foundation/Mobile/Configuration/RedirectSection.cs +++ /dev/null @@ -1,179 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Configuration; -using System.Text; -using System.Xml; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Configuration -{ - /// - /// Settings for automatic redirection of mobile devices. - /// - public sealed class RedirectSection : ConfigurationSection - { - #region Constructors - - /// - /// Default constructor for an instance of - /// - public RedirectSection() {} - - #endregion - - #region Methods - - /// - /// Simple settings to remove the declaration. - /// - private XmlWriterSettings Settings - { - get - { - XmlWriterSettings settings = new XmlWriterSettings(); - settings.OmitXmlDeclaration = true; - return settings; - } - } - - /// - /// Returns the XML that needs to be written to the configuration file. - /// - /// - internal string GetXmlElement() - { - StringBuilder sb = new StringBuilder(); - using (XmlWriter writer = XmlWriter.Create(sb, Settings)) - base.SerializeToXmlElement(writer, "redirect"); - return sb.ToString(); - } - - #endregion - - #region Properties - - /// - /// Returns true if the functionality of is enabled. - /// - internal bool Enabled - { - get { return ElementInformation.IsPresent; } - } - - /// - /// A file used to store the details of devices that have previously accessed the web - /// site to determine if they're making a subsequent request. Needed to ensure - /// multiple worker processes have a consistent view of previous activity. - /// (Optional – random behaviour will be experienced if not specified on web sites - /// with more than one worker processes) - /// - [ConfigurationProperty("devicesFile", IsRequired = false)] - [StringValidator(InvalidCharacters = "!@#$%^&*()[]{};'\"|", MaxLength = 255)] - public string DevicesFile - { - get { return (string) this["devicesFile"]; } - set { this["devicesFile"] = value; } - } - - /// - /// The number of minutes of inactivity that should occur before the requesting - /// device should be treated as making a new request to the web site for the - /// purposes of redirection. If the session is available the session timeout - /// will be used and override this value. (Optional - defaults to 20 minutes) - /// - [ConfigurationProperty("timeout", IsRequired = false, DefaultValue = "20")] - public int Timeout - { - get { return (int) this["timeout"]; } - set { this["timeout"] = value; } - } - - /// - /// If set to true only the first request received by the web site is redirected - /// to the mobileUrl when the site is accessed from a mobile device. - /// (Optional – defaults to true) - /// - [ConfigurationProperty("firstRequestOnly", IsRequired = false, DefaultValue = "true")] - public bool FirstRequestOnly - { - get { return (bool) this["firstRequestOnly"]; } - set { this["firstRequestOnly"] = value; } - } - - /// - /// This attribute is used when redirecting to a mobile home page. - /// If set to true the original URL will be encoded and set - /// as the query string for the . - /// (Optional – defaults to false) - /// - [ConfigurationProperty("originalUrlAsQueryString", IsRequired = false, DefaultValue = "false")] - public bool OriginalUrlAsQueryString - { - get { return (bool) this["originalUrlAsQueryString"]; } - set { this["originalUrlAsQueryString"] = value; } - } - - /// - /// Previously mobileRedirectUrl under the mobile/toolkit element. A url to direct - /// mobile devices to instead of the normal web sites landing page. (Optional) - /// - [ConfigurationProperty("mobileHomePageUrl", IsRequired = false, DefaultValue = "")] - [StringValidator(MaxLength = 255)] - public string MobileHomePageUrl - { - get { return (string) this["mobileHomePageUrl"]; } - set { this["mobileHomePageUrl"] = value; } - } - - /// - /// A regular expression used to identify pages on the web site that are designed - /// for mobile phones. Any page that derives from System.Web.UI.MobileControls.MobilePage - /// will automatically be treated as a mobile page. Use this attribute to tell redirection - /// about mobile pages derived from other base classes such as System.Web.UI.Page. - /// The value is evaluated against the HttpRequests AppRelativeCurrentExecutionFilePath and - /// Url properties. - /// Redirection needs to be aware of mobile pages so that requests to these pages can be - /// ignored. (Optional) - /// - [ConfigurationProperty("mobilePagesRegex", IsRequired = false, DefaultValue = "")] - [StringValidator(MaxLength = 2048)] - public string MobilePagesRegex - { - get { return (string) this["mobilePagesRegex"]; } - set { this["mobilePagesRegex"] = value; } - } - - /// - /// An optional collection of homepages that uses regular expressions to see if a mobile - /// device should be redirected to one of these pages. A device is defined in terms of - /// the manufacturer and model. - /// - [ConfigurationProperty("locations", IsRequired = false, IsDefaultCollection = true)] - [ConfigurationCollection(typeof(LocationsCollection), AddItemName = "location")] - public LocationsCollection Locations - { - get - { - return (LocationsCollection)this["locations"]; - } - set - { - this["locations"] = value; - } - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Configuration/Support.cs b/Foundation/Mobile/Configuration/Support.cs deleted file mode 100644 index 01443ae..0000000 --- a/Foundation/Mobile/Configuration/Support.cs +++ /dev/null @@ -1,389 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Configuration; -using System.IO; -using System.Security; -using System.Web.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Configuration -{ - /// - /// Utility methods for handling common configuration tasks such as converting virutal - /// to physical paths, or retrieving configuration sections. - /// - /// - /// This class should not be used in developers code. - /// - public static class Support - { - #region Fields - - /// - /// Lists of files to use as machine config file sources. - /// - private static readonly string _machineConfigFile = null; - - #endregion - - #region Constructor - - /// - /// Gets the path to the machine config file. If medium trust is enabled the call - /// will fail and web.config should be used. - /// - static Support() - { - // Try and access the machine configuration first. This may fail - // if in medium trust mode. - try - { - _machineConfigFile = InitMachineConfigFiles(); - return; - } - catch(Exception) - { - // Nothing we can do as there is a problem accessing - // the machine configuration. Likely to do with medium - // trust. - } - - // Use the first configuration file we can find which we - // do have read access to. - foreach (string file in Constants.ConfigFileNames) - { - string configFileName = GetFilePath(file); - // Checking for the existence of the configuration file. - if (File.Exists(configFileName)) - { - _machineConfigFile = configFileName; - break; - } - } - } - - /// - /// Has to be a seperate method incase a medium trust security exception is generated. - /// - private static string InitMachineConfigFiles() - { - return ConfigurationManager.OpenMachineConfiguration().FilePath; - } - - #endregion - - #region Public Methods - - /// - /// Returns a real path from a virtiual path. - /// - /// - /// - public static string GetFilePath(string pathSetOnWebConfig) - { - if (string.IsNullOrEmpty(pathSetOnWebConfig)) - return string.Empty; - - // Use file info to determine the file path if security permissions - // allow this. - try - { - if (DoesDirectoryOrFileExist(pathSetOnWebConfig)) - return pathSetOnWebConfig; - } - catch (SecurityException) - { - // Do nothing as we're not allowed to check for this type - // of file. - } - - // If this is a virtual path then remove the tilda, make absolute - // and then add the base directory. - if (pathSetOnWebConfig.StartsWith("~")) - return MakeAbsolute(RemoveTilda(pathSetOnWebConfig)); - - // Return the original path. - return pathSetOnWebConfig; - } - - /// - /// Returns the configuration section relating to the name provided. If the section - /// is present in the web.config file this location is used. If it's present in the - /// alternative configuration file then it will be return from there. - /// - /// The name of the section to be returned. - /// True if the section is mandatary. - /// Thrown if the section does not exist and the section is mandatory. - /// The configuration section requested. - public static ConfigurationSection GetWebApplicationSection(string sectionName, bool isManadatory) - { - ConfigurationSection configurationSection = WebConfigurationManager.GetWebApplicationSection(sectionName) as ConfigurationSection; - - // If section is not present in default web.config try to get it from the 51Degrees.mobi.config file. - if (configurationSection == null || configurationSection.ElementInformation.IsPresent == false) - configurationSection = GetConfigurationSectionFromAltConfig(sectionName, isManadatory); - - else - EventLog.Debug(string.Format("Getting '{0}' configuration from the web.config file.", sectionName)); - - return configurationSection; - } - - #endregion - - #region Internal and Private Methods - - private static bool DoesDirectoryOrFileExist(string pathSetOnWebConfig) - { - FileInfo info = new FileInfo(pathSetOnWebConfig); - if (info.Exists || info.Directory.Exists) - return true; - return false; - } - - internal static string RemoveTilda(string partialPath) - { - if (partialPath.StartsWith("~")) - return partialPath.Substring(1, partialPath.Length - 1); - return partialPath; - } - - internal static string MakeAbsolute(string partialPath) - { - // Remove any leading directory markers. - if (partialPath.StartsWith(Path.AltDirectorySeparatorChar.ToString()) || - partialPath.StartsWith(Path.DirectorySeparatorChar.ToString())) - partialPath = partialPath.Substring(1, partialPath.Length - 1); - // Combing with the application root. - return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, partialPath).Replace("/", "\\"); - } - - private static System.Configuration.Configuration OpenConfigFileMap(string configFileName) - { - // Define configuration file(s) mapping for loading the alternate configuration. - ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap(); - configFileMap.ExeConfigFilename = configFileName; - configFileMap.MachineConfigFilename = _machineConfigFile; - - // Load the alternate configuration file using the configuration file map definition. - return OpenConfigFileMap(configFileMap); - } - - private static System.Configuration.Configuration OpenConfigFileMap(ExeConfigurationFileMap configFileMap) - { - try - { - return ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None); - } - catch - { - return null; - } - } - - private static ConfigurationSection GetConfigurationSectionFromAltConfig(string sectionName, bool isMandatory) - { - System.Configuration.Configuration fiftyOneConfig = null; - - foreach (string file in Constants.ConfigFileNames) - { - string configFileName = GetFilePath(file); - - // Checking for the existence of the configured alternate config file - if (File.Exists(configFileName)) - { - // Load the alternate configuration file using the configuration file map definition. - fiftyOneConfig = OpenConfigFileMap(configFileName); - - // If alternate configuration file loaded successfully go ahead and retrieve requested - // confguration section. - if (fiftyOneConfig != null) - { - if (fiftyOneConfig.HasFile == true) - { - EventLog.Debug(String.Format("Getting '{0}' configuration from file '{1}'.", sectionName, configFileName)); - ConfigurationSection section = fiftyOneConfig.GetSection(sectionName); - EventLog.Debug(String.Format("Got section '{0}'.", section)); - if (section != null) - return section; - else - EventLog.Debug(String.Format("Null section for '{0}' configuration from file '{1}'.", sectionName, configFileName)); - } - } - } - } - - // If the configuration section is mandatory and failed to load the alternate configuration throw the exception. - if (isMandatory) - throw new MobileException(string.Format( - "Could not retrieve '{0}' section from configuration files '{1}'.", - sectionName, - String.Join(", ", Constants.ConfigFileNames))); - - return null; - } - - /// - /// Sets the section name in the first valid configuration file to the value contained - /// in the section. - /// - /// - internal static void SetWebApplicationSection(ConfigurationSection section) - { - try - { - try - { - System.Configuration.Configuration configuration = WebConfigurationManager.OpenWebConfiguration(null); - - // If the section is present then try setting it. - if (configuration != null) - { - ConfigurationSection existingSection = configuration.GetSection(section.SectionInformation.SectionName); - if (existingSection != null && existingSection.ElementInformation.IsPresent) - { - SetConfigurationSection(section, configuration); - return; - } - } - } - catch (ConfigurationErrorsException) - { - // Can't get to the master configuration file. Do nothing and carry on. - } - - // If section is not present in default web.config try to set it with the alternative files. - SetConfigurationSectionFromAltConfig(section); - } - catch (Exception ex) - { - throw new ConfigurationErrorsException(String.Format( - "Could not set configuration name '{0}'.", - section.SectionInformation.SectionName), ex); - } - } - - internal static System.Configuration.Configuration GetConfigurationContainingSectionGroupName(string name) - { - foreach (string file in Constants.ConfigFileNames) - { - string configFileName = GetFilePath(file); - - // Checking for the existence of the configured alternate config file - if (File.Exists(configFileName)) - { - // Load the alternate configuration file using the configuration file map definition. - System.Configuration.Configuration fiftyOneConfig = OpenConfigFileMap(configFileName); - - // If alternate configuration file loaded successfully go ahead and retrieve requested - // confguration section. - if (fiftyOneConfig != null && fiftyOneConfig.HasFile == true) - { - foreach (ConfigurationSectionGroup group in fiftyOneConfig.SectionGroups) - if (SectionGroupMatch(group, name)) - return fiftyOneConfig; - } - } - } - - return null; - } - - /// - /// Checks to determine if the group contains the section name requested. - /// - /// - /// - /// - private static bool SectionGroupMatch(ConfigurationSectionGroup group, string name) - { - foreach (ConfigurationSection section in group.Sections) - if (section.SectionInformation.SectionName == name) - return true; - - foreach (ConfigurationSectionGroup child in group.SectionGroups) - if (SectionGroupMatch(child, name)) - return true; - - return false; - } - - /// - /// Sets the section name in the first valid alternative configuration file to the value contained - /// in the section. - /// - /// - internal static void SetConfigurationSectionFromAltConfig(ConfigurationSection section) - { - Exception lastException = null; - - foreach (string file in Constants.ConfigFileNames) - { - try - { - string configFileName = GetFilePath(file); - - // Checking for the existence of the configured alternate config file - if (File.Exists(configFileName)) - { - // Load the alternate configuration file using the configuration file map definition. - System.Configuration.Configuration fiftyOneConfig = OpenConfigFileMap(configFileName); - - // If alternate configuration file loaded successfully go ahead and retrieve requested - // confguration section. - if (fiftyOneConfig != null && fiftyOneConfig.HasFile == true && - SetConfigurationSection(section, fiftyOneConfig)) - return; - } - } - catch (SecurityException ex) - { - // Ignore as could be because file permissions are denied. Move - // to the next file. - lastException = ex; - } - } - - throw new MobileException(String.Format( - "Could not set section with name '{0}' in any configuration files.", - section.SectionInformation.SectionName), lastException); - } - - /// - /// Replaces an existing section with the name provided with a new one. - /// - /// The definintion of the section. - /// The configuration it's being replaced within. - private static bool SetConfigurationSection(ConfigurationSection section, System.Configuration.Configuration configuration) - { - ConfigurationSection existingSection = configuration.GetSection(section.SectionInformation.SectionName); - - // Remove the existing section if it exists. - if (existingSection != null && - existingSection.GetType() == section.GetType()) - { - foreach (string key in existingSection.ElementInformation.Properties.Keys) - existingSection.ElementInformation.Properties[key].Value = - section.ElementInformation.Properties[key].Value; - configuration.Save(ConfigurationSaveMode.Modified); - return true; - } - return false; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Configuration/UrlCollection.cs b/Foundation/Mobile/Configuration/UrlCollection.cs deleted file mode 100644 index c18f197..0000000 --- a/Foundation/Mobile/Configuration/UrlCollection.cs +++ /dev/null @@ -1,158 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Configuration -{ - /// - /// A collection of . This class cannot be inherited. - /// - public sealed class UrlCollection : ConfigurationElementCollection - { - #region Constructors - - #endregion - - #region Methods - - /// - /// Creates a new instance of . - /// - protected override ConfigurationElement CreateNewElement() - { - return new UrlElement(); - } - - /// - /// Gets the element key value. - /// - protected override Object GetElementKey(ConfigurationElement element) - { - return ((UrlElement) element).Url; - } - - /// - /// Add element to the base collection. - /// - protected override void BaseAdd(ConfigurationElement element) - { - BaseAdd(element, false); - } - - /// - /// Gets the index of the specific element inside the collection. - /// - /// a to locate in the the collection. - /// The index of the element in the collection. - /// thrown if equals null. - public int IndexOf(UrlElement element) - { - if (element == null) - throw new ArgumentNullException("element"); - return BaseIndexOf(element); - } - - /// - /// Add element into the collection. - /// - /// a to add to the collection. - /// thrown if equals null. - public void Add(UrlElement element) - { - if (element == null) - throw new ArgumentNullException("element"); - BaseAdd(element); - } - - /// - /// Removes a from the collection. - /// - /// a to remove from the collection. - /// thrown if equals null. - public void Remove(UrlElement element) - { - if (element == null) - throw new ArgumentNullException("element"); - - if (BaseIndexOf(element) >= 0) - BaseRemove(element.Url); - } - - /// - /// Removes a at the specified index location. - /// - /// Index of the element to remove in the collection. - /// Thrown if is less than zero or bigger than the number of indexes on the collections. - public void RemoveAt(int index) - { - if ((index < 0) || (index > base.Count - 1)) - throw new ArgumentOutOfRangeException("index"); - BaseRemoveAt(index); - } - - /// - /// Removes a from the collection. - /// - /// Url of the element in the collection to remove. - /// thrown if equals null. - public void Remove(string url) - { - if (string.IsNullOrEmpty(url)) - throw new ArgumentNullException("url"); - - BaseRemove(url); - } - - /// - /// Removes all configuration elements from the collection. - /// - public void Clear() - { - BaseClear(); - } - - #endregion - - #region Properties - - /// - /// Gets or sets the . - /// - public UrlElement this[int index] - { - get { return (UrlElement) BaseGet(index); } - set - { - if (BaseGet(index) != null) - { - BaseRemoveAt(index); - } - BaseAdd(index, value); - } - } - - /// - /// Gets or sets the . - /// - public new UrlElement this[string name] - { - get { return (UrlElement) BaseGet(name); } - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Configuration/UrlElement.cs b/Foundation/Mobile/Configuration/UrlElement.cs deleted file mode 100644 index a1fdbc8..0000000 --- a/Foundation/Mobile/Configuration/UrlElement.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Configuration -{ - /// - /// Used in the web.config to provide Urls and refresh periods to automatically - /// update application data files such as 51Degrees.mobi data files. - /// - public sealed class UrlElement : ConfigurationElement - { - #region Constructors - - #endregion - - #region Properties - - /// - /// Gets or sets the url. - /// - [ConfigurationProperty("url", IsRequired = true)] - [StringValidator(InvalidCharacters = "!@#$%^*()[]{};'\"|", MaxLength = 255)] - public string Url - { - get { return (string) this["url"]; } - } - - /// - /// Gets or sets a value indicating whether this url should be used. - /// - [ConfigurationProperty("days", IsRequired = false, DefaultValue = 7)] - public int Days - { - get { return (int) this["days"]; } - } - - /// - /// Gets or sets a value indicating whether this url should be used. - /// - [ConfigurationProperty("enabled", IsRequired = false, DefaultValue = true)] - public bool Enabled - { - get { return (bool) this["enabled"]; } - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/AutoUpdate.cs b/Foundation/Mobile/Detection/AutoUpdate.cs deleted file mode 100644 index e1a706b..0000000 --- a/Foundation/Mobile/Detection/AutoUpdate.cs +++ /dev/null @@ -1,345 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Security.Cryptography; -using System.Text; -using System.Threading; -using System.Web.Hosting; -using FiftyOne.Foundation.Mobile.Detection.Configuration; - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Used to fetch new device data from 51Degrees.mobi if a premium - /// licence has been installed. - /// - internal static class AutoUpdate - { - #region Fields - - /// - /// Maps to the binary file path. - /// - private static FileInfo _binaryFile = null; - - /// - /// Used to signal between multiple instances of the update - /// threads. - /// - private static AutoResetEvent _autoUpdateSignal = new AutoResetEvent(true); - - private static AutoResetEvent _autoFileUpdateSignal = new AutoResetEvent(true); - - private static AutoResetEvent _autoDownloadUpdateSignal = new AutoResetEvent(true); - - #endregion - - #region Internal Properties - - /// - /// Returns details of the binary file to be updated. - /// - internal static FileInfo BinaryFile - { - get - { - if (_binaryFile == null) - { - _binaryFile = DataOnDisk(); - } - return _binaryFile; - } - } - - #endregion - - #region Static Methods - - /// - /// Gets FileInfo on the data file currently on disk. Returns null if no file was found. - /// - /// - private static FileInfo DataOnDisk() - { - EventLog.Debug("Examining disk for newer data file."); - if (String.IsNullOrEmpty(Manager.BinaryFilePath) == false) - return new FileInfo(Manager.BinaryFilePath); - return null; - } - - private static string GetMd5Hash(byte[] value) - { - using (MD5 md5Hash = MD5.Create()) - return GetMd5Hash(md5Hash, value); - } - - private static string GetMd5Hash(MD5 md5Hash, byte[] value) - { - if (value == null) - return String.Empty; - - // Convert the input string to a byte array and compute the hash. - byte[] data = md5Hash.ComputeHash(value); - - // Create a new Stringbuilder to collect the bytes - // and create a string. - StringBuilder sBuilder = new StringBuilder(); - - // Loop through each byte of the hashed data - // and format each one as a hexadecimal string. - for (int i = 0; i < data.Length; i++) - { - sBuilder.Append(data[i].ToString("x2")); - } - - // Return the hexadecimal string. - return sBuilder.ToString(); - } - - /// - /// Checks the MD5 hash of the data against the expected value. - /// - /// - /// - internal static void ValidateMD5(WebClient client, byte[] data) - { - // Check the MD5 hash of the data downloaded. - string mdHash = client.ResponseHeaders["Content-MD5"]; - if (mdHash != GetMd5Hash(data)) - throw new MobileException(String.Format( - "MD5 hash '{0}' validation failure with data downloaded from update URL '{1}'.", - mdHash, - client.BaseAddress)); - - } - - /// - /// Throws an exception if the data is not valid. - /// - /// The data to use to create the provider. - /// A newly created provider. - internal static Provider CreateProvider(byte[] data) - { - try - { - // Create new provider with the data to ensure it is valid. - Provider provider = Binary.Reader.Create(data); - if (provider.AllDevices.Count == 0) - throw new MobileException("No devices found in downloaded data."); - return provider; - } - catch (Exception ex) - { - throw new MobileException("Exception validating data array", ex); - } - } - - /// - /// Used to get the url for data download. - /// - /// The full url including all parameters needed to download - /// the device data file. - internal static string FullUrl() - { - return FullUrl(LicenceKey.Keys); - } - - /// - /// Used to get the url for data download. - /// - /// An array of licences to try. - /// The full url including all parameters needed to download - /// the device data file. - internal static string FullUrl(string[] licences) - { - List parameters = new List(); - parameters.Add(String.Format("LicenseKeys={0}", String.Join("|", licences))); - parameters.Add(String.Format("Download={0}", bool.TrueString)); - parameters.Add("Type=Binary"); - - return String.Format("{0}?{1}", - Constants.AutoUpdateUrl, - String.Join("&", parameters.ToArray())); - } - - #endregion - - #region Thread Methods - - /// - /// Checks if a newer file is on disk than the one in memory, forcing an update - /// if it is. This method is designed to run a seperate thread from the one - /// performing detection. - /// - /// Not used. Can be null. - internal static void CheckForNewFile(object state) - { - try - { - // Wait until any other threads have finished executing. - _autoFileUpdateSignal.WaitOne(); - - // get file info of data currently on disk and compare it to currently loaded data. - FileInfo diskFile = DataOnDisk(); - - if (diskFile != null && BinaryFile != null) - { - // update active provider if data is newer - if (diskFile.LastWriteTimeUtc != BinaryFile.LastWriteTimeUtc) - Factory.ForceDataUpdate(); - } - } - catch (ThreadAbortException ex) - { - EventLog.Warn(new MobileException( - "Auto local file check thread aborted", - ex)); - } - catch (Exception ex) - { - if (BinaryFile != null && BinaryFile.FullName != null) - { - EventLog.Warn(new MobileException(String.Format( - "Exception local file check thread binary data file '{0}'.", - BinaryFile.FullName), ex)); - } - else - { - EventLog.Fatal(ex); - } - } - finally - { - // signal any waiting threads to start - _autoFileUpdateSignal.Set(); - } - } - - /// - /// Checks if a new data file is available for download and if it is newer than - /// the current data on disk, if enough time has passed between now and the write - /// time of the current data in memory. See Constants.AutoUpdateWait. This method - /// is designed to be used in a seperate thread from the one performing detection. - /// - /// Not used. Can be null. - internal static void CheckForUpdate(object state) - { - try - { - // Wait until any other threads have finished executing. - _autoDownloadUpdateSignal.WaitOne(); - - // If licence keys are available auto update. - if (LicenceKey.Keys.Length > 0) - { - // Check the last accessed date of the binary file to determine - // if it should be updated. - if (BinaryFile != null && - BinaryFile.LastWriteTimeUtc.Add(Constants.AutoUpdateWait) < DateTime.UtcNow) - { - if (Download()) - Factory.ForceDataUpdate(); - } - } - } - catch (ThreadAbortException ex) - { - EventLog.Warn(new MobileException( - "Auto update download thread aborted", - ex)); - } - catch (Exception ex) - { - if (BinaryFile != null && BinaryFile.FullName != null) - { - EventLog.Warn(new MobileException(String.Format( - "Exception auto update download binary data file '{0}'.", - BinaryFile.FullName), ex)); - } - else - { - EventLog.Fatal(ex); - } - } - finally - { - // Signal any waiting threads to start. - _autoDownloadUpdateSignal.Set(); - } - } - - /// - /// Downloads and updates the premium data file. - /// - internal static bool Download() - { - // Download the latest data. - WebClient client = new WebClient(); - byte[] data = client.DownloadData(FullUrl()); - - // Validate the results. - ValidateMD5(client, data); - Provider provider = CreateProvider(data); - - // Check this is new data based on publish data and - // number of available properties. - if (provider.PublishedDate != Factory.ActiveProvider.PublishedDate || - provider.Properties.Count != Factory.ActiveProvider.Properties.Count) - { - // Both the MD5 hash was good and the provider was created. - // Save the data and force the factory to reload. - File.WriteAllBytes(BinaryFile.FullName, data); - - // Sets the last modified time of the file downloaded. - BinaryFile.LastWriteTimeUtc = provider.PublishedDate; - - EventLog.Info(String.Format( - "Automatically updated binary data file '{0}' with version " + - "published on the '{1:d}'.", - BinaryFile.FullName, - provider.PublishedDate)); - - return true; - } - return false; - } - - /// - /// Writes a file to the bin folder to reset the application if the - /// data file is not already in the bin folder. - /// - internal static void Reset() - { - try - { - DirectoryInfo binDirectory = new DirectoryInfo(Path.Combine( - HostingEnvironment.ApplicationPhysicalPath, "bin")); - - if (BinaryFile.Directory.FullName.Equals(binDirectory.FullName) == false) - { - File.WriteAllText( - Path.Combine(binDirectory.FullName, "51Degrees.mobi.reset.txt"), - "This file is used to force worker processes to restart following a data file update. It can be deleted."); - } - } - catch - { - // Ignore as there is nothing we can do. - } - } - - #endregion - } -} diff --git a/Foundation/Mobile/Detection/BaseDeviceInfo.cs b/Foundation/Mobile/Detection/BaseDeviceInfo.cs deleted file mode 100644 index 43084ed..0000000 --- a/Foundation/Mobile/Detection/BaseDeviceInfo.cs +++ /dev/null @@ -1,546 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections.Generic; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Represents a device and holds all its settings. - /// - public class BaseDeviceInfo - { - #region Fields - - /// - /// Used to populate the active children. - /// - private object _lock = new object(); - - /// - /// A list of child devices. - /// - internal List _children = new List(); - - /// - /// A list of the active children for the device. - /// - internal List _activeChildren = null; - - /// - /// The parent device. - /// - internal BaseDeviceInfo _parent; - - /// - /// Holds all properties from the current device - /// - private Collection _deviceProperties; - - /// - /// The unique Id of the device. - /// - private string _deviceId; - - /// - /// A reference to the provider associated with this device. - /// - protected Provider _provider; - - /// - /// The useragent string of the device. - /// - private string _userAgent; - - /// - /// A list of the profile IDs which make up the device. - /// - private string[] _profileIDs = null; - - /// - /// A collection of handler specific data. - /// - private SortedList _handlerData; - - #endregion - - #region Public Properties - - /// - /// Contains the device user agent string. - /// - public string UserAgent - { - get { return _userAgent; } - } - - /// - /// The parent of the device, or null if this is a root device. - /// - public BaseDeviceInfo Parent - { - get { return _parent; } - set - { - // update the parent, ensuring the child collection - // is also updated. - if (_parent != null) - { - _parent._children.Remove(this); - _parent._activeChildren = null; - } - _parent = value; - if (_parent != null) - _parent._children.Add(this); - } - } - - /// - /// Gets the unique identifier of the device. - /// - public string DeviceId - { - get { return _deviceId; } - } - - /// - /// Returns the profile IDs which make up the device ID. - /// - public string[] ProfileIDs - { - get - { - if (_profileIDs == null) - { - List list = new List(); - foreach (string id in DeviceId.Split(new string[] { Constants.ProfileSeperator, " " }, StringSplitOptions.RemoveEmptyEntries)) - list.Add(id); - _profileIDs = list.ToArray(); - } - return _profileIDs; - } - } - - /// - /// Returns true if the device is only available in the premium data set. - /// - public bool IsPremium - { - get - { - return Detection.Provider.EmbeddedProvider.GetDeviceInfoByID(DeviceId) == null; - } - } - - #endregion - - #region Internal Properties - - /// - /// Returns the provider associated with the device. - /// - internal Provider Provider - { - get { return _provider; } - } - - /// - /// Internal accessor for user agent string. - /// - internal string InternalUserAgent - { - set { _userAgent = value; } - } - - /// - /// The list of device properties. - /// - internal Collection Properties - { - get { return _deviceProperties; } - } - - /// - /// Returns a list of the children that are active - /// with properties assigned to them. - /// - internal List ActiveChildren - { - get - { - if (_activeChildren == null) - { - lock (_lock) - { - if (_activeChildren == null) - { - _activeChildren = new List(); -#if VER4 || VER35 - _activeChildren = _children.Where(i => - i.Properties.Count > 0 || - i._children.Count > 0).ToList(); -#else - foreach (BaseDeviceInfo child in _children) - if (child.Properties.Count > 0 || - child._children.Count > 0) - _activeChildren.Add(child); -#endif - } - } - } - return _activeChildren; - } - } - - #endregion - - #region Private Properties - - /// - /// Returns the data object for the specific handler. - /// - private SortedList HandlerData - { - get - { - if (_handlerData == null) - { - lock (_lock) - { - if (_handlerData == null) - { - _handlerData = new SortedList(); - } - } - } - return _handlerData; - } - } - - #endregion - - #region Handler Data Methods - - /// - /// Returns a the handlers data object of type T. If no data has - /// been created for the handler then new data is created. - /// - /// The type of handler data to store. - /// The handler related to the device. - /// The data of type T, or a new instance. - internal object GetHandlerData(Handlers.Handler handler) where T : new() - { - object data = null; - if (HandlerData.TryGetValue(handler, out data) == false) - { - lock (HandlerData) - { - if (HandlerData.TryGetValue(handler, out data) == false) - { - data = new T(); - HandlerData.Add(handler, data); - } - } - } - return data; - } - - #endregion - - #region Constructors - - /// - /// Hide the default constructor. - /// - private BaseDeviceInfo() - { - } - - /// - /// Creates an instance of . - /// - /// User agent string used to identify this device. - /// A unique Identifier of the device. - /// A reference to the complete index of devices. - /// The parent device if one exists. - internal BaseDeviceInfo( - Provider devices, - string deviceId, - string userAgent, - BaseDeviceInfo parent) - { - Init(devices, deviceId, userAgent, parent); - } - - /// - /// Creates an instance of . - /// - /// User agent string used to identify this device. - /// A unique Identifier of the device. - /// A reference to the complete index of devices. - internal BaseDeviceInfo( - Provider devices, - string deviceId, - string userAgent) - { - Init(devices, deviceId, userAgent); - } - - /// - /// Creates an instance of DeviceInfo. - /// - /// A unique Identifier of the device. - /// A reference to the complete index of devices. - internal BaseDeviceInfo( - Provider devices, - string deviceId) - { - Init(devices, deviceId); - } - - private void Init( - Provider devices, - string deviceId) - { - if (string.IsNullOrEmpty(deviceId)) - throw new ArgumentNullException("deviceId"); - - if (devices == null) - throw new ArgumentNullException("devices"); - - _provider = devices; - _deviceId = deviceId; - _deviceProperties = new Collection(devices.Strings); - } - - private void Init( - Provider devices, - string deviceId, - string userAgent, - BaseDeviceInfo parent) - { - Parent = parent; - Init(devices, deviceId, userAgent); - } - - private void Init( - Provider devices, - string deviceId, - string userAgent) - { - _userAgent = userAgent; - Init(devices, deviceId); - } - - #endregion - - #region Parent Methods - - /// - /// Returns true if the deviceId is in the parent hierarchy of the - /// device. - /// - /// The device being checked. - /// True if the device is within the parent hierarchy. - internal bool GetIsParent(BaseDeviceInfo device) - { - if (this == device) - return true; - if (Parent != null) - return Parent.GetIsParent(device); - return false; - } - - #endregion - - #region Property Methods - - /// - /// Gets the capability value index in the static Strings collection for this device - /// based on the index of the capability name. If this device does not have the - /// value then checks the parent if one exists. - /// - /// Capability name index. - /// Capability index value in the String collection, or null if the capability does not exist. - internal protected virtual List GetPropertyValueStringIndexes(int index) - { - List value; - if (_deviceProperties.TryGetValue(index, out value)) - return value; - if (Parent != null) - return Parent.GetPropertyValueStringIndexes(index); - return null; - } - - /// - /// Returns the string index of the first element in the collection. - /// - /// Capability name index. - /// Capability index value in the String collection, or -1 if the capability does not exist. - internal protected virtual int GetFirstPropertyValueStringIndex(int index) - { - IList value = GetPropertyValueStringIndexes(index); - if (value != null && value.Count > 0) - return value[0]; - return -1; - } - - /// - /// Returns a list of the string values for the property index string provided. - /// - /// The string index of the property name. - /// A list of string values. - internal protected List GetPropertyValues(int propertyStringIndex) - { - List values = new List(); - foreach (int index in GetPropertyValueStringIndexes(propertyStringIndex)) - if (index >= 0) - values.Add(Provider.Strings.Get(index)); - return values; - } - - /// - /// Adds the device properties to the collection. - /// - /// Collection to have properties added to. - internal protected void AddProperties(SortedList> collection) - { - foreach (int propertyStringIndex in Properties.Keys) - { - string property = _provider.Strings.Get(propertyStringIndex); - if (Constants.ExcludePropertiesFromAllProperties.Contains(property) == false && - collection.ContainsKey(property) == false) - collection.Add( - property, - GetPropertyValues(propertyStringIndex)); - } - if (Parent != null) - Parent.AddProperties(collection); - } - - /// - /// Gets the value of the first value for the property. - /// - /// - /// - public string GetFirstPropertyValue(string property) - { - int index = GetFirstPropertyValueStringIndex(Provider.Strings.Add(property)); - if (index >= 0) - return Provider.Strings.Get(index); - - // Check for any special values not held in - // the strings collection. - switch (property) - { - case Constants.DeviceId: return DeviceId; - } - - return null; - } - - /// - /// Returns a list of the string values for the property. - /// - /// - /// - public List GetPropertyValues(string property) - { - List values = new List(); - List indexes = GetPropertyValueStringIndexes(Provider.Strings.Add(property)); - if (indexes != null) - { - foreach (int index in indexes) - { - if (index >= 0) - values.Add(Provider.Strings.Get(index)); - } - } - else - { - // Check for any special values not held in - // the strings collection. - switch (property) - { - case Constants.DeviceId: values.Add(DeviceId); break; - } - } - return values; - } - - /// - /// Returns a sorted list containing all the property values for the - /// the device. - /// - public SortedList> GetAllProperties() - { - SortedList> collection = new SortedList>(); - collection.Add(Constants.DeviceId, new List(new string[] { DeviceId })); -#if DEBUG - List handlerNames = new List(); - foreach (FiftyOne.Foundation.Mobile.Detection.Handlers.Handler handler in _provider.GetHandlers(UserAgent)) - handlerNames.Add(handler.Name); - collection.Add("Handlers", new List(new string[] { String.Join(", ", handlerNames.ToArray()) })); - collection.Add("UserAgent", new List(new string[] { UserAgent })); -#endif - AddProperties(collection); - return collection; - } - - #endregion - - #region Equal Members - - /// - /// Checks if another BaseDeviceInfo is equal to this one. - /// - /// Other BaseDeviceInfo. - /// True if the object instances are the same. - internal bool Equals(BaseDeviceInfo other) - { - return DeviceId.Equals(other.DeviceId) && - UserAgent.Equals(other.UserAgent) && - Properties.Equals(other.Properties) && - CapabilitiesEquals(other); - } - - /// - /// Check the strings are all equal. - /// - /// Other BaseDeviceInfo. - /// True if the object capability strings are the same. - private bool CapabilitiesEquals(BaseDeviceInfo other) - { - foreach(int key in Properties.Keys) - { - if (_provider.Strings.Get(key).Equals(other.Provider.Strings.Get(key)) == false) - return false; - foreach(int value in GetPropertyValueStringIndexes(key)) - if (_provider.Strings.Get(value).Equals(other.Provider.Strings.Get(value)) == false) - return false; - } - return true; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/BaseProvider.cs b/Foundation/Mobile/Detection/BaseProvider.cs deleted file mode 100644 index 3062d9b..0000000 --- a/Foundation/Mobile/Detection/BaseProvider.cs +++ /dev/null @@ -1,383 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.Collections.Specialized; -using FiftyOne.Foundation.Mobile.Detection.Handlers; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// The base provider class used by all detection providers. - /// - public class BaseProvider - { - #region Fields - - /// - /// A list of handlers used to match devices. - /// - private readonly List _handlers = new List(); - - /// - /// Collection of all strings used by the provider. - /// - internal readonly Strings Strings = new Strings(); - - /// - /// Hashtable of all devices keyed on device hash code. - /// - internal readonly SortedDictionary> AllDevices = - new SortedDictionary>(); - - /// - /// A list of string indexes used for user agent profile properties. - /// - private List _userAgentProfileStringIndexes; - - /// - /// List of all the actual devices ignoring parents, or those - /// children added to handle useragent strings. - /// - private List _actualDevices = null; - - private object _lockDevices = new object(); - - #endregion - - #region Internal Properties - - /// - /// Returns a list of the string indexes for user agent profile properties. - /// - internal List UserAgentProfileStringIndexes - { - get - { - if (_userAgentProfileStringIndexes == null) - { - _userAgentProfileStringIndexes = new List(); - foreach (string value in Constants.UserAgentProfiles) - _userAgentProfileStringIndexes.Add(Strings.Add(value)); - } - return _userAgentProfileStringIndexes; - } - } - - #endregion - - #region Public Properties - - /// - /// A list of handlers being used by the provider. - /// - public List Handlers - { - get { return _handlers; } - } - - /// - /// Returns a list of all devices available to the provider which - /// have properties assigned to them. This is needed to ignore devices - /// which are only present to represent a useragent and do not have - /// any properties assigned to them. - /// - public List Devices - { - get - { - if (_actualDevices == null) - { - lock (_lockDevices) - { - if (_actualDevices == null) - { - _actualDevices = new List(); - foreach (int key in AllDevices.Keys) - foreach (BaseDeviceInfo device in AllDevices[key]) - if (device.DeviceId.Split(new string[] { Constants.ProfileSeperator }, StringSplitOptions.RemoveEmptyEntries).Length == 4) - _actualDevices.Add(device); - } - } - } - return _actualDevices; - } - } - - #endregion - - #region Methods - - /// - /// Find all the devices that match the request. - /// - /// List of http headers associated with the request. - /// The closest matching device. - internal Matchers.Results GetMatches(NameValueCollection headers) - { - // Get a user agent string with common issues removed. - string userAgent = GetUserAgent(headers); - if (String.IsNullOrEmpty(userAgent) == false) - { - // Using the handler for this userAgent find the device. - return GetMatches(headers, GetHandlers(headers)); - } - return null; - } - - /// - /// Find all the devices that match the useragent string. - /// - /// Useragent string associated with the mobile device. - /// The closest matching device. - internal Matchers.Results GetMatches(string userAgent) - { - if (String.IsNullOrEmpty(userAgent) == false) - { - // Using the handler for this userAgent find the device. - return GetMatches(userAgent, GetHandlers(userAgent)); - } - return null; - } - - /// - /// Use the HttpRequest fields to determine devices that match. - /// - /// Collection of Http headers associated with the request. - /// Handlers capable of finding devices for the request. - /// The closest matching device or null if one can't be found. - private static Matchers.Results GetMatches(NameValueCollection headers, IEnumerable handlers) - { - Matchers.Results results = new Matchers.Results(); - - foreach (Handler handler in handlers) - { - // Find the closest matching devices. - Matchers.Results temp = handler.Match(headers); - // If some results have been found. - if (temp != null) - // Combine the results with results from previous - // handlers. - results.AddRange(temp); - } - - return results; - } - - /// - /// Use the HttpRequest fields to determine devices that match. - /// - /// The useragent string of the device being sought. - /// Handlers capable of finding devices for the request. - /// The closest matching device or null if one can't be found. - private static Matchers.Results GetMatches(string useragent, IEnumerable handlers) - { - Matchers.Results results = new Matchers.Results(); - - foreach (Handler handler in handlers) - { - // Find the closest matching devices. - Matchers.Results temp = handler.Match(useragent); - // If some results have been found. - if (temp != null) - // Combine the results with results from previous - // handlers. - results.AddRange(temp); - } - - return results; - } - - /// - /// Using the unique device id returns the device. Very quick return - /// when the device id is known. - /// - /// Unique internal ID of the device. - /// BaseDeviceInfo object. - public BaseDeviceInfo GetDeviceInfoByID(string deviceID) - { - List list; - if (AllDevices.TryGetValue(deviceID.GetHashCode(), out list)) - { - // If only 1 element return this one. - if (list.Count == 1) - return list[0]; - // Return the first matching element. -#if VER35 || VER4 - return list.Find(i => i.DeviceId == deviceID); -#else - foreach (BaseDeviceInfo device in list) - if (device.DeviceId == deviceID) - return device; -#endif - } - return null; - } - - /// - /// Gets an array of handlers that will support the useragent string. - /// - /// Useragent string associated with the HTTP request. - /// A list of all handlers that can handle this device. - public Handler[] GetHandlers(string userAgent) - { - byte highestConfidence = 0; - List handlers = new List(); -#if VER4 || VER35 - - foreach (Handler handler in Handlers.Where(handler => handler.CanHandle(userAgent))) - { - GetHandlers(ref highestConfidence, handlers, handler); - } -#else - foreach (Handler handler in Handlers) - { - if (handler.CanHandle(userAgent)) - GetHandlers(ref highestConfidence, handlers, handler); - } -#endif - return handlers.ToArray(); - } - - /// - /// Returns an array of handlers that will be supported by the request. - /// Is used when a request is available so that header fields other - /// than Useragent can also be used in matching. For example; the - /// Useragent Profile fields. - /// - /// Collection of Http headers associated with the request. - /// An array of handlers able to match the request. - private Handler[] GetHandlers(NameValueCollection headers) - { - byte highestConfidence = 0; - List handlers = new List(); -#if VER4 || VER35 - foreach (Handler handler in Handlers.Where(handler => handler.CanHandle(headers))) - { - GetHandlers(ref highestConfidence, handlers, handler); - } -#else - foreach (Handler handler in Handlers) - { - // If the handler can support the request and it's not the - // catch all handler add it to the list we'll use for matching. - if (handler.CanHandle(headers)) - GetHandlers(ref highestConfidence, handlers, handler); - } -#endif - return handlers.ToArray(); - } - - /// - /// Adds the handler to the list of handlers if the handler's confidence - /// is higher than or equal to the current highest handler confidence. - /// - /// Highest confidence value to far. - /// List of handlers. - /// Handler to be considered for adding. - /// The new highest confidence value. - private static void GetHandlers(ref byte highestConfidence, List handlers, Handler handler) - { - if (handler.Confidence > highestConfidence) - { - handlers.Clear(); - handlers.Add(handler); - highestConfidence = handler.Confidence; - } - else if (handler.Confidence == highestConfidence) - handlers.Add(handler); - } - - /// - /// Records the device in the indexes used by the API. If a device - /// with the same ID already exists the previous one is overwritten. - /// The device is also assigned to a handler based on the useragent, - /// and supported root devices of the handler. - /// - /// The new device being added. - internal virtual void Set(BaseDeviceInfo device) - { - // Reset the list of devices. - _actualDevices = null; - - // Does the device already exist? - lock (AllDevices) - { - int hashCode = device.DeviceId.GetHashCode(); - if (AllDevices.ContainsKey(hashCode)) - { - // Yes. Add this device to the list. - AllDevices[hashCode].Add(device); - } - else - { - // No. So add the new device. - AllDevices.Add(hashCode, new List(new BaseDeviceInfo[] { device })); - } - } - - // Add the new device to handlers that can support it. - if (String.IsNullOrEmpty(device.UserAgent) == false) - { -#if VER4 || VER35 - foreach (Handler handler in GetHandlers(device.UserAgent).Where(handler => handler != null)) - { - handler.Set(device); - } -#else - foreach (Handler handler in GetHandlers(device.UserAgent)) - if (handler != null) - handler.Set(device); -#endif - } - } - - /// - /// Used to check other header fields in case a transcoder is being used - /// and returns the true useragent string. - /// - /// Collection of Http headers associated with the request. - /// The useragent string to use for matching purposes. - internal static string GetUserAgent(NameValueCollection headers) - { - string userAgent = headers[Detection.Constants.UserAgentHeader]; -#if VER4 || VER35 - string transcodeUserAgent = - Detection.Constants.TranscoderUserAgentHeaders.FirstOrDefault(e => headers[e] != null); - if (transcodeUserAgent != null) - userAgent = transcodeUserAgent; -#else - foreach (string current in Detection.Constants.TranscoderUserAgentHeaders) - { - if (headers[current] != null) - { - userAgent = headers[current]; - break; - } - } -#endif - if (userAgent == null) - userAgent = string.Empty; - else - userAgent = userAgent.Trim(); - return userAgent; - } - - #endregion - } -} diff --git a/Foundation/Mobile/Detection/Binary/BinaryException.cs b/Foundation/Mobile/Detection/Binary/BinaryException.cs deleted file mode 100644 index bdcbd33..0000000 --- a/Foundation/Mobile/Detection/Binary/BinaryException.cs +++ /dev/null @@ -1,25 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile.Detection.Binary -{ - /// - /// Thrown by the binary format detection classes. - /// - public class BinaryException : MobileException - { - /// - /// Constructs a new instance of . - /// - /// - internal BinaryException(string message) : base(message) { } - } -} diff --git a/Foundation/Mobile/Detection/Binary/DeviceInfo.cs b/Foundation/Mobile/Detection/Binary/DeviceInfo.cs deleted file mode 100644 index ba7e494..0000000 --- a/Foundation/Mobile/Detection/Binary/DeviceInfo.cs +++ /dev/null @@ -1,57 +0,0 @@ -/* ********************************************************************* - * 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 System; - -namespace FiftyOne.Foundation.Mobile.Detection.Binary -{ - /// - /// Device info for the binary data type where the parent information - /// is held as a direct reference and not as a fallback device id. - /// - public class DeviceInfo : BaseDeviceInfo - { - #region Constructor - - /// - /// Constructs a new instance of the device information. Device and useragent are provided - /// uses indexes in the providers strings collection. - /// - /// The provider the device will be assigned to. - /// The unique device name. - /// The string index of the user agent string. - /// The parent device, or null if no parent. - internal DeviceInfo(Provider provider, string uniqueDeviceID, int userAgentStringIndex, DeviceInfo parent) : - base(provider, - uniqueDeviceID, - userAgentStringIndex >= 0 ? provider.Strings.Get(userAgentStringIndex) : String.Empty, - parent) - { - } - - /// - /// Constructs a new instance of the device information. Device and useragent are provided - /// uses indexes in the providers strings collection. - /// - /// The provider the device will be assigned to. - /// The unique device name. - /// The parent device, or null if no parent. - internal DeviceInfo(Provider provider, string uniqueDeviceID, DeviceInfo parent) : - base(provider, - uniqueDeviceID, - String.Empty, - parent) - { - } - - #endregion - } -} diff --git a/Foundation/Mobile/Detection/Binary/HandlerTypes.cs b/Foundation/Mobile/Detection/Binary/HandlerTypes.cs deleted file mode 100644 index 9d51ee2..0000000 --- a/Foundation/Mobile/Detection/Binary/HandlerTypes.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile.Detection.Binary -{ - /// - /// An enumeration of the different handler types available. - /// - public enum HandlerTypes - { - /// - /// The edit distance handler. - /// - EditDistance = 1, - - /// - /// The regular expression handler. - /// - RegexSegment = 2, - - /// - /// The reduced initial string handler. - /// - ReducedInitialString = 3 - } -} diff --git a/Foundation/Mobile/Detection/Binary/Reader.cs b/Foundation/Mobile/Detection/Binary/Reader.cs deleted file mode 100644 index 02e134c..0000000 --- a/Foundation/Mobile/Detection/Binary/Reader.cs +++ /dev/null @@ -1,501 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Text; -using FiftyOne.Foundation.Mobile.Detection.Handlers; - -namespace FiftyOne.Foundation.Mobile.Detection.Binary -{ - /// - /// Used to read device data into the detection provider. - /// - public class Reader - { - #region Static Public Methods - - /// - /// Creates a new provider from the binary file supplied. - /// - /// Binary file to use to create the provider. - /// A new provider initialised with data from the file provided. - public static Provider Create(string file) - { - FileInfo fileInfo = new FileInfo(file); - if (fileInfo.Exists) - { - using (FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Create(stream); - } - } - return null; - } - - /// - /// Creates a new provider from the binary data array supplied. - /// - /// Binary data array supplied. - /// A new provider initialised with data from the stream provided. - public static Provider Create(byte[] data) - { - using (MemoryStream ms = new MemoryStream(data)) - return Create(ms); - } - - /// - /// Creates a new provider from the binary stream supplied. - /// - /// Binary stream to use to create the provider. - /// A new provider initialised with data from the stream provided. - public static Provider Create(Stream stream) - { - Provider provider = new Provider(); - using (BinaryReader reader = new BinaryReader(new GZipStream(stream, CompressionMode.Decompress))) - { - Add(provider, reader); - } - return provider; - } - - #endregion - - #region Static Private Methods - - /// - /// Adds the data from the binary reader to the provider. - /// - /// The provider to have data added to/ - /// Reader connected to the input stream. - private static void Add(Provider provider, BinaryReader reader) - { - // Read and ignore the copyright notice. This is ignored. - string copyright = reader.ReadString(); - - // Ignore any additional information at the moment. - reader.ReadString(); - - // Check the versions are correct. - Version streamFormat = ReadVersion(reader); - if ((streamFormat.Major == BinaryConstants.FormatVersion.Major && - streamFormat.Minor == BinaryConstants.FormatVersion.Minor) == false) - throw new BinaryException(String.Format( - "The data provided is not supported by this version of Foundation. " + - "The version provided is '{0}' and the version expected is '{1}'.", - streamFormat, - BinaryConstants.FormatVersion)); - - // Load the data now that validation is completed. - ReadStrings(reader, provider.Strings); - ReadHandlers(reader, provider); - ReadDevices(reader, provider, null); - ReadPublishedDate(reader, provider); - ReadManifest(reader, provider); - ReadDataSetName(reader, provider); - ReadComponents(reader, provider); - } - - /// - /// Reads details about the components and properties updating - /// the properties loaded earlier in the file. - /// - /// BinaryReader of the input stream. - /// The provider the device will be added to. - private static void ReadComponents(BinaryReader reader, Provider provider) - { - try - { - int count = reader.ReadInt32(); - for (int i = 0; i < count; i++) - { - // Get the names of the property and component. - int propertyIndex = reader.ReadInt32(); - int componentIndex = reader.ReadInt32(); - - // If the property and component names are valid then - // find the property object and set the component name. - if (propertyIndex >= 0 && - componentIndex >= 0) - { - // Find the propety and update it's component. - Property property = null; - if (provider.Properties.TryGetValue(propertyIndex, out property)) - { - Provider.Components component = Provider.Components.Unknown; - switch (provider.Strings.Get(componentIndex)) - { - case "HardwarePlatform": component = Provider.Components.Hardware; break; - case "SoftwarePlatform": component = Provider.Components.Software; break; - case "BrowserUA": component = Provider.Components.Browser; break; - case "Crawler": component = Provider.Components.Crawler; break; - } - property.SetComponent(component); - } - } - } - } - catch (EndOfStreamException) - { - // Nothing we can do as data is not included. - EventLog.Debug("EndOfStreamException reading components."); - - // Set the properties components to hard coded values. - provider.SetDefaultComponents(); - } - } - - /// - /// Reads the devices and any children. - /// - /// BinaryReader of the input stream. - /// The provider the device will be added to. - /// The parent of the device, or null if a root device. - private static void ReadDevices(BinaryReader reader, Provider provider, DeviceInfo parent) - { - short count = reader.ReadInt16(); - for (short i = 0; i < count; i++) - { - // Get the device id string. - int uniqueDeviceIDStringIndex = reader.ReadInt32(); - string uniqueDeviceID = - uniqueDeviceIDStringIndex >= 0 ? - provider.Strings.Get(uniqueDeviceIDStringIndex) : - String.Empty; - - DeviceInfo device; - - // Get the number of useragents available for the device. - short userAgentCount = reader.ReadInt16(); - - if (userAgentCount > 0) - { - // Read the 1st one, if one is present to assign to the master device. - device = new DeviceInfo( - provider, - uniqueDeviceID, - reader.ReadInt32(), - parent); - - // Add the device to the handlers. - foreach (short index in ReadDeviceHandlers(reader)) - provider.Handlers[index].Set(device); - - // Reduce the number of useragents by 1 because we've read - // the 1st one. - userAgentCount--; - } - else - { - // Create the device and don't assign any useragents. - device = new DeviceInfo( - provider, - uniqueDeviceID, - parent); - } - - // Create new devices as children of this one to hold the - // remaining user agent strings. - for (int u = 0; u < userAgentCount; u++) - { - // Get the user agent string index and create a new - // device. - DeviceInfo uaDevice = new DeviceInfo( - provider, - uniqueDeviceID, - reader.ReadInt32(), - device); - - // Add the device to the handlers. - foreach (short index in ReadDeviceHandlers(reader)) - provider.Handlers[index].Set(uaDevice); - } - - // Add the device to the list of all devices. - int hashCode = device.DeviceId.GetHashCode(); - if (provider.AllDevices.ContainsKey(hashCode)) - { - // Yes. Add this device to the list. - provider.AllDevices[hashCode].Add(device); - } - else - { - // No. So add the new device. - provider.AllDevices.Add(hashCode, new List(new BaseDeviceInfo[] { device })); - } - - // Get the remaining properties and values to the device. - ReadCollection(reader, device.Properties); - - // Read the child devices. - ReadDevices(reader, provider, device); - } - } - - /// - /// Reads all the handler indexes that support this device. - /// - /// - /// - private static List ReadDeviceHandlers(BinaryReader reader) - { - List indexes = new List(); - short count = reader.ReadInt16(); - for (int i = 0; i < count; i++) - indexes.Add(reader.ReadInt16()); - return indexes; - } - - /// - /// Reads the handler from the binary reader. - /// - /// - /// - private static void ReadHandlers(BinaryReader reader, Provider provider) - { - int count = reader.ReadInt32(); - for (int i = 0; i < count; i++) - { - Handler handler = CreateHandler(reader, provider); - ReadHandlerRegexes(reader, handler.CanHandleRegex); - ReadHandlerRegexes(reader, handler.CantHandleRegex); - provider.Handlers.Add(handler); - } - } - - /// - /// Reads the regular expressions used to determine if the user agent can be handled - /// by the handler. - /// - /// - /// - private static void ReadHandlerRegexes(BinaryReader reader, List list) - { - int count = reader.ReadInt16(); - for (int i = 0; i < count; i++) - { - string pattern = reader.ReadString(); - HandleRegex regex = new HandleRegex(pattern); - ReadHandlerRegexes(reader, regex.Children); - list.Add(regex); - } - } - - /// - /// Reads a collection of properties. - /// - /// - /// - private static void ReadCollection(BinaryReader reader, Collection properties) - { - // Read the number of properties. - short propertiesCount = reader.ReadInt16(); - for (int p = 0; p < propertiesCount; p++) - { - // Get the index of the properties string. - int propertyNameStringIndex = reader.ReadInt32(); - - // Read the number of values. - byte valuesCount = reader.ReadByte(); - - // Read all the values. - List values = new List(); - for (int v = 0; v < valuesCount; v++) - values.Add(reader.ReadInt32()); - - // Add the property and values. - properties.Add(propertyNameStringIndex, values); - } - } - - /// - /// Creates the handler for the current provider. - /// - /// Data source being processed. - /// Provider the new handler should be assigned to. - /// An instance of the new handler. - private static Handler CreateHandler(BinaryReader reader, Provider provider) - { - HandlerTypes type = (HandlerTypes)reader.ReadByte(); - byte confidence = reader.ReadByte(); - string name = reader.ReadString(); - bool checkUAProfs = reader.ReadBoolean(); - string defaultDeviceId = String.Empty; - - switch (type) - { - case HandlerTypes.EditDistance: - return new Handlers.EditDistanceHandler( - provider, name, defaultDeviceId, confidence, checkUAProfs); - case HandlerTypes.ReducedInitialString: - return new Handlers.ReducedInitialStringHandler( - provider, name, defaultDeviceId, confidence, checkUAProfs, reader.ReadString()); - case HandlerTypes.RegexSegment: - Handlers.RegexSegmentHandler handler = new Handlers.RegexSegmentHandler( - provider, name, defaultDeviceId, confidence, checkUAProfs); - ReadRegexSegmentHandler(reader, handler); - return handler; - } - - throw new BinaryException(String.Format("Type '{0}' is not a recognised handler.", type)); - } - - /// - /// Reads the regular expressions and weights that form the handler. - /// - /// Data source being processed. - /// Handler being created. - private static void ReadRegexSegmentHandler(BinaryReader reader, RegexSegmentHandler handler) - { - int count = reader.ReadInt16(); - for (int i = 0; i < count; i++) - { - handler.Segments.Add(new RegexSegmentHandler.RegexSegment( - reader.ReadString(), reader.ReadInt32())); - } - } - - /// - /// Reads the initial number of strings into the strings collection. - /// - /// Data source being processed. - /// Strings instance to be added to. - private static void ReadStrings(BinaryReader reader, Strings strings) - { - int count = reader.ReadInt32(); - for (int i = 0; i < count; i++) - { - short length = reader.ReadInt16(); - byte[] value = reader.ReadBytes(length); - strings.Add(Encoding.Unicode.GetString( - Encoding.Convert(Encoding.ASCII, Encoding.Unicode, value))); - } - } - - /// - /// Returns the version number from the stream. The version number represents - /// the data format used in the file. - /// - /// Reader connected to an input stream. - /// The version number read from the stream. - private static Version ReadVersion(BinaryReader reader) - { - return new Version( - reader.ReadInt32(), - reader.ReadInt32()); - } - - /// - /// Reads the name of the data set. - /// - /// Data source being processed. - /// Provider the new handler should be assigned to. - private static void ReadDataSetName(BinaryReader reader, Provider provider) - { - try - { - provider._dataSetName = ReadString(reader); - } - catch (EndOfStreamException) - { - // Nothing we can do as data is not included. - EventLog.Debug("EndOfStreamException reading data set name."); - provider._dataSetName = "Unknown"; - } - } - - /// - /// Reads the date and time the file was published. - /// - /// Data source being processed. - /// Provider the new handler should be assigned to. - private static void ReadPublishedDate(BinaryReader reader, Provider provider) - { - try - { - provider._publishedDate = new DateTime(reader.ReadInt64()); - } - catch (EndOfStreamException) - { - // Nothing we can do as data is not included. - EventLog.Debug("EndOfStreamException reading published date."); - provider._publishedDate = DateTime.MinValue; - } - } - - /// - /// Adds manifest information to the provider if the data file includes it. - /// - /// Data source being processed. - /// Provider the new handler should be assigned to. - private static void ReadManifest(BinaryReader reader, Provider provider) - { - // Ensure any old properties are removed. - provider.Properties.Clear(); - - try - { - int countOfProperties = reader.ReadInt32(); - for (int p = 0; p < countOfProperties; p++) - { - // Create the property. - Property property = new Property( - provider, - provider.Strings.Get(reader.ReadInt32()), - ReadString(reader), - ReadString(reader), - reader.ReadBoolean(), - reader.ReadBoolean(), - reader.ReadBoolean()); - - // Add the values to the list. - int countOfValues = reader.ReadInt32(); - for (int v = 0; v < countOfValues; v++) - { - Value value = new Value( - property, - provider.Strings.Get(reader.ReadInt32()), - ReadString(reader), - ReadString(reader)); - property.Values.Add(value); - } - - // Finally add the property to the list of properties. - provider.Properties.Add(property.NameStringIndex, property); - } - } - catch (EndOfStreamException) - { - // Nothing we can do. Clear the data. - EventLog.Debug("EndOfStreamException reading manifest."); - provider.Properties.Clear(); - } - } - - /// - /// Checks for a boolean value to indicate if the string is present. - /// If it is present then read the string and return it. - /// - /// - /// - private static string ReadString(BinaryReader reader) - { - bool isPresent = reader.ReadBoolean(); - if (isPresent) - return reader.ReadString(); - return null; - } - - #endregion - } -} diff --git a/Foundation/Mobile/Detection/Binary/Resources/51Degrees.mobi-Lite.dat b/Foundation/Mobile/Detection/Binary/Resources/51Degrees.mobi-Lite.dat deleted file mode 100644 index 993b46f..0000000 Binary files a/Foundation/Mobile/Detection/Binary/Resources/51Degrees.mobi-Lite.dat and /dev/null differ diff --git a/Foundation/Mobile/Detection/Collection.cs b/Foundation/Mobile/Detection/Collection.cs deleted file mode 100644 index 911fc76..0000000 --- a/Foundation/Mobile/Detection/Collection.cs +++ /dev/null @@ -1,103 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Collections.Generic; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// A collection of string indexes. - /// - internal class Collection : Dictionary> - { - #region Fields - - private readonly Strings _strings; - - #endregion - - #region Constructor - - internal Collection(Strings strings) : base() - { - _strings = strings; - } - - #endregion - - #region Methods - - /// - /// Sets the capabilityName and Value in the collection. - /// - /// Name of the capability being set. - /// Values of the capability being set. - internal void Set(string capabilityName, string[] values) - { - int capabilityNameIndex = _strings.Add(capabilityName); - if (capabilityNameIndex >= 0) - { - List stringIndexes = new List(); - foreach (string value in values) - { - stringIndexes.Add(_strings.Add(value)); - } - Set(capabilityNameIndex, stringIndexes); - } - } - - /// - /// Sets the capabilityName and Value in the collection. - /// - /// String index of the capability being set. - /// Value of the capability being set. - internal void Set(int capabilityNameIndex, List values) - { - lock (this) - { - // Does this capability already exist in the list? - if (ContainsKey(capabilityNameIndex) == false) - { - // No. Create a new value and add it to the list. - base.Add(capabilityNameIndex, values); - } - else - { - // Yes. Replace it's value with the current one. - List list = base[capabilityNameIndex]; - foreach(int value in values) - if (list.Contains(value) == false) - list.Add(value); - } - } - } - - /// - /// Checks the other Collection object instance contains identical keys and values - /// as this one. - /// - /// Other Collection object. - /// True if the object instances contain the same values. - internal bool Equals(Collection other) - { - foreach(int key in Keys) - if (other[key] != this[key]) - return false; - return true; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Configuration/DetectionSection.cs b/Foundation/Mobile/Detection/Configuration/DetectionSection.cs deleted file mode 100644 index c2ca9f2..0000000 --- a/Foundation/Mobile/Detection/Configuration/DetectionSection.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Configuration -{ - /// - /// Configures the detection section. This class cannot be inherited. - /// - internal sealed class DetectionSection : ConfigurationSection - { - #region Properties - - /// - /// Gets the collection of xml files to be processed. - /// - [ConfigurationProperty("xmlFiles", IsRequired = false)] - internal FilesCollection XmlFiles - { - get { return (FilesCollection)this["xmlFiles"]; } - } - - /// - /// Gets or sets the path to access the binary file. - /// - [ConfigurationProperty("binaryFilePath", IsRequired = false)] - [StringValidator(InvalidCharacters = "!@#$%^&*()[]{};'\"|", MaxLength = 255)] - internal string BinaryFilePath - { - get { return (string)this["binaryFilePath"]; } - set { this["binaryFilePath"] = value; } - } - - /// - /// Real usage information provides 51Degrees.mobi insight to improve this products - /// performance and identify new or less popular devices quickly. It is amalgamated - /// with other data sources to bring you this solution. We ask you to leave this - /// property set to true. - /// - [ConfigurationProperty("shareUsage", IsRequired = false, DefaultValue = "true")] - internal bool ShareUsage - { - get { return (bool)this["shareUsage"]; } - set { this["shareUsage"] = value; } - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Configuration/FileConfigElement.cs b/Foundation/Mobile/Detection/Configuration/FileConfigElement.cs deleted file mode 100644 index e02016d..0000000 --- a/Foundation/Mobile/Detection/Configuration/FileConfigElement.cs +++ /dev/null @@ -1,64 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Configuration -{ - /// - /// Defines configuration settings for data files. This class cannot be inherited. - /// - internal sealed class FileConfigElement : ConfigurationElement - { - #region Properties - - // Note: The default value is set for required unique properties to prevent - // .NET throwing an exception when validating the default value. - - /// - /// Gets or sets the name of the file. - /// - [ConfigurationProperty("name", IsRequired = true, IsKey = true, DefaultValue="name")] - [StringValidator(InvalidCharacters = "!@#$%^&*()[]{};'\"|", MinLength = 1, MaxLength = 60)] - internal string Name - { - get { return (string) this["name"]; } - set { this["name"] = value; } - } - - /// - /// Gets or sets the file path. - /// - [ConfigurationProperty("filePath", IsRequired = true, DefaultValue="filePath")] - [StringValidator(InvalidCharacters = "!@#$%^&*()[]{};'\"|", MinLength = 1, MaxLength = 255)] - internal string FilePath - { - get { return (string) this["filePath"]; } - set { this["filePath"] = value; } - } - - /// - /// Gets or sets a value indicating whether this file patch should be used. - /// - [ConfigurationProperty("enabled", IsRequired = false, DefaultValue = true)] - internal bool Enabled - { - get { return (bool) this["enabled"]; } - set { this["enabled"] = value; } - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Configuration/FilesCollection.cs b/Foundation/Mobile/Detection/Configuration/FilesCollection.cs deleted file mode 100644 index ef33b13..0000000 --- a/Foundation/Mobile/Detection/Configuration/FilesCollection.cs +++ /dev/null @@ -1,157 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Configuration -{ - /// - /// A collection of . This class cannot be inherited. - /// - internal sealed class FilesCollection : ConfigurationElementCollection - { - #region Methods - - /// - /// Creates a new instance of . - /// - protected override ConfigurationElement CreateNewElement() - { - return new FileConfigElement(); - } - - /// - /// Gets the element key value. - /// - protected override Object GetElementKey(ConfigurationElement element) - { - return ((FileConfigElement)element).Name; - } - - /// - /// Add element to the base collection. - /// - protected override void BaseAdd(ConfigurationElement element) - { - BaseAdd(element, false); - } - - /// - /// Gets the index of the specific element inside the collection. - /// - /// The file element being sought. - /// The index of the element. - /// Thrown if equals null. - internal int IndexOf(FileConfigElement file) - { - if (file == null) - throw new ArgumentNullException("file"); - - return BaseIndexOf(file); - } - - /// - /// Add element into the collection. - /// - /// The file to be added to the collection. - /// Thrown if equals null. - internal void Add(FileConfigElement file) - { - if (file == null) - throw new ArgumentNullException("file"); - - BaseAdd(file); - } - - /// - /// Removes a from the collection. - /// - /// The xml file to be removed from the collection. - /// Thrown if equals null. - internal void Remove(FileConfigElement file) - { - if (file == null) - throw new ArgumentNullException("file"); - - if (BaseIndexOf(file) >= 0) - BaseRemove(file.Name); - } - - /// - /// Removes a at the specified index location. - /// - /// The index of the patch to remove from the collection. - /// Thrown if is less than zero or bigger than the number of indexes on the collections. - internal void RemoveAt(int index) - { - if ((index < 0) || (index > base.Count - 1)) - throw new ArgumentOutOfRangeException("index"); - - BaseRemoveAt(index); - } - - /// - /// Removes a from the collection. - /// - /// The name of the patch to remove from the collection. - /// Thrown if equals null. - internal void Remove(string name) - { - if (string.IsNullOrEmpty(name)) - throw new ArgumentNullException("name"); - - BaseRemove(name); - } - - /// - /// Removes all configuration elements from the collection. - /// - internal void Clear() - { - BaseClear(); - } - - #endregion - - #region Properties - - /// - /// Gets or sets the . - /// - internal FileConfigElement this[int index] - { - get { return (FileConfigElement)BaseGet(index); } - set - { - if (BaseGet(index) != null) - { - BaseRemoveAt(index); - } - BaseAdd(index, value); - } - } - - /// - /// Gets or sets the . - /// - internal new FileConfigElement this[string name] - { - get { return (FileConfigElement)BaseGet(name); } - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Configuration/Manager.cs b/Foundation/Mobile/Detection/Configuration/Manager.cs deleted file mode 100644 index 59109d6..0000000 --- a/Foundation/Mobile/Detection/Configuration/Manager.cs +++ /dev/null @@ -1,152 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Configuration; -using FiftyOne.Foundation.Mobile.Configuration; - -#if VER4 || VER35 - -using System.Linq; - -#else - -using System.Collections.Generic; - -#endif - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Configuration -{ - /// - /// Returns all the settings from the Web.Config for this component. - /// - internal static class Manager - { - #region Fields - - private static DetectionSection _configurationSection; - - #endregion - - #region Constructors - - static Manager() - { - _configurationSection = Support.GetWebApplicationSection("fiftyOne/detection", false) as DetectionSection; - } - - #endregion - - #region Properties - - /// - /// Returns true or false depending on whether usage information - /// should be shared with 51Degrees.mobi. - /// - internal static bool ShareUsage - { - get - { - if (_configurationSection == null) - return true; - return _configurationSection.ShareUsage; - } - set - { - SetShareUsage(value); - } - } - - /// - /// Sets the shared usage value. - /// - /// - private static void SetShareUsage(bool value) - { - DetectionSection element = GetDetectionElement(); - element.ShareUsage = value; - Support.SetWebApplicationSection(element); - Refresh(); - } - - /// - /// Gets the detection element from a configuration source. - /// - /// - private static DetectionSection GetDetectionElement() - { - System.Configuration.Configuration configuration = Support.GetConfigurationContainingSectionGroupName("fiftyOne/detection"); - - if (configuration == null) - return null; - - return configuration.GetSection("fiftyOne/detection") as DetectionSection; - } - - /// - /// Returns the path to the binary file if provided. - /// - internal static string BinaryFilePath - { - get - { - if (_configurationSection == null) - return null; - return Mobile.Configuration.Support.GetFilePath(_configurationSection.BinaryFilePath); - } - } - - /// - /// Gets a list containing the path of the xml files to be applied. - /// - internal static string[] XmlFiles - { - get - { - if (_configurationSection == null) - return null; -#if VER4 || VER35 - return (from FileConfigElement patch in _configurationSection.XmlFiles - where patch.Enabled - select Mobile.Configuration.Support.GetFilePath(patch.FilePath)).ToArray(); -#else - List patchFiles = new List(); - foreach (FileConfigElement patch in _configurationSection.XmlFiles) - if (patch.Enabled) - patchFiles.Add(Support.GetFilePath(patch.FilePath)); - return patchFiles.ToArray(); -#endif - } - } - - #endregion - - #region Methods - - /// - /// Creates a new configuration instance checking for - /// fresh data. - /// - internal static void Refresh() - { - // Ensure the managers detection section is refreshed in case the - // process is not going to restart as a result of the change. - ConfigurationManager.RefreshSection("fiftyOne/detection"); - - _configurationSection = Support.GetWebApplicationSection("fiftyOne/detection", false) as DetectionSection; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/DetectorModule.cs b/Foundation/Mobile/Detection/DetectorModule.cs deleted file mode 100644 index 7992c1a..0000000 --- a/Foundation/Mobile/Detection/DetectorModule.cs +++ /dev/null @@ -1,354 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Security; -using System.Text; -using System.Web; -using System.Web.Configuration; -using System.Web.UI; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Module used to enhance mobile browser information and detect and redirect - /// mobile devices accessing non-mobile web pages. - /// - public class DetectorModule : Redirection.RedirectModule - { - #region Fields - - /// - /// Used to lock the initialisation of static fields. - /// - private static readonly object _lock = new object(); - - #if !VER4 - - /// - /// Indicates if static initialisation has been completed. - /// - private static bool _initialised = false; - - /// - /// Collection of client targets used by the application with the key - /// field representing the alias and the value the useragent. - /// - private static SortedList _clientTargets; - - #endif - - #endregion - - #region Initialisers - - /// - /// Initialises the device detection module. - /// - /// HttpApplication object for the web application. - public override void Init(HttpApplication application) - { - Initialise(application); - base.Init(application); - } - - /// - /// Initiliases the HttpModule registering this modules interest in - /// all new requests and handler mappings. - /// - /// HttpApplication object for the web application. - protected void Initialise(HttpApplication application) - { -#if VER4 - // Replace the .NET v4 BrowserCapabilitiesProvider if it's not ours. - if (HttpCapabilitiesBase.BrowserCapabilitiesProvider is MobileCapabilitiesProvider == false) - { - lock (_lock) - { - if (HttpCapabilitiesBase.BrowserCapabilitiesProvider is MobileCapabilitiesProvider == false) - { - // Use the existing provider as the parent if it's not null. - if (HttpCapabilitiesBase.BrowserCapabilitiesProvider != null) - HttpCapabilitiesBase.BrowserCapabilitiesProvider = - new MobileCapabilitiesProvider((HttpCapabilitiesDefaultProvider)HttpCapabilitiesBase.BrowserCapabilitiesProvider); - else - HttpCapabilitiesBase.BrowserCapabilitiesProvider = - new MobileCapabilitiesProvider(); - } - } - } - - // The new BrowserCapabilitiesProvider functionality in .NET v4 negates the need to - // override browser properties in the following way. The rest of the module is redundent - // in .NET v4. -#else - EventLog.Debug("Initialising Detector Module"); - - StaticFieldInit(); - - // Intercept the beginning of the request to override the capabilities. - application.BeginRequest += OnBeginRequest; - - // Check for a MobilePage handler being used. - application.PreRequestHandlerExecute += SetPreferredRenderingType; - - // If client targets are specified then check to see if one is being used - // and override the requesting device information. - if (_clientTargets != null) - application.PreRequestHandlerExecute += SetPagePreIntClientTargets; -#endif - } - -#if !VER4 - - /// - /// Initialises the static fields. - /// - private static void StaticFieldInit() - { - if (_initialised == false) - { - lock (_lock) - { - if (_initialised == false) - { - // Get a list of the client target names. - _clientTargets = GetClientTargets(); - - // Indicate initialisation is complete. - _initialised = true; - } - } - } - } - -#endif - - #endregion - -#if !VER4 - - #region Events - - - /// - /// If the handler is a MobilePage then ensure a compaitable textwriter will be used. - /// - /// HttpApplication related to the request. - /// EventArgs related to the event. Not used. - private static void SetPreferredRenderingType(object sender, EventArgs e) - { - if (sender is HttpApplication) - { - HttpContext context = ((HttpApplication)sender).Context; - - // Check to see if the handler is a mobile page. If so then the preferred markup - // needs to change as the legacy mobile controls do not work with html4 specified. - // If these lines are removed a "No mobile controls device configuration was registered - // for the requesting device" exception is likely to occur. - if (context.Handler != null && - IsMobileType(context.Handler.GetType()) && - "html4".Equals(context.Request.Browser.PreferredRenderingType, - StringComparison.InvariantCultureIgnoreCase)) - { - context.Request.Browser.Capabilities["preferredRenderingType"] = "html32"; - } - } - } - - /// - /// Ensures the PreInit event of the page is processed by the module - /// to override capabilities associated with a client target specification. - /// - /// HttpApplication related to the request. - /// EventArgs related to the event. Not used. - private void SetPagePreIntClientTargets(object sender, EventArgs e) - { - if (sender is HttpApplication) - { - HttpContext context = ((HttpApplication)sender).Context; - - // If this handler relates to a page use the preinit event of the page - // to set the capabilities providing time for the page to set the - // clienttarget property if required. - if (context != null && - context.Handler is Page) - ((Page)context.Handler).PreInit += OnPreInitPage; - } - } - - /// - /// Override the capabilities assigned to the request. - /// - /// HttpApplication related to the request. - /// EventArgs related to the event. Not used. - private void OnBeginRequest(object sender, EventArgs e) - { - if (sender is HttpApplication) - { - HttpContext context = ((HttpApplication)sender).Context; - if (context != null) - { - try - { - // Override the capabilities incase the developers page needs them in the - // preinit event of the page. - OverrideCapabilities(context); - } - - // Some issues of null exceptions have been reported and this is temporary code to trap - // them recording headers to help further diagnosis. - catch (NullReferenceException ex) - { - StringBuilder builder = new StringBuilder("A Null Exception occured which has the following header info:"); - foreach (string key in context.Request.Headers.Keys) - builder.Append(Environment.NewLine).Append(key).Append("=").Append( - context.Request.Headers[key]); - - // Create new exception with the additional information and record to the log file. - EventLog.Fatal(new MobileException(builder.ToString(), ex)); - } - } - } - } - - /// - /// Before the page initialises make sure the latest browser capabilities - /// are available if a client target has been specified. - /// - /// Page associated with the request. - /// Event arguements. - private void OnPreInitPage(object sender, EventArgs e) - { - Page page = sender as Page; - - // Check to see if a client target has been specified and if it has - // use the associated useragent string to assign the capabilities. - string userAgent = null; - if (page != null && _clientTargets.TryGetValue(page.ClientTarget, out userAgent)) - OverrideCapabilities(page.Request, userAgent); - } - - #endregion - - #region Static Methods - - /// - /// Gets the client target section from the configuration if the security level - /// allows this method to be used. Will fail in medium trust environments. - /// - /// - private static ClientTargetSection GetClientTargetsSection() - { - return WebConfigurationManager.GetWebApplicationSection( - "system.web/clientTarget") as ClientTargetSection; - } - - /// - /// Gets a list of the client target names configured for the application. Will return null - /// if either target names are not defined or unrestricted security access is not available. - /// - /// A list of client target names. - private static SortedList GetClientTargets() - { - try - { - ClientTargetSection targets = GetClientTargetsSection(); - if (targets != null) - { - // Client targets have been defined so set the sorted list to include - // these details. - SortedList clientNames = new SortedList(); - for (int index = 0; index < targets.ClientTargets.Count; index++) - { - clientNames.Add( - targets.ClientTargets[index].Alias, - targets.ClientTargets[index].UserAgent); - } - return clientNames; - } - } - catch (SecurityException) - { - // There is nothing we can do so return null. - return null; - } - return null; - } - - /// - /// Adds the capabilities provided into the existing dictionary of capabilities - /// already assigned by Microsoft. - /// - /// - /// - protected static HttpBrowserCapabilities AddNewCapabilities(HttpBrowserCapabilities currentCapabilities, IDictionary overrideCapabilities) - { - // We can't do anything with null capabilities. Return the current ones. - if (overrideCapabilities == null) - return currentCapabilities; - - // Use our own capabilities object. - return new FiftyOneBrowserCapabilities(currentCapabilities, overrideCapabilities); - } - - #endregion - - #region Virtual Methods - - /// - /// If this device is not already using our mobile capabilities - /// then check to see if it's a mobile. If we think it's a mobile - /// or .NET thinks it's not the same type of device then override - /// the current capabilities. - /// - /// to be tested and overridden. - protected virtual void OverrideCapabilities(HttpContext context) - { - context.Request.Browser = AddNewCapabilities(context.Request.Browser, - Factory.Create(context.Request, context.Request.Browser.Capabilities)); - } - - /// - /// Adds new capabilities for the useragent provided rather than the request details - /// provided in the request paramters. - /// - /// The request who's capabilities collection should be updated. - /// The useragent string of the device requiring capabilities to be added. - protected virtual void OverrideCapabilities(HttpRequest request, string userAgent) - { - request.Browser = AddNewCapabilities(request.Browser, Factory.Create(userAgent)); - } - - #endregion - -#endif - - #region Methods - - /// - /// Records the module being disposed if debug enabled. - /// - public override void Dispose() - { - base.Dispose(); - EventLog.Debug("Disposing Detector Module"); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Factory.cs b/Foundation/Mobile/Detection/Factory.cs deleted file mode 100644 index 4a4197d..0000000 --- a/Foundation/Mobile/Detection/Factory.cs +++ /dev/null @@ -1,264 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections; -using System.Collections.Specialized; -using System.IO; -using System.Threading; -using System.Web; -using FiftyOne.Foundation.Mobile.Detection.Configuration; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Used to create the Capabilities collection based on the input like user agent string. - /// - public static class Factory - { - #region Fields - - /// - /// Cache for mobile capabilities. Items are removed approx. 60 minutes after the last - /// time they were used. - /// - private static readonly Cache _cache = new Cache(60); - - /// - /// Lock used when - /// - private static readonly object _lock = new object(); - - /// - /// Used to obtain the mobile capabilities for the request or user agent string - /// from the device data source provided. - /// - private static MobileCapabilities _instance; - - /// - /// The background timer used to update device data. - /// - private static Timer _autoUpdateDownloadTimer = null; - - private static Timer _autoUpdateFileTimer = null; - - #endregion - - #region Private Properties - - /// - /// Returns a single instance of the MobileCapabilities class used to provide - /// capabilities to enhance the request. - /// - private static MobileCapabilities Instance - { - get - { - if (_instance == null) - { - lock (_lock) - { - if (_instance == null) - { - ForceDataUpdate(); - - if (LicenceKey.Keys.Length > 0) - { - // Start the auto update thread to check for new data files. - _autoUpdateDownloadTimer = new Timer( - new TimerCallback(AutoUpdate.CheckForUpdate), - null, - Constants.AutoUpdateDelayedStart, - Constants.AutoUpdateSleep); - } - - // start a thread that will check if a newer data file on disk is available. - _autoUpdateFileTimer = new Timer( - new TimerCallback(AutoUpdate.CheckForNewFile), - null, - Constants.FileUpdateDelayedStart, - Constants.FileUpdateSleep); - } - } - } - return _instance; - } - } - - #endregion - - #region Public Properties - - /// - /// Returns the instance being - /// used by the factory. - /// - public static Provider ActiveProvider - { - get { return Instance.Provider; } - } - - /// - /// Forces the factory to update current ActiveProvider with new data. - /// - public static void ForceDataUpdate() - { - Provider provider = null; - try - { - // Does a binary file exist? - if (Manager.BinaryFilePath != null && - File.Exists(Manager.BinaryFilePath)) - { - EventLog.Info(String.Format("Creating provider from binary data file '{0}'.", - Manager.BinaryFilePath)); - provider = Binary.Reader.Create(Manager.BinaryFilePath); - EventLog.Info(String.Format("Created provider from binary data file '{0}'.", - Manager.BinaryFilePath)); - } - - // Do XML files exist? - if (Manager.XmlFiles != null && - Manager.XmlFiles.Length > 0) - { - if (provider == null) - { - EventLog.Info(String.Format("Creating provider from XML data files '{0}'.", - String.Join(", ", Manager.XmlFiles))); - provider = Xml.Reader.Create(Manager.XmlFiles); - EventLog.Info(String.Format("Created provider from XML data files '{0}'.", - String.Join(", ", Manager.XmlFiles))); - } - else - { - EventLog.Info(String.Format("Adding to existing provider from XML data files '{0}'.", - String.Join(", ", Manager.XmlFiles))); - Xml.Reader.Add(provider, Manager.XmlFiles); - EventLog.Info(String.Format("Added to existing provider from XML data files '{0}'.", - String.Join(", ", Manager.XmlFiles))); - } - } - } - catch (Exception ex) - { - // Record the exception in the log file. - EventLog.Fatal( - new MobileException(String.Format( - "Exception processing device data from binary file '{0}', and XML files '{1}'. " + - "Enable debug level logging and try again to help identify cause.", - Manager.BinaryFilePath, String.Join(", ", Manager.XmlFiles)), - ex)); - // Reset the provider to enable it to be created from the embedded data. - provider = null; - } - finally - { - // Does the provider exist and has data been loaded? - if (provider == null || provider.Handlers.Count == 0) - { - // No so initialise it with the embeddded binary data so at least we can do something. - provider = Provider.EmbeddedProvider; - - // Do XML files exist? - if (Manager.XmlFiles != null && - Manager.XmlFiles.Length > 0) - { - EventLog.Info(String.Format("Adding to existing provider from XML data files '{0}'.", - String.Join(", ", Manager.XmlFiles))); - Xml.Reader.Add(provider, Manager.XmlFiles); - EventLog.Info(String.Format("Added to existing provider from XML data files '{0}'.", - String.Join(", ", Manager.XmlFiles))); - } - } - } - _instance = new MobileCapabilities(provider); - } - - #endregion - - #region Internal Static Methods - - /// - /// Creates a new class based on the useragent - /// string provided. - /// - /// The useragent for the device. - /// - public static IDictionary Create(string userAgent) - { - IDictionary caps; - - // We can't do anything with empty user agent strings. - if (userAgent == null) - return null; - - if (_cache.GetTryParse(userAgent, out caps)) - { - // Return these capabilities for adding to the existing ones. - return caps; - } - - // Create the new mobile capabilities and record the collection of - // capabilities for quick creation in future requests. - caps = Instance.Create(userAgent); - _cache[userAgent] = caps; - return caps; - } - - /// - /// Creates a new class based on the - /// HttpHeaders collection provided. - /// - /// A collection of Http headers from the device. - /// Capabilities already determined by other sources. - /// A new mobile capabilities - public static IDictionary Create(NameValueCollection headers, IDictionary currentCapabilities) - { - IDictionary caps; - string ua = headers["User-Agent"] as string; - - // We can't do anything with empty user agent strings. - if (ua == null) - return null; - - if (_cache.GetTryParse(ua, out caps)) - { - // Return these capabilities for adding to the existing ones. - return caps; - } - - // Create the new mobile capabilities and record the collection of - // capabilities for quick creation in future requests. - caps = Instance.Create(headers, currentCapabilities); - _cache[ua] = caps; - - return caps; - } - - /// - /// Creates a new class based on the context - /// of the requesting device. - /// - /// HttpRequest from the device. - /// Capabilities already determined by other sources. - /// A new mobile capabilities - public static IDictionary Create(HttpRequest request, IDictionary currentCapabilities) - { - return Create(request.Headers, currentCapabilities); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/FiftyOneBrowserCapabilities.cs b/Foundation/Mobile/Detection/FiftyOneBrowserCapabilities.cs deleted file mode 100644 index c99bee3..0000000 --- a/Foundation/Mobile/Detection/FiftyOneBrowserCapabilities.cs +++ /dev/null @@ -1,159 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections; -using System.Collections.Generic; -using System.Web; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// The this[] property has been changed to also check the 51Degrees.mobi capabilities - /// before returning a value if the capability has not been found in the - /// standard collection. - /// - /// - /// Note: The OBSOLETE_SUPPORT pre-compilation directive should be set if support is needed - /// for SharePoint or other applications that expect the Request.Browser property to return - /// an object of type . A reference will - /// need to be added to the project to System.Web.Mobile. This module has been marked - /// obsolete by Microsoft but is still used by SharePoint 2010. Because it is marked - /// obsolete we decided not to require developers have to reference System.Web.Mobile. - /// -#if OBSOLETE_SUPPORT - public class FiftyOneBrowserCapabilities : System.Web.Mobile.MobileCapabilities -#else - public class FiftyOneBrowserCapabilities : HttpBrowserCapabilities -#endif - { - #region Fields - - private SortedList> _fiftyOneProperties; - - #endregion - - #region Constructor - - /// - /// Constructs an instance of - /// - /// Capabilities provided by Microsoft. - /// New capabilities provided by 51Degrees.mobi. Can not be null. - public FiftyOneBrowserCapabilities(HttpBrowserCapabilities currentCapabilities, IDictionary overrideCapabilities) - { - // Initialise the hashtable for capabilities. - Capabilities = new Hashtable(StringComparer.InvariantCultureIgnoreCase); - - // Copy the keys from both the original and new capabilities. - foreach (object key in currentCapabilities.Capabilities.Keys) - Capabilities[key] = currentCapabilities.Capabilities[key]; - - - foreach (object key in overrideCapabilities.Keys) - // Do not override the preferredRenderingType if original - // .NET mobile controls are being used as values greater - // than html32 result in runtime exceptions. -#if OBSOLETE_SUPPORT - if (key.Equals("preferredRenderingType") == false) - { -#endif - Capabilities[key] = overrideCapabilities[key]; -#if OBSOLETE_SUPPORT - } -#endif - - // Copy the adapters from the original. - foreach (object key in currentCapabilities.Adapters.Keys) - Adapters.Add(key, currentCapabilities.Adapters[key]); - - // Copy the browsers from the original to prevent the Browsers - // property returning null. - if (currentCapabilities.Browsers != null) - foreach (string browser in currentCapabilities.Browsers) - AddBrowser(browser); - } - - #endregion - - #region Properties - - /// - /// Returns the 51Degrees.mobi list if it exists. It should - /// always exist if this class is being used. - /// - private SortedList> FiftyOneProperties - { - get - { - if (_fiftyOneProperties == null) - _fiftyOneProperties = Capabilities[Constants.FiftyOneDegreesProperties] as SortedList>; - return _fiftyOneProperties; - } - } - - #endregion - - #region Overridden Members - - /// - /// Returns the value for the property key from the standard - /// collection of capabilities provided by Microsoft. If a value is not - /// found 51Degrees.mobi properties are checked using first a case - /// sensitive, and then insensitive match. - /// - /// The capability key being sought. - /// The value of the key, otherwise null. - public override string this[string key] - { - get - { - string result = base[key]; - - // If the base list of capabilities does not return a result - // then try the 51degrees.mobi capabilities. - if (result == null && - FiftyOneProperties != null) - { - List values; - if (FiftyOneProperties.TryGetValue(key, out values)) - result = String.Join(Constants.ValueSeperator, values.ToArray()); - - // If the key can't be found try a case insensitive search. - else - { -#if VER4 || VER35 - var matches = FiftyOneProperties.Where(i => - i.Key.Equals(key, StringComparison.InvariantCultureIgnoreCase)).ToList(); -#else - List>> matches = new List>>(); - foreach(KeyValuePair> item in FiftyOneProperties) - if (item.Key.Equals(key, StringComparison.InvariantCultureIgnoreCase)) - matches.Add(item); -#endif - if (matches != null && matches.Count > 0) - result = String.Join(Constants.ValueSeperator, matches[0].Value.ToArray()); - } - } - - return result; - } - } - - #endregion - } -} diff --git a/Foundation/Mobile/Detection/Handlers/EditDistanceHandler.cs b/Foundation/Mobile/Detection/Handlers/EditDistanceHandler.cs deleted file mode 100644 index 1f45a50..0000000 --- a/Foundation/Mobile/Detection/Handlers/EditDistanceHandler.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using FiftyOne.Foundation.Mobile.Detection.Matchers; -using Matcher = FiftyOne.Foundation.Mobile.Detection.Matchers.EditDistance.Matcher; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Handlers -{ - /// - /// Device detection handler using the EditDistance method of matching devices. - /// - public class EditDistanceHandler : Handler - { - #region Constructor - - internal EditDistanceHandler(Provider provider, string name, string defaultDeviceId, byte confidence, bool checkUAProfs) - : base(provider, name, defaultDeviceId, confidence, checkUAProfs) - { - } - - #endregion - - #region Overridden Methods - - internal override Results Match(string userAgent) - { - return Matcher.Match(userAgent, this); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Handlers/HandleRegex.cs b/Foundation/Mobile/Detection/Handlers/HandleRegex.cs deleted file mode 100644 index f9515f1..0000000 --- a/Foundation/Mobile/Detection/Handlers/HandleRegex.cs +++ /dev/null @@ -1,83 +0,0 @@ -/* ********************************************************************* - * 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 System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace FiftyOne.Foundation.Mobile.Detection.Handlers -{ - /// - /// A regex, and children, used to determine if a useragent can - /// be matched by the associated handler. Not only does the regex - /// provided have to match by any one of the children. - /// - public class HandleRegex : Regex - { - #region Fields - - /// - /// A list of children. - /// - private List _children = new List(); - - #endregion - - #region Properties - - /// - /// A list of children. - /// - public List Children - { - get { return _children; } - } - - #endregion - - #region Constructor - - /// - /// Constructs a new instance of . - /// - /// Regex pattern. - internal HandleRegex(string pattern) - : base(pattern, RegexOptions.Compiled | RegexOptions.CultureInvariant) - { - } - - #endregion - - #region Overriden Properties - - /// - /// Returns true if the regex and any one of it's child match. - /// - /// The useragent string to check. - /// True if a match is found. - internal new bool IsMatch(string useragent) - { - if (base.IsMatch(useragent)) - { - if (_children.Count == 0) - return true; - - foreach (HandleRegex child in _children) - { - if (child.IsMatch(useragent)) - return true; - } - } - return false; - } - - #endregion - } -} diff --git a/Foundation/Mobile/Detection/Handlers/Handler.cs b/Foundation/Mobile/Detection/Handlers/Handler.cs deleted file mode 100644 index cae3c08..0000000 --- a/Foundation/Mobile/Detection/Handlers/Handler.cs +++ /dev/null @@ -1,521 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using FiftyOne.Foundation.Mobile.Detection.Matchers; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Handlers -{ - /// - /// Base handler class for device detection. - /// - public abstract class Handler : IComparable - { - #region Constants - - /// - /// The default confidence to assign to results from the handler. - /// - private const byte DEFAULT_CONFIDENCE = 5; - - /// - /// HTTP headers containing uaprof urls. - /// - private static readonly string[] UAPROF_HEADERS = new string[] - { - "profile", - "x-wap-profile", - "X-Wap-Profile" - }; - - #endregion - - #region Fields - - /// - /// A collection of domain names used with uaprof urls. - /// - private readonly List _uaProfDomains = new List(); - - /// - /// A single collection of all uaprof urls used by devices assigned to this handler. - /// - private readonly SortedDictionary _uaprofs = - new SortedDictionary(); - - /// - /// A single collection of all devices assigned to this handler, keyed on the hashcode of the useragent. - /// - private readonly SortedDictionary _devices = - new SortedDictionary(); - - /// - /// The name of the handler for debugging purposes. - /// - private string _name = null; - - /// - /// The default device to be used if no match is found. - /// - private string _defaultDeviceId = null; - - /// - /// The confidence matches from this handler should be given - /// compared to other handlers. - /// - private byte _confidence = 0; - - /// - /// True if the UA Prof HTTP headers should be checked. - /// - private bool _checkUAProfs = false; - - /// - /// A list of regex's that if matched will indicate support for this handler. - /// - private List _canHandleRegex = new List(); - - /// - /// A list of regex's that if matched indicate the handler is not supported. - /// - private List _cantHandleRegex = new List(); - - /// - /// The provider instance the handler is associated with. - /// - private readonly Provider _provider; - - #endregion - - #region Public Properties - - /// - /// The name of the handler for debugging purposes. - /// - public string Name - { - get { return _name; } - } - - /// - /// Returns the number of devices assigned to the handler. - /// - public int Count - { - get { return Devices.Count; } - } - - /// - /// Returns true/false depending on if the UA Profs should be checked. - /// - public bool CheckUAProfs { get { return _checkUAProfs; } } - - /// - /// The confidence to assign to results from this handler. - /// - public byte Confidence - { - get { return _confidence; } - } - - /// - /// A list of regexs that if matched indicate the handler does support the - /// useragent passed to it. - /// - public List CanHandleRegex - { - get { return _canHandleRegex; } - } - - /// - /// A list of regexs that if matched indicate the handler does not support the - /// useragent passed to it. - /// - public List CantHandleRegex - { - get { return _cantHandleRegex; } - } - - #endregion - - #region Internal Properties - - /// - /// Returns the provider the handler is associated to. - /// - internal Provider Provider - { - get { return _provider; } - } - - /// - /// Returns the list of devices assigned to the handler keyed on the useragent's hashcode. - /// - internal SortedDictionary UAProfs - { - get { return _uaprofs; } - } - - /// - /// Returns the list of devices assigned to the handler keyed on the useragent's hashcode. - /// - internal SortedDictionary Devices - { - get { return _devices; } - } - - #endregion - - #region Constructor - - /// - /// Constructs an instance of . - /// - /// Reference to the provider instance the handler will be associated with. - /// Name of the handler for debugging purposes. - /// The default device ID to return if no match is possible. - /// The confidence this handler should be given compared to others. - /// True if UAProfs should be checked. - internal Handler(Provider provider, string name, string defaultDeviceId, byte confidence, bool checkUAProfs) - { - if (String.IsNullOrEmpty(name)) - throw new ArgumentNullException(name); - - _provider = provider; - _name = name; - _defaultDeviceId = defaultDeviceId; - _confidence = confidence > 0 ? confidence : DEFAULT_CONFIDENCE; - _checkUAProfs = checkUAProfs; - } - - #endregion - - #region Abstract Methods - - /// - /// The inheriting classes match method. - /// - /// The useragent to match. - /// A result set of matching devices. - internal abstract Results Match(string userAgent); - - #endregion - - #region Public Methods - - /// - /// Compares this handler to another where the handler is used - /// as a key in a sorted list. - /// - /// The other handler to compare to this one. - /// See string CompareTo method. - public int CompareTo(Handler other) - { - return Name.CompareTo(other.Name); - } - - /// - /// Returns true or false depending on the handlers ability - /// to match the user agent provided. - /// - /// The user agent to be tested. - /// True if this handler can support the useragent, otherwise false. - public virtual bool CanHandle(string userAgent) - { - foreach (HandleRegex regex in _cantHandleRegex) - if (regex.IsMatch(userAgent)) - return false; - - foreach (HandleRegex regex in _canHandleRegex) - if (regex.IsMatch(userAgent)) - return true; - - return false; - } - - #endregion - - #region Internal Methods - - /// - /// Adds a new device to the handler. - /// - /// device being added to the handler. - internal virtual void Set(BaseDeviceInfo device) - { - SetUserAgent(device); - SetUaProf(device); - } - - /// - /// Returns the device matching the userAgent string if one is available. - /// - /// userAgent being sought. - /// null if no device is found. Otherwise the matching device. - internal BaseDeviceInfo GetDeviceInfo(string userAgent) - { - // Get the devices with the same hashcode as the useragent. - BaseDeviceInfo[] devices = GetDeviceInfo(_devices, userAgent); - if (devices != null && devices.Length > 0) - { - // If only one device available return this one. - if (devices.Length == 1) - return devices[0]; - - // Look at each device for an exact match. Very rare - // that more than one device will be returned. - foreach (BaseDeviceInfo device in devices) - { - if (device.UserAgent == userAgent) - { - return device; - } - } - } - return null; - } - - /// - /// Returns all the devices that match the UA prof provided. - /// - /// UA prof to search for. - /// Results containing all the matching devices. - internal Results GetResultsFromUAProf(string uaprof) - { - BaseDeviceInfo[] devices = GetDeviceInfo(_uaprofs, uaprof); - if (devices != null && devices.Length > 0) - { - // Add the devices to the list of results and return. - Results results = new Results(); - results.AddRange(devices, this, 0, string.Empty); - return results; - } - return null; - } - - /// - /// Checks to see if the handler can support this device. - /// - /// Device to be checked. - /// True if the device is supported, other false. - protected internal virtual bool CanHandle(BaseDeviceInfo device) - { - return CanHandle(device.UserAgent); - } - - /// - /// - /// First checks if the useragent from the request can be handled by - /// this handler. - /// - /// - /// If the useragent can't be handled then the request is checked to - /// determine if a uaprof header field is provided. If so we check - /// the list of uaprof domains assigned to this handler to see if - /// they share the same domain. - /// - /// - /// Collection of http headers. - /// True if this handler could be able to match the device otherwise false. - internal virtual bool CanHandle(NameValueCollection headers) - { - bool canHandle = CanHandle(Provider.GetUserAgent(headers)); - if (_checkUAProfs && canHandle == false && _uaProfDomains.Count > 0) - { - Uri url = null; - foreach (string header in UAPROF_HEADERS) - { - string value = headers[header]; - if (value != null && - Uri.TryCreate(value, UriKind.Absolute, out url) && - _uaProfDomains.Contains(url.Host)) - { - return true; - } - } - } - return canHandle; - } - - /// - /// Performs an exact match using the userAgent string. If no results are found - /// uses the UA prof header parameters to find a list of devices. - /// - /// Collection of Http headers associated with the request. - /// null if no exact match was found. Otherwise the matching devices. - internal virtual Results Match(NameValueCollection headers) - { - // Check for an exact match of the user agent string. - string userAgent = Provider.GetUserAgent(headers); - BaseDeviceInfo device = GetDeviceInfo(userAgent); - if (device != null) - return new Results(device, this, 0, userAgent); - - // Check to see if we have a uaprof header parameter that will produce - // an exact match. - if (_checkUAProfs && headers != null && headers.Count > 0) - { - foreach (string header in UAPROF_HEADERS) - { - string value = headers[header]; - if (String.IsNullOrEmpty(value) == false) - { - value = UserAgentProfileUrlParser.CleanUserAgentProfileUrl(value); - Results results = GetResultsFromUAProf(value); - if (results != null && results.Count > 0) - { - if (EventLog.IsDebug) - EventLog.Debug(String.Format("UAProf matched '{0}' devices to header '{1}'.", - results.Count, value)); - return results; - } - } - } - } - - // There isn't a UA Prof match so use the handler specific methods. - return Match(userAgent); - } - - #endregion - - #region Private Methods - - /// - /// Adds the device and it's user agent string to the collection - /// of user agent strings and devices. The useragent string - /// hashcode is the key of the collection. - /// - /// A new device to add. - private void SetUserAgent(BaseDeviceInfo device) - { - int hashcode = device.UserAgent.GetHashCode(); - lock (_devices) - { - BaseDeviceInfo[] value; - // Does the hashcode already exist? - if (_devices.TryGetValue(hashcode, out value)) - { - // Does the key already exist? - for (int i = 0; i < value.Length; i++) - { - if (value[i].UserAgent == device.UserAgent) - { - // Yes. Update with the new device and then exit. - value[i] = device; - return; - } - } - // No. Expand the array adding the new device. - List newList = new List(value); - newList.Add(device); - _devices[hashcode] = newList.ToArray(); - } - else - { - // Add the device to the collection. - _devices.Add(hashcode, new BaseDeviceInfo[] { device }); - } - } - } - - /// - /// Adds the device to the collection of devices with UA prof information. - /// If the device already exists the previous one is replaced. - /// - /// Device to be added. - private void SetUaProf(BaseDeviceInfo device) - { - foreach (int index in _provider.UserAgentProfileStringIndexes) - { - List list = device.GetPropertyValueStringIndexes(index); - if (list != null) - { - foreach (int userAgentProfileStringIndex in list) - { - string value = _provider.Strings.Get(userAgentProfileStringIndex); - - // Don't process empty values. - if (String.IsNullOrEmpty(value)) continue; - - // If the url is not valid don't continue processing. - Uri url = null; - if (Uri.TryCreate(value, UriKind.Absolute, out url) == false) continue; - - // Get the hashcode before locking the list and processing - // the device and hashcode. - int hashcode = value.GetHashCode(); - lock (_uaprofs) - { - ProcessUaProf(device, hashcode); - } - - // Add the domain to the list of domains for the handler. - lock (_uaProfDomains) - { - if (_uaProfDomains.Contains(url.Host) == false) - _uaProfDomains.Add(url.Host); - } - } - } - } - } - - private void ProcessUaProf(BaseDeviceInfo device, int hashcode) - { - // Does the hashcode already exist? - if (_uaprofs.ContainsKey(hashcode)) - { - // Does the key already exist? - int index; - for (index = 0; index < _uaprofs[hashcode].Length; index++) - { - if (_uaprofs[hashcode][index].DeviceId != device.DeviceId) continue; - // Yes. Update with the new device and then exit. - _uaprofs[hashcode][index] = device; - return; - } - // No. Expand the array adding the new device. - List newList = new List(_uaprofs[hashcode]); - newList.Add(device); - _uaprofs[hashcode] = newList.ToArray(); - } - else - { - // Add the device to the collection. - _uaprofs.Add(hashcode, new BaseDeviceInfo[] { device }); - } - } - - /// - /// Returns the devices that match a specific hashcode. - /// - /// Collection of hashcodes and devices. - /// Value that's hashcode is being sought. - /// Array of devices matching the value. - private static BaseDeviceInfo[] GetDeviceInfo(SortedDictionary dictionary, string value) - { - BaseDeviceInfo[] result; - if (dictionary != null && - dictionary.TryGetValue(value.GetHashCode(), out result)) - return result; - return null; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Handlers/ReducedInitialStringHandler.cs b/Foundation/Mobile/Detection/Handlers/ReducedInitialStringHandler.cs deleted file mode 100644 index 2b1dfbb..0000000 --- a/Foundation/Mobile/Detection/Handlers/ReducedInitialStringHandler.cs +++ /dev/null @@ -1,77 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Text.RegularExpressions; -using FiftyOne.Foundation.Mobile.Detection.Matchers; -using Matcher = FiftyOne.Foundation.Mobile.Detection.Matchers.ReducedInitialString.Matcher; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Handlers -{ - /// - /// Device detection handler using the reduced initial string method. The first - /// part of the strings are checked to determine a match. - /// - public class ReducedInitialStringHandler : Handler - { - #region Fields - - private Regex _tolerance = null; - - #endregion - - #region Properties - - /// - /// The regular expression used to determine the first X - /// characters to check of the string. - /// - public Regex Tolerance - { - get { return _tolerance; } - } - - #endregion - - #region Constructor - - /// - /// Constucts an instance of . - /// - /// Reference to the provider instance the handler will be associated with. - /// Name of the handler for debugging purposes. - /// The default device ID to return if no match is possible. - /// The confidence this handler should be given compared to others. - /// True if UAProfs should be checked. - /// Regex used to calculate how many characters should be matched at the beginning of the useragent. - internal ReducedInitialStringHandler(Provider provider, string name, string defaultDeviceId, byte confidence, bool checkUAProfs, string tolerance) - : base(provider, name, defaultDeviceId, confidence, checkUAProfs) - { - _tolerance = new Regex(tolerance, RegexOptions.Compiled); - } - - #endregion - - #region Methods - - internal override Results Match(string userAgent) - { - return Matcher.Match(userAgent, this, _tolerance.Match(userAgent).Length); - } - - #endregion - - - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Handlers/RegexSegmentHandler.cs b/Foundation/Mobile/Detection/Handlers/RegexSegmentHandler.cs deleted file mode 100644 index 52b5491..0000000 --- a/Foundation/Mobile/Detection/Handlers/RegexSegmentHandler.cs +++ /dev/null @@ -1,229 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using FiftyOne.Foundation.Mobile.Detection.Matchers.Segment; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Handlers -{ - /// - /// Device detection handler using regular expressions to segment strings - /// before matching specific segments. - /// - public class RegexSegmentHandler : SegmentHandler - { - #region Classes - - /// - /// Contains regular expression and weight to apply to - /// each segment of the user agent string. - /// - public class RegexSegment - { - #region Fields - - private Regex _pattern; - private int _weight; - - #endregion - - #region Properties - - /// - /// The regular expression to use to get the segment. - /// - public Regex Pattern { get { return _pattern; }} - - /// - /// The weight that should be given to the segment. The lower - /// the number the greater the significance. - /// - public int Weight { get { return _weight; } } - - #endregion - - #region Constructor - - /// - /// Constructs a new instance of . - /// - /// The regular expression for the segment. - /// The relative weight to apply to the segment. - internal RegexSegment(string pattern, int weight) - { - _pattern = new Regex(pattern, RegexOptions.Compiled | RegexOptions.CultureInvariant); - _weight = weight; - } - - #endregion - } - - #endregion - - #region Fields - - /// - /// A list of segments to be found and matched by the handler. - /// - private List _segments = new List(); - - /// - /// Lock used to add new segments to the device. - /// - private object _createSegmentsLock = new object(); - - #endregion - - #region Properties - - /// - /// A list of the regular expressions used to create segments. - /// - public List Segments - { - get { return _segments; } - } - - #endregion - - #region Constructor - - internal RegexSegmentHandler(Provider provider, string name, string defaultDeviceId, byte confidence, bool checkUAProfs) - : base(provider, name, defaultDeviceId, confidence, checkUAProfs) - { - } - - #endregion - - #region Methods - - internal void AddSegment(string pattern, int weight) - { - _segments.Add(new RegexSegment(pattern, weight)); - } - - #endregion - - #region Overridden Methods - - /// - /// Returns true if the handler can match the requests useragent string - /// and at least one valid segment ise returned as a segment. - /// - /// - /// - public override bool CanHandle(string userAgent) - { - if (base.CanHandle(userAgent) == false) - return false; - - foreach (RegexSegment segment in _segments) - if (segment.Pattern.IsMatch(userAgent)) - return true; - - return false; - } - - #endregion - - #region Abstract Method Implementation - - /// - /// Returns segments for the index specified checking in the stored results first - /// if the StoreSegmentResults constant is enabled. - /// - /// The source useragent string. - /// The index of the regular expression to use to get the segments. - /// The list of matching segments. - #pragma warning disable 162 - internal override List CreateSegments(BaseDeviceInfo device, int index) - { - List segments = null; - if (Constants.StoreSegmentResults) - { - // Get the handlers data from the device. - List> cachedSegments = (List>)device.GetHandlerData>>(this); - - // If the segment does not already exist then add it. - if (cachedSegments.Count <= index) - { - lock (_createSegmentsLock) - { - if (cachedSegments.Count <= index) - { - while (cachedSegments.Count <= index) - cachedSegments.Add(new List()); - segments = CreateSegments(device.UserAgent, _segments[index]); - cachedSegments[index] = segments; - } - } - } - else - segments = cachedSegments[index]; - } - else - { - segments = CreateSegments(device.UserAgent, _segments[index]); - } - return segments; - } - #pragma warning restore 162 - - /// - /// Returns the segments from the source string. Where a segment returns nothing - /// a single empty segment will be added. - /// - /// - /// - internal override Segments CreateAllSegments(string source) - { - Segments results = new Segments(); - foreach (RegexSegment segment in _segments) - { - results.Add(CreateSegments(source, segment)); - } - return results; - } - - private List CreateSegments(string source, RegexSegment segment) - { - bool matched = false; - List newSegments = new List(); - MatchCollection matches = segment.Pattern.Matches(source); - - // Add a segment for each match found. - foreach (Match match in matches) - { - if (match.Success) - { - newSegments.Add(new Segment(match.Value, segment.Weight)); - matched = true; - } - } - if (matched == false) - { - // Add an empty segment to avoid problems of missing segments - // stopping others being compared correctly. - newSegments.Add(new Segment(String.Empty, segment.Weight)); - } - - return newSegments; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Handlers/SegmentHandler.cs b/Foundation/Mobile/Detection/Handlers/SegmentHandler.cs deleted file mode 100644 index c20fbb0..0000000 --- a/Foundation/Mobile/Detection/Handlers/SegmentHandler.cs +++ /dev/null @@ -1,65 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Collections.Generic; -using FiftyOne.Foundation.Mobile.Detection.Matchers.Segment; -using Results = FiftyOne.Foundation.Mobile.Detection.Matchers.Results; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Handlers -{ - /// - /// An abstract handler used by any handler that breaks a string down into - /// segments. - /// - public abstract class SegmentHandler : Handler - { - #region Constructor - - internal SegmentHandler(Provider provider, string name, string defaultDeviceId, byte confidence, bool checkUAProfs) - : base(provider, name, defaultDeviceId, confidence, checkUAProfs) - { - } - - #endregion - - #region Abstract Methods - - /// - /// Creates segments for all regexes. - /// - /// The useragent segments should be returned for. - /// The list of segments. - internal abstract Segments CreateAllSegments(string userAgent); - - /// - /// Creates segments for the regex index provided. - /// - /// The device to get the segments from. - /// The index of the segment required. - /// The list of segments. - internal abstract List CreateSegments(BaseDeviceInfo device, int index); - - #endregion - - #region Overridden Methods - - internal override Results Match(string userAgent) - { - return Matcher.Match(userAgent, this); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/LicenceKey.cs b/Foundation/Mobile/Detection/LicenceKey.cs deleted file mode 100644 index 80bb4f3..0000000 --- a/Foundation/Mobile/Detection/LicenceKey.cs +++ /dev/null @@ -1,352 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Security; -using System.Text.RegularExpressions; -using System.Web.Hosting; -using FiftyOne.Foundation.Mobile.Configuration; -using FiftyOne.Foundation.Mobile.Detection.Configuration; - -#if VER4 - -using System.Linq; -using System.Configuration; - -#endif - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Static class used to manage the activate licence keys. - /// - public static class LicenceKey - { - #region Fields - - /// - /// Licence keys added dynamically via external assmeblies. - /// - private static List _dynamicKeys = new List(); - - #endregion - - #region Internal Properties - - /// - /// Returns a list of the valid license keys available - /// to the assembly. - /// - internal static string[] Keys - { - get - { - // Initilaise the list with any dynamic keys. - List list = new List(_dynamicKeys); - - // See if a license key is included in the assembly. - if (String.IsNullOrEmpty(Constants.PremiumLicenceKey) == false && - IsKeyFormatValid(Constants.PremiumLicenceKey)) - list.Add(Constants.PremiumLicenceKey); - - // Now try the bin folder for license key files. - foreach (string fileName in Directory.GetFiles( - HostingEnvironment.ApplicationPhysicalPath + "bin", "*.lic")) - { - string alltext = File.ReadAllText(fileName); - foreach(string key in alltext.Split( - new string[] { "\r\n", "\r", "\n" }, - StringSplitOptions.RemoveEmptyEntries)) - if (IsKeyFormatValid(key)) - list.Add(key); - } - - return list.ToArray(); - } - } - - #endregion - - #region Public Properties - - /// - /// Returns the host name of the web service used to provide new device data - /// and also validate the licence key. - /// - public static string HostName - { - get { return new Uri(FiftyOne.Foundation.Mobile.Detection.Constants.AutoUpdateUrl).Host; } - } - - /// - /// The name of the licence key file in the bin folder. - /// - public static string LicenceKeyFileName - { - get { return Detection.Constants.LicenceKeyFileName; } - } - - #endregion - - #region Public Methods - - /// - /// Adds a licence key to the list of available licence keys at runtime. - /// This method can be used by 3rd party assemblies to set licence keys. - /// - /// - public static void AddKey(string key) - { - if (IsKeyFormatValid(key) && - _dynamicKeys.Contains(key) == false) - _dynamicKeys.Add(key); - } - - /// - /// Activates the data pointed to by the stream. - /// - /// Stream to data to activate - public static LicenceKeyResults Activate(Stream stream) - { - byte[] data = null; - try - { - using (MemoryStream ms = new MemoryStream()) - { -#if VER4 - stream.CopyTo(ms); -#else - int value = stream.ReadByte(); - while (value >= 0) - { - ms.WriteByte((byte)value); - value = stream.ReadByte(); - } -#endif - data = ms.ToArray(); - } - } - catch (Exception ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.StreamFailure; - } - - return Activate(data); - } - - /// - /// Activates the data array containing the premium data. - /// - /// Data to activate - public static LicenceKeyResults Activate(byte[] data) - { - try - { - Provider provider = null; - - // Validate the data provided is correct. - try - { - provider = AutoUpdate.CreateProvider(data); - } - catch (MobileException ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.DataInvalid; - } - - // Check the configuration. - try - { - CheckConfig(); - } - catch (Exception ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.Config; - } - - // Write the file to the binary data path. - try - { - File.WriteAllBytes(Detection.Configuration.Manager.BinaryFilePath, data); - File.SetLastAccessTimeUtc(Detection.Configuration.Manager.BinaryFilePath, provider.PublishedDate); - } - catch (IOException ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.WriteDataFile; - } - - // Switch in the new data to complete activation. - AutoUpdate.Reset(); - - EventLog.Info(String.Format( - "Activated binary data file '{0}' with new version " + - "dated the '{1:d}'.", - AutoUpdate.BinaryFile.FullName, - Factory.ActiveProvider.PublishedDate)); - } - catch (Exception ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.GenericFailure; - } - - return LicenceKeyResults.Success; - } - - /// - /// Activates the licence key provided. - /// - /// Licence key - public static LicenceKeyResults Activate(string licenceKey) - { - try - { - try - { - CheckConfig(); - } - catch (Exception ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.Config; - } - - WebClient client; - byte[] data; - - // Try and get the latest data. If there is a failure then - // return the status code indicating that there is an HTTPS - // problem connecting to the device data service. - try - { - client = new WebClient(); - data = client.DownloadData(AutoUpdate.FullUrl(new string[] { licenceKey })); - } - catch (SecurityException ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.Https; - } - catch (WebException ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.Https; - } - - // Validate the results and ensure the data provided is correct. - Provider provider = null; - try - { - AutoUpdate.ValidateMD5(client, data); - provider = AutoUpdate.CreateProvider(data); - } - catch (MobileException ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.Invalid; - } - - // Write the license key to the bin folder. - try - { - File.WriteAllText(Path.Combine( - HostingEnvironment.ApplicationPhysicalPath, - Path.Combine("bin", Constants.LicenceKeyFileName)), licenceKey); - } - catch (Exception ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.WriteLicenceFile; - } - - // Write the file to the binary data path. - try - { - File.WriteAllBytes(Detection.Configuration.Manager.BinaryFilePath, data); - File.SetLastAccessTimeUtc(Detection.Configuration.Manager.BinaryFilePath, provider.PublishedDate); - } - catch (IOException ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.WriteDataFile; - } - - // Switch in the new data to complete activation. - AutoUpdate.Reset(); - - EventLog.Info(String.Format( - "Activated binary data file '{0}' with new version " + - "dated the '{1:d}'.", - AutoUpdate.BinaryFile.FullName, - Factory.ActiveProvider.PublishedDate)); - - } - catch (Exception ex) - { - EventLog.Warn(ex); - return LicenceKeyResults.GenericFailure; - } - - return LicenceKeyResults.Success; - } - - #endregion - - #region Private Methods - - /// - /// Returns true if the key format is valid. i.e. it contains - /// only upper case letters and numbers. - /// - /// - /// - private static bool IsKeyFormatValid(string key) - { - return Regex.IsMatch(key, Constants.LicenceKeyValidationRegex); - } - - /// - /// Checks - /// - private static void CheckConfig() - { - // Get the current section. - DetectionSection section = Support.GetWebApplicationSection("fiftyOne/detection", false) as DetectionSection; - - // If the section is valid then do nothing. - if (section != null && - String.IsNullOrEmpty(section.BinaryFilePath) == false) - return; - - // If the section does not exist then create it. - if (section == null) - section = new DetectionSection(); - - // Set the binary path to the default. - section.BinaryFilePath = Detection.Constants.DefaultBinaryFilePath; - - // Add the section back to the configuration. - FiftyOne.Foundation.Mobile.Configuration.Support.SetWebApplicationSection(section); - - // Refresh the configuration. - Detection.Configuration.Manager.Refresh(); - } - - #endregion - } -} diff --git a/Foundation/Mobile/Detection/LicenceKeyActivationResults.cs b/Foundation/Mobile/Detection/LicenceKeyActivationResults.cs deleted file mode 100644 index 6e80e2f..0000000 --- a/Foundation/Mobile/Detection/LicenceKeyActivationResults.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Enumeration of reasons why activation could fail. - /// - public enum LicenceKeyResults - { - /// - /// The licence key was activated successfully for this web site. - /// - Success = 1, - /// - /// An HTTPS connection could not be established with the validation service. - /// - Https = 2, - /// - /// The licence key is invalid. - /// - Invalid = 3, - /// - /// The configuration file could not be altered. - /// - Config = 4, - /// - /// The licence file could not be written to the bin folder. - /// - WriteLicenceFile = 5, - /// - /// The data file could not be written to the folder. - /// - WriteDataFile = 6, - /// - /// The licence key could not be activated for an unknown reason. - /// - GenericFailure = 7, - /// - /// The source stream could not be read from. - /// - StreamFailure = 8, - /// - /// The stream does not contain valid data. - /// - DataInvalid = 9 - } -} diff --git a/Foundation/Mobile/Detection/Matchers/Algorithms.cs b/Foundation/Mobile/Detection/Matchers/Algorithms.cs deleted file mode 100644 index 5189461..0000000 --- a/Foundation/Mobile/Detection/Matchers/Algorithms.cs +++ /dev/null @@ -1,115 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers -{ - /// - /// Contains major matching algorithms used by the solution. - /// - public class Algorithms - { - /// - /// Measures the amount of difference between two strings using the Levenshtein - /// Distance algorithm. This implementation uses a modified version of the pseudo - /// code found at http://en.wikipedia.org/wiki/Levenshtein_distance. - /// The logic has been modified to ignore string comparisions that will return - /// a value greater than the lowest one found so far. This significantly improves - /// performance as we can determine earlier if there is any point completing the - /// calculation. - /// - /// 1st string to compare. - /// 2nd string to compare. - /// The maximum value we're interested in. Anything higher can be ignored. - /// - public static int EditDistance(string str1, string str2, int maxValue) - { - return EditDistance( - new int[][] {new int[str1.Length + 1], new int[str1.Length + 1]}, - str1, str2, maxValue); - } - - - /// - /// Measures the amount of difference between two strings using the Levenshtein - /// Distance algorithm. This implementation uses a modified version of the pseudo - /// code found at http://en.wikipedia.org/wiki/Levenshtein_distance. - /// The logic has been modified to ignore string comparisions that will return - /// a value greater than the lowest one found so far. This significantly improves - /// performance as we can determine earlier if there is any point completing the - /// calculation. - /// Requires the integer array to preallocated to improve memory management. - /// - /// Preallocated memory for the calculation. - /// 1st string to compare. - /// 2nd string to compare. - /// The maximum value we're interested in. Anything higher can be ignored. - /// - public static int EditDistance(int[][] rows, string str1, string str2, int maxValue) - { - // Confirm input strings are valid. - if (str1 == null) throw new ArgumentNullException("str1"); - if (str2 == null) throw new ArgumentNullException("str2"); - - // Get string lengths and check for zero length. - int l1 = str1.Length, l2 = str2.Length; - if (l1 == 0) return l2; - if (l2 == 0) return l1; - - // Initialise the data structures. - int curRow = 0, nextRow = 1; - for (int x = 0; x <= l1; ++x) rows[curRow][x] = x; - - for (int y = 1; y <= l2; ++y) - { - int lowest = int.MaxValue; - rows[nextRow][0] = y; - for (int x = 1; x <= l1; ++x) - { - // Calculate the edit distant value for the current cell. - int value = Math.Min( - rows[curRow][x] + 1, - Math.Min(rows[nextRow][x - 1] + 1, - rows[curRow][x - 1] + ((str1[x - 1] == str2[y - 1]) ? 0 : 1))); - rows[nextRow][x] = value; - - // Record the lowest value on this row. - if (value < lowest) - lowest = value; - } - - // If the lowest value found so far is greater than the maximum value - // we're interested in return a large number that will be ignored. - if (lowest > maxValue) - return int.MaxValue; - - // Swap the current and next rows - if (curRow == 0) - { - curRow = 1; - nextRow = 0; - } - else - { - curRow = 0; - nextRow = 1; - } - } - - return rows[curRow][l1]; - } - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/EditDistance/Matcher.cs b/Foundation/Mobile/Detection/Matchers/EditDistance/Matcher.cs deleted file mode 100644 index 4f77055..0000000 --- a/Foundation/Mobile/Detection/Matchers/EditDistance/Matcher.cs +++ /dev/null @@ -1,113 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Threading; -using FiftyOne.Foundation.Mobile.Detection.Handlers; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers.EditDistance -{ - internal class Matcher : Matchers.Matcher - { - /// - /// Returns the closest match to the userAgent string from the queue of - /// possible values. - /// - /// userAgent being matched - /// the handler associated with the matching request - /// best match userAgent - internal static Results Match(string userAgent, Handler handler) - { -#pragma warning disable 162 - if (Environment.ProcessorCount > 1 && - Detection.Constants.ForceSingleProcessor == false) - { - return MatchMultiProcessor(userAgent, handler); - } - else - { - return MatchSingleProcessor(userAgent, handler); - } -#pragma warning restore 162 - } - - private static Results MatchSingleProcessor(string userAgent, Handler handler) - { - // Create a single matcher and start it. - Request request = new Request(userAgent, handler); - // Process the request. - ServiceRequest(request); - // Return the results. - return request.Results; - } - - private static Results MatchMultiProcessor(string userAgent, Handler handler) - { - // Create the request. - Request request = new Request(userAgent, handler); - if (request.Count > 0) - { - // For each thread add this to the queue. - for (int i = 0; i < request.ThreadCount; i++) - ThreadPool.QueueUserWorkItem(ServiceRequest, request); - - // Wait until a signal is received. Keeping coming back to - // this thread so that a request to close the request - // can be processed. - while (request.Wait(1) == false) - { - // Do nothing - } - } - // Return the results. - return request.Results; - } - - private static void ServiceRequest(object sender) - { - ServiceRequest((Request) sender); - } - - private static void ServiceRequest(Request request) - { - string userAgent = request.UserAgent; - int[][] rows = new int[][] { new int[userAgent.Length + 1], new int[userAgent.Length + 1] }; - BaseDeviceInfo current = request.Next(); - while (current != null) - { - // Perform the edit distance check. - int distance = Algorithms.EditDistance(rows, userAgent, current.UserAgent, request.Results.MinDistance); - if (distance <= request.Results.MinDistance) - { - lock (request.Results) - { - if (distance < request.Results.MinDistance) - { - request.Results.MinDistance = distance; - request.Results.Clear(); - request.Results.Add(current, request.Handler, (uint)distance, userAgent); - } - else if (distance == request.Results.MinDistance) - { - request.Results.Add(current, request.Handler, (uint)distance, userAgent); - } - } - } - current = request.Next(); - } - request.Complete(); - } - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/EditDistance/Request.cs b/Foundation/Mobile/Detection/Matchers/EditDistance/Request.cs deleted file mode 100644 index c3adf64..0000000 --- a/Foundation/Mobile/Detection/Matchers/EditDistance/Request.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Threading; -using FiftyOne.Foundation.Mobile.Detection.Handlers; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers.EditDistance -{ - internal class Request : Matchers.Request - { - #region Fields - - private readonly Results _results; - - #endregion - - #region Properties - - internal Results Results - { - get { return _results; } - } - - #endregion - - #region Constructors - - internal Request(string userAgent, Handler handler) : - base(userAgent, handler) - { - _results = new Results(); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/EditDistance/Results.cs b/Foundation/Mobile/Detection/Matchers/EditDistance/Results.cs deleted file mode 100644 index ebf2307..0000000 --- a/Foundation/Mobile/Detection/Matchers/EditDistance/Results.cs +++ /dev/null @@ -1,18 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers.EditDistance -{ - internal class Results : Matchers.Results - { - internal int MinDistance = int.MaxValue; - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/Final/Matcher.cs b/Foundation/Mobile/Detection/Matchers/Final/Matcher.cs deleted file mode 100644 index 75adaf2..0000000 --- a/Foundation/Mobile/Detection/Matchers/Final/Matcher.cs +++ /dev/null @@ -1,164 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Collections.Generic; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers.Final -{ - internal class Matcher - { - /// - /// Examines each string in the list to find the one that has the highest number of - /// initial matching characters. If only one is found this is returned. If more than - /// one have the same number of matches are found further analysis is performed - /// on the non matching parts or string tails. - /// - /// userAgent to be found - /// list of possible devices to match against - /// The closest matching result - internal static Result Match(string userAgent, Results results) - { - int pos = 0; - int highestPosition = 0; - List subset = new List(); - foreach (Result result in results) - { - // Find the shortest length and compare characters - // upto this point. - int length = result.Device.UserAgent.Length > userAgent.Length - ? userAgent.Length - : result.Device.UserAgent.Length; - // For each character check equality. If the characters - // aren't equal record this position. - for (pos = 0; pos < length; pos++) - { - if (userAgent[pos] != result.Device.UserAgent[pos]) - break; - } - // If this position is greater than the highest position so - // far than empty the list of subsets found and record this - // result in addition to the new highest position. - if (pos > highestPosition) - { - highestPosition = pos; - subset.Clear(); - subset.Add(result); - } - // If the position is the same as the best one found so far - // then add it to the results. - else if (pos == highestPosition) - { - subset.Add(result); - } - } - - // If only one is found return it. - if (subset.Count == 1) - return subset[0]; - - // If there is an exact match return it. - if (highestPosition == userAgent.Length) - { -#if VER35 || VER4 - var res = subset.FirstOrDefault(i => i.Device.UserAgent == userAgent); - if (res != null) - { - return res; - } - } - -#else - foreach (Result result in subset) - if (result.Device.UserAgent == userAgent) - return result; - } -#endif - - // If there are more than 1 find the best one based on the end - // of the useragent strings. - if (subset.Count > 1) - return MatchTails(userAgent, highestPosition, subset); - return null; - } - - private static Result MatchTails(string userAgent, int pos, List results) - { - int longestSubset = 0; - Queue tails = new Queue(); - - // Get the tails of all the strings and add them to the queue. -#if VER4 || VER35 - foreach (string tail in - results.Select(i => - i.Device.UserAgent.Substring(pos, i.Device.UserAgent.Length - pos))) - { - tails.Enqueue(tail); - if (tail.Length > longestSubset) - longestSubset = tail.Length; - } -#else - foreach (Result res in results) - { - string tail = res.Device.UserAgent.Substring(pos, res.Device.UserAgent.Length - pos); - tails.Enqueue(tail); - if (tail.Length > longestSubset) - longestSubset = tail.Length; - } -#endif - // Get the longest part of the tail needed. - string userAgentTail = userAgent.Substring(pos, - longestSubset + pos < userAgent.Length - ? longestSubset - : userAgent.Length - pos); - - // Find the tail with the closest edit distance match. - string closestTail = null; - int minDistance = int.MaxValue; - int[][] rows = new int[][] { new int[userAgentTail.Length + 1], new int[userAgentTail.Length + 1] }; - while (tails.Count > 0) - { - string current = tails.Dequeue(); - int currentDistance = Algorithms.EditDistance(rows, userAgentTail, current, minDistance); - if (currentDistance < minDistance) - { - minDistance = currentDistance; - closestTail = current; - } - } - - // Find the 1st matching useragent and return. - Result result = null; -#if VER35 || VER4 - result = results.Find(i => - i.Device.UserAgent.EndsWith(closestTail)); -#else - foreach (Result res in results) - if (res.Device.UserAgent.EndsWith(closestTail)) - result = res; -#endif - if (result != null) - return result; - - // Give up and return the 1st element! - return results[0]; - } - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/Matcher.cs b/Foundation/Mobile/Detection/Matchers/Matcher.cs deleted file mode 100644 index c3ac603..0000000 --- a/Foundation/Mobile/Detection/Matchers/Matcher.cs +++ /dev/null @@ -1,17 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers -{ - internal abstract class Matcher - { - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/ReducedInitialString/Matcher.cs b/Foundation/Mobile/Detection/Matchers/ReducedInitialString/Matcher.cs deleted file mode 100644 index 9928abe..0000000 --- a/Foundation/Mobile/Detection/Matchers/ReducedInitialString/Matcher.cs +++ /dev/null @@ -1,72 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using FiftyOne.Foundation.Mobile.Detection.Handlers; - -#endregion - -#if VER4 -using System.Linq; -#endif - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers.ReducedInitialString -{ - internal class Matcher - { - /// - /// Uses a reduced initial string matching routine to determine the results. - /// - /// The useragent to be matched. - /// The handler performing the match. - /// The number of characters that need to be the same at the begining of the string for a match to have occurred. - /// All the devices that matched. - internal static Results Match(string userAgent, Handler handler, int tolerance) - { - BaseDeviceInfo bestMatch = null; - int maxInitialString = 0; - lock (handler.Devices) - { - foreach (BaseDeviceInfo[] devices in handler.Devices.Values) - { - foreach (BaseDeviceInfo device in devices) - { - Check(userAgent, ref bestMatch, ref maxInitialString, device); - } - } - } - return maxInitialString >= tolerance ? - new Results(bestMatch, handler, (uint)maxInitialString, userAgent) : - null; - } - - /// - /// Checks to see if the current device or the useragent string contain each - /// other at the start. - /// - /// The useragent being searched for. - /// Reference to the best matching device so far. - /// The maximum number of characters that have matched in the search so far. - /// The current device being checked for a match. - private static void Check(string userAgent, ref BaseDeviceInfo bestMatch, ref int maxInitialString, - BaseDeviceInfo current) - { - if ((userAgent.StartsWith(current.UserAgent) || - current.UserAgent.StartsWith(userAgent)) && - maxInitialString < current.UserAgent.Length) - { - maxInitialString = current.UserAgent.Length; - bestMatch = current; - } - } - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/Request.cs b/Foundation/Mobile/Detection/Matchers/Request.cs deleted file mode 100644 index bde2217..0000000 --- a/Foundation/Mobile/Detection/Matchers/Request.cs +++ /dev/null @@ -1,186 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Collections.Generic; -using System.Threading; -using FiftyOne.Foundation.Mobile.Detection.Handlers; -using System; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers -{ - internal abstract class Request - { - #region Classes - -#if VER4 - /// - /// A simple countdown singalling class derived for .NET 4. - /// Used to co-ordinate processing across multiple threads. - /// - internal class CountdownEvent : System.Threading.CountdownEvent - { - private static readonly int _count = Environment.ProcessorCount; - internal CountdownEvent() : base(_count) { } - } -#else - /// - /// A simple countdown singalling class. - /// Used to co-ordinate processing across multiple threads. - /// - internal class CountdownEvent - { - private static readonly int _count = Environment.ProcessorCount; - private int _remain; - private EventWaitHandle _event; - - internal CountdownEvent() - { - _remain = _count; - _event = new ManualResetEvent(false); - } - - internal int InitialCount - { - get { return _count; } - } - - internal void Signal() - { - // The last thread to signal also sets the event. - if (Interlocked.Decrement(ref _remain) == 0) - _event.Set(); - } - - /// - /// Blocks the current thread until the timeout has passed or - /// the object is signalled. - /// - /// - /// - internal bool Wait(int milliSeconds) - { - return _event.WaitOne(milliSeconds); - } - } -#endif - - #endregion - - #region Fields - - private readonly Handler _handler; - protected readonly CountdownEvent _completeEvent; - protected readonly Queue _queue; - protected readonly string _userAgent; - - #endregion - - #region Properties - - internal string UserAgent - { - get { return _userAgent; } - } - - internal virtual Handler Handler - { - get { return _handler; } - } - - internal int Count - { - get { return _queue.Count; } - } - - /// - /// Returns the number of threads - /// - internal int ThreadCount - { - get { return _completeEvent.InitialCount; } - } - - #endregion - - #region Constructors - - internal Request(string userAgent, Handler handler) - { - _userAgent = userAgent; - _queue = CreateQueue(handler); - _handler = handler; - _completeEvent = new CountdownEvent(); - } - - #endregion - - #region Methods - - /// - /// Waits until the time has elapsed, or the process has signaled complete. - /// - /// - /// - internal bool Wait(int millisecondsTimeout) - { - return _completeEvent.Wait(millisecondsTimeout); - } - - /// - /// Returns the next device in the queue to be checked. - /// - /// - internal BaseDeviceInfo Next() - { - lock (_queue) - if (_queue.Count > 0) - return _queue.Dequeue(); - return null; - } - - /// - /// Tells the waiting main thread that this worker thread has finished. - /// - internal void Complete() - { - _completeEvent.Signal(); - } - - /// - /// Takes a handler and returns a queue containing the userAgent strings. Ensures a - /// lock is obtained on the handler before creating the queue to avoid another thread - /// accessing or changing content at the same time. - /// - /// Handler containing devices. - /// A queue of devices. - private static Queue CreateQueue(Handler handler) - { - Queue queue = new Queue(handler.Devices.Count); - lock (handler.Devices) - { - foreach (BaseDeviceInfo[] devices in handler.Devices.Values) - { - foreach (BaseDeviceInfo device in devices) - { - queue.Enqueue(device); - } - } - } - return queue; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/Result.cs b/Foundation/Mobile/Detection/Matchers/Result.cs deleted file mode 100644 index 36ff976..0000000 --- a/Foundation/Mobile/Detection/Matchers/Result.cs +++ /dev/null @@ -1,304 +0,0 @@ -/* ********************************************************************* - * 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 System; -using FiftyOne.Foundation.Mobile.Detection.Handlers; -using System.Collections.Generic; - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers -{ - /// - /// Contains a device matched via a handler. - /// - public class Result : IComparable - { - private readonly Provider _provider; - private readonly BaseDeviceInfo _primaryDevice; - private BaseDeviceInfo _secondaryDevice; - private readonly Handler _handler; - private readonly uint _score; - private readonly string _userAgent; - private object _difference; - - internal Result(Provider provider, BaseDeviceInfo primaryDevice, Handler handler, uint score, string userAgent) - { - _provider = provider; - _primaryDevice = primaryDevice; - _handler = handler; - _score = score; - _userAgent = userAgent; - } - - internal Result(Provider provider, BaseDeviceInfo primaryDevice, BaseDeviceInfo secondaryDevice, Handler handler, uint score, string userAgent) - { - _provider = provider; - _primaryDevice = primaryDevice; - _secondaryDevice = secondaryDevice; - _handler = handler; - _score = score; - _userAgent = userAgent; - } - - #region Public Properties - - /// - /// The confidence of the result. - /// - public byte Confidence - { - get { return Difference == 0 ? byte.MaxValue : _handler.Confidence; } - } - - /// - /// The edit distant indicator for the result. - /// - public int Difference - { - get - { - if (_difference == null) - _difference = Algorithms.EditDistance(Device.UserAgent, _userAgent, int.MaxValue); - return (int)_difference; - } - } - - /// - /// The score for the result. - /// - public uint Score - { - get { return _score; } - } - - /// - /// The device found from the user agent provided by the requesting information. - /// - public BaseDeviceInfo Device - { - get { return _primaryDevice; } - } - - /// - /// The device found using the UserAgent header User-Agent. - /// - public BaseDeviceInfo DevicePrimary - { - get { return _primaryDevice; } - } - - /// - /// The device found using a secondary HTTP header. - /// See - /// - public BaseDeviceInfo DeviceSecondary - { - get { return _secondaryDevice; } - } - - /// - /// The handler used to obtain the result. - /// - public Handler Handler - { - get { return _handler; } - } - - #endregion - - #region Public Methods - - /// - /// Gets the first value for the property. - /// - /// Name of the property to be returned. - /// Value of the property. - public string GetFirstPropertyValue(string property) - { - int index = GetFirstPropertyValueStringIndex(_provider.Strings.Add(property)); - if (index >= 0) - return _provider.Strings.Get(index); - return null; - } - - /// - /// Returns a list of the string values for the property. - /// - /// Name of the property to be returned. - /// List of values for the property. - public List GetPropertyValues(string property) - { - int propertyStringIndex = _provider.Strings.Add(property); - List values = new List(); - List indexes = GetPropertyValueStringIndexes(propertyStringIndex); - if (indexes != null) - { - foreach (int index in indexes) - { - if (index >= 0) - values.Add(_provider.Strings.Get(index)); - } - } - else - { - // Check for any special values not held in - // the strings collection. - switch (property) - { - case Constants.DeviceId: values.Add( - _secondaryDevice == null ? - _primaryDevice.DeviceId : - _secondaryDevice.DeviceId); - break; - } - } - return values; - } - - /// - /// Returns a sorted list containing all the property values for the - /// the result. - /// - public SortedList> GetAllProperties() - { - SortedList> collection = new SortedList>(); - collection.Add(Constants.DeviceId, new List(new string[] { - _secondaryDevice == null ? - _primaryDevice.DeviceId : - _secondaryDevice.DeviceId })); -#if DEBUG - List handlerNames = new List(); - foreach (FiftyOne.Foundation.Mobile.Detection.Handlers.Handler handler in _provider.GetHandlers( - _secondaryDevice == null ? - _primaryDevice.UserAgent : - _secondaryDevice.UserAgent)) - handlerNames.Add(handler.Name); - collection.Add("Handlers", new List(new string[] { String.Join(", ", handlerNames.ToArray()) })); - collection.Add("UserAgent", new List(new string[] { - _secondaryDevice == null ? - _primaryDevice.UserAgent : - _secondaryDevice.UserAgent })); -#endif - AddProperties(collection); - return collection; - } - - #endregion - - #region Internal Methods - - /// - /// Sets the secondary device if one has been detected. - /// - /// - internal void SetSecondaryDevice(BaseDeviceInfo device) - { - _secondaryDevice = device; - } - - /// - /// Adds the device properties to the collection. - /// - /// Collection to have properties added to. - internal protected void AddProperties(SortedList> collection) - { - foreach (int propertyStringIndex in _provider.Properties.Keys) - { - string property = _provider.Strings.Get(propertyStringIndex); - if (Constants.ExcludePropertiesFromAllProperties.Contains(property) == false && - collection.ContainsKey(property) == false) - collection.Add( - property, - GetPropertyValues(propertyStringIndex)); - } - } - - /// - /// Gets the capability value index in the static Strings collection for this device - /// based on the index of the capability name. If this device does not have the - /// value then checks the parent if one exists. - /// - /// The string index of the property name. - /// Capability index value in the String collection, or null if the capability does not exist. - internal List GetPropertyValueStringIndexes(int propertyStringIndex) - { - return GetDeviceForProperty(propertyStringIndex).GetPropertyValueStringIndexes(propertyStringIndex); - } - - /// - /// Returns the string index of the first element in the collection. - /// - /// The string index of the property name. - /// Capability index value in the String collection, or -1 if the capability does not exist. - internal int GetFirstPropertyValueStringIndex(int propertyStringIndex) - { - return GetDeviceForProperty(propertyStringIndex).GetFirstPropertyValueStringIndex(propertyStringIndex); - } - - /// - /// Returns a list of the string values for the property index string provided. - /// - /// The string index of the property name. - /// A list of string values. - internal List GetPropertyValues(int propertyStringIndex) - { - return GetDeviceForProperty(propertyStringIndex).GetPropertyValues(propertyStringIndex); - } - - #endregion - - #region Private Methods - - /// - /// If there are two devices, both a primary and secondary device, - /// this method works out which one should be used to return the - /// property value. - /// - /// The string index of the property being sought. - /// The device that should be used to provide the property. - private BaseDeviceInfo GetDeviceForProperty(int propertyNameStringIndex) - { - if (_secondaryDevice != null) - { - Property property = null; - if (_provider.Properties.TryGetValue(propertyNameStringIndex, out property)) - { - switch(property.Component) - { - case Provider.Components.Hardware: - case Provider.Components.Software: - return _secondaryDevice; - default: - return _primaryDevice; - } - } - } - return _primaryDevice; - } - - #endregion - - #region IComparable Members - - /// - /// Compare this instance to another. - /// - /// Instance for comparison. - /// Zero if equal. 1 if higher or -1 if lower. - public int CompareTo(Result other) - { - if (Device == null && other.Device == null) - return 0; - return Device.DeviceId.CompareTo(other.Device.DeviceId); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/Results.cs b/Foundation/Mobile/Detection/Matchers/Results.cs deleted file mode 100644 index c9b0bc6..0000000 --- a/Foundation/Mobile/Detection/Matchers/Results.cs +++ /dev/null @@ -1,71 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Collections.Generic; -using FiftyOne.Foundation.Mobile.Detection.Handlers; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers -{ - /// - /// Represents all the results found for the detection. - /// - internal class Results : List - { - /// - /// Constructs an instance of the result class. - /// - internal Results() - { - } - - /// - /// Constructs an instance of the result class. - /// - /// Initial device to be added. - /// Handler to be associated with the device. - /// The score associated with the result. - /// The target user agent. - internal Results(BaseDeviceInfo device, Handler handler, uint score, string userAgent) - { - Add(device, handler, score, userAgent); - } - - /// - /// Adds a result to the result set. - /// - /// Initial device to be added. - /// Handler to be associated with the device. - /// The score associated with the result. - /// The target user agent. - internal void Add(BaseDeviceInfo device, Handler handler, uint score, string userAgent) - { - Add(new Result(device.Provider, device, handler, score, userAgent)); - } - - /// - /// Adds a range of devices to the results, all associated - /// with the handler provided. - /// - /// Array of all devices to be added. - /// Handler to be associated with the devices. - /// The score associated with the result. - /// The target user agent. - internal void AddRange(BaseDeviceInfo[] devices, Handler handler, uint score, string userAgent) - { - foreach (BaseDeviceInfo device in devices) - Add(device, handler, score, userAgent); - } - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/Segment/Matcher.cs b/Foundation/Mobile/Detection/Matchers/Segment/Matcher.cs deleted file mode 100644 index 7262bc8..0000000 --- a/Foundation/Mobile/Detection/Matchers/Segment/Matcher.cs +++ /dev/null @@ -1,158 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using FiftyOne.Foundation.Mobile.Detection.Handlers; -using System.Collections.Generic; -using System.Threading; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers.Segment -{ - internal class Matcher : Matchers.Matcher - { - internal static Results Match(string userAgent, - SegmentHandler handler) - { - if (handler.Devices.Count > 0) - { -#pragma warning disable 162 - if (Environment.ProcessorCount > 1 && - Detection.Constants.ForceSingleProcessor == false) - { - return MatchMultiProcessor(userAgent, handler); - } - else - { - return MatchSingleProcessor(userAgent, handler); - } -#pragma warning restore 162 - } - return null; - } - - private static Results MatchSingleProcessor(string userAgent, SegmentHandler handler) - { - // Create a segment matcher request. - Request request = new Request(userAgent, handler); - // Process the request. - ServiceRequest(request); - // Return the results. - return request.Results; - } - - private static Results MatchMultiProcessor(string userAgent, SegmentHandler handler) - { - // Create the request. - Request request = new Request(userAgent, handler); - if (request.Count > 0) - { - // For each thread add this to the queue. - for (int i = 0; i < request.ThreadCount; i++) - ThreadPool.QueueUserWorkItem(ServiceRequest, request); - - // Wait until a signal is received. Keeping coming back to - // this thread so that a request to close the request - // can be processed. - while (request.Wait(1) == false) - { - // Do nothing - } - } - // Return the results. - return request.Results; - } - - private static void ServiceRequest(object sender) - { - ServiceRequest((Request) sender); - } - - private static void ServiceRequest(Request request) - { - int index; - uint runningScore, score; - int[][] rows = new int[][] { new int[request.UserAgent.Length + 1], new int[request.UserAgent.Length + 1] }; - BaseDeviceInfo current = request.Next(); - while (current != null) - { - // Reset the counters. - runningScore = 0; - index = 0; - - while (index < request.Target.Count && - runningScore <= request.Results.LowestScore) - { - // Get the next segment for the comparision. - List compare = request.Handler.CreateSegments( - current, index); - - if (compare != null) - { - // If the two results are not equal in length so do not consider - // this useragent as a possible match. - if (request.Target[index].Count != compare.Count) - { - runningScore = uint.MaxValue; - break; - } - - // Work out the score for each of the returned segments. - for (int segmentIndex = 0; - segmentIndex < request.Target[index].Count; - segmentIndex++) - { - // If the two are equal then set to zero. - if (request.Target[index][segmentIndex].Value == compare[segmentIndex].Value) - score = 0; - else - score = (uint)Algorithms.EditDistance( - rows, - request.Target[index][segmentIndex].Value, - compare[segmentIndex].Value, - int.MaxValue) * - (uint)request.Target[index][segmentIndex].Weight; - - // Update the counters. - compare[segmentIndex].Score = score; - runningScore += score; - } - } - index++; - } - - if (runningScore <= request.Results.LowestScore) - { - lock (request.Results) - { - if (runningScore == request.Results.LowestScore) - { - request.Results.Add( - current, request.Handler, runningScore, request.UserAgent); - } - else if (runningScore < request.Results.LowestScore) - { - request.Results.LowestScore = runningScore; - request.Results.Clear(); - request.Results.Add( - current, request.Handler, runningScore, request.UserAgent); - } - } - } - current = request.Next(); - } - request.Complete(); - } - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/Segment/Request.cs b/Foundation/Mobile/Detection/Matchers/Segment/Request.cs deleted file mode 100644 index b7211cb..0000000 --- a/Foundation/Mobile/Detection/Matchers/Segment/Request.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Threading; -using FiftyOne.Foundation.Mobile.Detection.Handlers; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers.Segment -{ - internal class Request : Matchers.Request - { - #region Fields - - private readonly Results _results; - private readonly Segments _target; - - #endregion - - #region Properties - - internal Segments Target - { - get { return _target; } - } - - internal new SegmentHandler Handler - { - get { return (SegmentHandler) base.Handler; } - } - - internal Results Results - { - get { return _results; } - } - - #endregion - - #region Constructors - - internal Request(string userAgent, SegmentHandler handler) - : base(userAgent, handler) - { - _target = Handler.CreateAllSegments(userAgent); - _results = new Results(); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/Segment/Results.cs b/Foundation/Mobile/Detection/Matchers/Segment/Results.cs deleted file mode 100644 index b47f0cd..0000000 --- a/Foundation/Mobile/Detection/Matchers/Segment/Results.cs +++ /dev/null @@ -1,18 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers.Segment -{ - internal class Results : Matchers.Results - { - internal uint LowestScore = uint.MaxValue; - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/Segment/Segment.cs b/Foundation/Mobile/Detection/Matchers/Segment/Segment.cs deleted file mode 100644 index 6124c65..0000000 --- a/Foundation/Mobile/Detection/Matchers/Segment/Segment.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers.Segment -{ - internal class Segment - { - private bool _isValid; - private uint _score; - private int _weight; - private string _value; - - internal string Value - { - get { return _value; } - } - - internal int Weight - { - get { return _weight; } - } - - internal Segment(string value, int weight) - { - _value = value; - _weight = weight; - } - - internal uint Score - { - get { return _score; } - set - { - _score = value; - _isValid = true; - } - } - - internal bool IsValid - { - get { return _isValid; } - } - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Matchers/Segment/Segments.cs b/Foundation/Mobile/Detection/Matchers/Segment/Segments.cs deleted file mode 100644 index f710197..0000000 --- a/Foundation/Mobile/Detection/Matchers/Segment/Segments.cs +++ /dev/null @@ -1,23 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Collections.Generic; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Matchers.Segment -{ - internal class Segments : List> - { - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/MobileCapabilities.cs b/Foundation/Mobile/Detection/MobileCapabilities.cs deleted file mode 100644 index 022e296..0000000 --- a/Foundation/Mobile/Detection/MobileCapabilities.cs +++ /dev/null @@ -1,778 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Text.RegularExpressions; -using FiftyOne.Foundation.Mobile.Detection.Matchers; - -#if VER4 - -using System.Linq; - - -#endif - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Enhanced mobile capabilities assigned to mobile devices. - /// - internal class MobileCapabilities - { - #region String Index Values - - // Gets the indexes of all the key capability strings as static readonly - // values during static construction to avoid needing to look them up every time. - private readonly int AjaxRequestType; - private readonly int AjaxRequestTypeNotSupported; - private readonly int Javascript; - private readonly int JavascriptVersion; - private readonly int CookiesCapable; - private readonly int BrowserVersion; - private readonly int BrowserName; - private readonly int PlatformName; - private readonly int Adapters; - private readonly int ScreenPixelsHeight; - private readonly int ScreenPixelsWidth; - private readonly int BitsPerPixel; - private readonly int HardwareName; - private readonly int HardwareModel; - private readonly int HardwareVendor; - private readonly int HtmlVersion; - private readonly int IsMobile; - private readonly int[] True = new int[2]; - private readonly int[] False = new int[2]; - private readonly int IsCrawler; - private readonly int CcppAccept; - private readonly int[] ImagePng; - private readonly int[] ImageJpeg; - private readonly int[] ImageGif; - private readonly int XHtmlVersion; - private readonly int TablesCapable; - - #endregion - - #region Fields - - /// - /// Instance of the provider to use with this class. - /// - private Provider _provider = null; - - #endregion - - #region Properties - - /// - /// Returns the instance of the provider being used. - /// - internal Provider Provider - { - get { return _provider; } - } - - #endregion - - #region Constructor - - /// - /// Constructs a new instance of . - /// - /// Data provider to use with this capabilities provider. - internal MobileCapabilities(Provider provider) - { - _provider = provider; - True[0] = _provider.Strings.Add("True"); - True[1] = _provider.Strings.Add("true"); - False[0] = _provider.Strings.Add("False"); - False[1] = _provider.Strings.Add("false"); - AjaxRequestType = _provider.Strings.Add("AjaxRequestType"); - AjaxRequestTypeNotSupported = _provider.Strings.Add("AjaxRequestTypeNotSupported"); - Javascript = _provider.Strings.Add("Javascript"); - JavascriptVersion = _provider.Strings.Add("JavascriptVersion"); - CookiesCapable = _provider.Strings.Add("CookiesCapable"); - BrowserVersion = _provider.Strings.Add("BrowserVersion"); - BrowserName = _provider.Strings.Add("BrowserName"); - PlatformName = _provider.Strings.Add("PlatformName"); - Adapters = _provider.Strings.Add("Adapters"); - ScreenPixelsHeight = _provider.Strings.Add("ScreenPixelsHeight"); - ScreenPixelsWidth = _provider.Strings.Add("ScreenPixelsWidth"); - BitsPerPixel = _provider.Strings.Add("BitsPerPixel"); - HardwareName = _provider.Strings.Add("HardwareName"); - HardwareModel = _provider.Strings.Add("HardwareModel"); - HardwareVendor = _provider.Strings.Add("HardwareVendor"); - HtmlVersion = _provider.Strings.Add("HtmlVersion"); - XHtmlVersion = _provider.Strings.Add("XHtmlVersion"); - IsMobile = _provider.Strings.Add("IsMobile"); - IsCrawler = _provider.Strings.Add("IsCrawler"); - TablesCapable = _provider.Strings.Add("TablesCapable"); - CcppAccept = _provider.Strings.Add("CcppAccept"); - ImageGif = new int[] { - _provider.Strings.Add("image/gif") }; - ImagePng = new int[] { - _provider.Strings.Add("image/png") }; - ImageJpeg = new int[] { - _provider.Strings.Add("image/jpeg"), - _provider.Strings.Add("image/jpg") }; - } - - #endregion - - #region Create Methods - - /// - /// Creates a dictionary of capabilites for the requesting device. - /// - /// A collection of Http headers from the device. - /// The current capabilities assigned by .NET. - /// A dictionary of capabilities for the request. - internal IDictionary Create(NameValueCollection headers, IDictionary currentCapabilities) - { - // Use the base class to create the initial list of capabilities. - IDictionary capabilities = new Hashtable(); - - // Get the device. - int start = Environment.TickCount; - Result result = _provider.GetResult(headers); - int detectionTime = Environment.TickCount - start + 1; - - // Add the capabilities for the device. - Create(result, capabilities, currentCapabilities); - - if (capabilities[Constants.FiftyOneDegreesProperties] is SortedList>) - { - // Add the detection time to the list of properties. - ((SortedList>)capabilities[Constants.FiftyOneDegreesProperties]) - .Add(Constants.DetectionTimeProperty, - new List(new string[] { - detectionTime.ToString() - })); - - // Add the handler confidence to the list of properties. - ((SortedList>)capabilities[Constants.FiftyOneDegreesProperties]) - .Add(Constants.ConfidenceProperty, - new List(new string[] { - result.Confidence.ToString() - })); - - // Add the difference to the list of properties. - ((SortedList>)capabilities[Constants.FiftyOneDegreesProperties]) - .Add(Constants.DifferenceProperty, - new List(new string[] { - String.Format( - "{0:#.###}", - result.Difference) - })); - } - - // Initialise any capability values that rely on the settings - // from the device data source. - Init(capabilities); - - return capabilities; - } - - /// - /// Creates a dictionary of capabilites for the useragent string. - /// - /// The useragent string associated with the device. - /// A dictionary of capabilities for the request. - internal IDictionary Create(string userAgent) - { - // Create the mobile capabilities hashtable. - IDictionary capabilities = new Hashtable(); - - // As we can't tell from the headers if javascript is supported assume - // it can be and that the inheriting class will provide the additional details. - SetJavaScript(capabilities, true); - - // Set the headers and return the new capabilities collection. - NameValueCollection headers = new NameValueCollection(); - headers.Add("User-Agent", userAgent); - return Create(headers, capabilities); - } - - #endregion - - #region Virtual Methods - - /// - /// Initialises the IDictionary of capabilities. - /// - protected virtual void Init(IDictionary capabilities) - { - // Set the tagwriter. - capabilities["tagwriter"] = GetTagWriter(capabilities); - } - - #endregion - - #region Private Methods - - private void Create(Result result, IDictionary properties, IDictionary currentProperties) - { - // Enhance with the capabilities from the device data. - if (result != null) - { - - // Enhance the default capabilities collection based on the device. - Enhance(properties, currentProperties, result); - - // Add the 51Degrees.mobi device properties to the collection. - properties.Add(Constants.FiftyOneDegreesProperties, result.GetAllProperties()); - - // If an adapters patch file has been loaded then include this - // capability in the exposed list of capabilities. - string adapters = GetAdapters(result); - if (String.IsNullOrEmpty(adapters) == false) - SetValue(properties, "adapters", adapters); - } - } - - /// - /// Sets static capabilities used by mobile controls. - /// - /// Dictionary of capabilities to be changed. - private static void SetStaticValues(IDictionary capabilities) - { - SetValue(capabilities, "requiresSpecialViewStateEncoding", "true"); - SetValue(capabilities, "requiresUniqueFilePathSuffix", "true"); - SetValue(capabilities, "requiresUniqueHtmlCheckboxNames", "true"); - SetValue(capabilities, "requiresUniqueHtmlInputNames", "true"); - SetValue(capabilities, "requiresUrlEncodedPostfieldValues", "true"); - SetValue(capabilities, "requiresOutputOptimization", "true"); - SetValue(capabilities, "requiresControlStateInSession", "true"); - } - - /// - /// Updates the capabilities used by Microsoft's implementation of the - /// HttpBrowserCapabilities class to control the property values it - /// returns. Only properties exposed by FiftyOneBrowserCapabilities are overriden - /// by this method. - /// - /// Dictionary of capabilities to be enhanced. - /// Dictionary of existing capabilities for the device. - /// The match result to use for the enhancement. - private void Enhance(IDictionary capabilities, IDictionary currentCapabilities, Result result) - { - // Set base capabilities for all mobile devices. - SetStaticValues(capabilities); - - SetValue(capabilities, "isMobileDevice", GetIsMobileDevice(result)); - SetValue(capabilities, "crawler", GetIsCrawler(result)); - SetValue(capabilities, "mobileDeviceModel", GetMobileDeviceModel(result)); - SetValue(capabilities, "mobileDeviceManufacturer", GetMobileDeviceManufacturer(result)); - SetValue(capabilities, "platform", GetPlatform(result)); - // property enhancement can be removed with this compiler flag -#if !REMOVE_OVERRIDE_BROWSER - SetValue(capabilities, "browser", GetBrowser(result)); -#endif - SetValue(capabilities, "type", capabilities["mobileDeviceManufacturer"]); - SetValue(capabilities, "screenPixelsHeight", GetScreenPixelsHeight(result) ?? - GetDefaultValue("screenPixelsHeight", currentCapabilities)); - SetValue(capabilities, "screenPixelsWidth", GetScreenPixelsWidth(result) ?? - GetDefaultValue("screenPixelsWidth", currentCapabilities)); - SetValue(capabilities, "screenBitDepth", GetBitsPerPixel(result)); - SetValue(capabilities, "preferredImageMime", GetPreferredImageMime(result)); - SetValue(capabilities, "isColor", GetIsColor(result)); - SetValue(capabilities, "supportsCallback", GetSupportsCallback(result)); - SetValue(capabilities, "SupportsCallback", GetSupportsCallback(result)); - SetValue(capabilities, "canInitiateVoiceCall", GetIsMobileDevice(result)); - SetValue(capabilities, "jscriptversion", GetJavascriptVersion(result)); - - // The following values are set to prevent exceptions being thrown in - // the standard .NET base classes if the property is accessed. - SetValue(capabilities, "screenCharactersHeight", - GetDefaultValue("screenCharactersHeight", currentCapabilities)); - SetValue(capabilities, "screenCharactersWidth", - GetDefaultValue("screenCharactersWidth", currentCapabilities)); - - // Use the Version class to find the version. If this fails use the 1st two - // decimal segments of the string. - string versionString = _provider.Strings.Get(result.GetFirstPropertyValueStringIndex(BrowserVersion)); - if (String.IsNullOrEmpty(versionString) == false) - { - try - { - Version version = new Version(versionString); - SetValue(capabilities, "majorversion", version.Major.ToString()); - SetValue(capabilities, "minorversion", String.Format(".{0}", version.Minor)); - SetValue(capabilities, "version", version.ToString()); - } - catch (FormatException) - { - SetVersion(capabilities, versionString); - } - catch (ArgumentException) - { - SetVersion(capabilities, versionString); - } - } - else - { - // Transfer the current version capabilities to the new capabilities. - SetValue(capabilities, "majorversion", currentCapabilities != null ? currentCapabilities["majorversion"] : null); - SetValue(capabilities, "minorversion", currentCapabilities != null ? currentCapabilities["minorversion"] : null); - SetValue(capabilities, "version", currentCapabilities != null ? currentCapabilities["version"] : null); - - // Ensure the version values are not null to prevent null arguement exceptions - // with some controls. - versionString = currentCapabilities != null ? currentCapabilities["version"] as string : "0.0"; - SetVersion(capabilities, versionString); - } - - // All we can determine from the device database is if javascript is supported as a boolean. - // If the value is not provided then null is returned and the capabilities won't be altered. - object javaScript = GetJavascriptSupport(result); - if (javaScript is bool) - { - SetJavaScript(capabilities, (bool)javaScript); - SetValue(capabilities, "ecmascriptversion", - (bool)javaScript ? "3.0" : "0.0"); - } - - // Sets the W3C DOM version. - SetValue(capabilities, "w3cdomversion", - GetW3CDOMVersion(result, - currentCapabilities != null - ? (string)currentCapabilities["w3cdomversion"] - : String.Empty)); - - // Update the cookies value if we have additional information. - SetValue(capabilities, "cookies", - GetCookieSupport(result, - currentCapabilities != null - ? (string)currentCapabilities["cookies"] - : String.Empty)); - - // Only set these values from 51Degrees.mobi if they've not already been set from - // the Http request header, or the .NET solution. - if (capabilities.Contains("preferredRenderingType") == false) - { - // Set the rendering type for the response. - SetValue(capabilities, "preferredRenderingType", GetPreferredHtmlVersion(result)); - - // Set the Mime type of the response. - SetValue(capabilities, "preferredRenderingMime", "text/html"); - } - } - - /// - /// Returns true if the device supports tables. - /// - /// The match result for the current request. - /// - private object GetTablesCapable(Result result) - { - int value = result.GetFirstPropertyValueStringIndex(TablesCapable); - if (value < 0) - return null; - - if (value == this.True[0] || value == this.True[1]) - return bool.TrueString.ToLowerInvariant(); - return bool.FalseString.ToLowerInvariant(); - } - - private string GetPreferredHtmlVersion(Result result) - { - // Working out ASP.NET will support HTML5. Return 4 for the moment. - return "html4"; - - /* - - // Get the list of values. - var values = new List(); - var versions = device.GetPropertyValueStringIndexes(HtmlVersion); - if (versions != null) - { - foreach (var index in versions) - { - double value; - if (double.TryParse(_provider.Strings.Get(index), out value)) - values.Add(value); - } - } - values.Sort(); - values.Reverse(); - - // Find the highest version of HTML supported. - foreach(double value in values) - { - switch (value.ToString()) - { - default: - case "4": - return "html4"; - case "3.2": - return "html32"; - case "5": - return "html5"; - } - } - - // Couldn't find anything return html 4. - return "html4"; - */ - } - - /// - /// Sets the version using a regular expression to find numeric segments of - /// the provided version string. If the version already exists in the - /// new dictionary of capabilities a new value will not be written. - /// - /// - /// - private static void SetVersion(IDictionary capabilities, string version) - { - if (version != null) - { - MatchCollection segments = Regex.Matches(version, @"\d+"); - string majorVersion = segments.Count > 0 ? segments[0].Value : "0"; - string minorVersion = segments.Count > 1 ? segments[1].Value : "0"; - if (String.IsNullOrEmpty(capabilities["majorversion"] as string)) - SetValue(capabilities, "majorversion", majorVersion); - if (String.IsNullOrEmpty(capabilities["minorversion"] as string)) - SetValue(capabilities, "minorversion", minorVersion); - if (String.IsNullOrEmpty(capabilities["version"] as string)) - SetValue(capabilities, "version", String.Format("{0}.{1}", majorVersion, minorVersion)); - } - } - - private string GetCookieSupport(Result result, string current) - { - bool value = false; - // Return either the capability or the current value as a boolean string. - if (bool.TryParse(_provider.Strings.Get(result.GetFirstPropertyValueStringIndex(CookiesCapable)), out value) == false) - bool.TryParse(current, out value); - return value.ToString(); - } - - /// - /// Returns true if the device supports callbacks from the browser. - /// - /// The match result for the current request. - /// True if callback is supported. - private string GetSupportsCallback(Result result) - { - List values = result.GetPropertyValueStringIndexes(AjaxRequestType); - if (values != null && values.Contains(AjaxRequestTypeNotSupported)) - return bool.FalseString.ToLowerInvariant(); - return bool.TrueString.ToLowerInvariant(); - } - - /// - /// Returns version 1.0 if DOM is supported based on Ajax - /// being supported, otherwise returns false. - /// - /// The match result for the current request. - /// The current value of the property. - /// 1.0, 0.0 or the current value. - private string GetW3CDOMVersion(Result result, string current) - { - Version version = new Version(0, 0); - - // Set the version to the current version. - try - { - version = new Version(current); - } - catch (ArgumentException) - { - // Do nothing and let the default value be returned. - } - - // Try and set version 1.0 if ajax is supported. - List values = result.GetPropertyValueStringIndexes(AjaxRequestType); - if (values != null && values.Contains(AjaxRequestTypeNotSupported) == false) - version = new Version("2.0.0.0"); - - return version.ToString(2); - } - - /// - /// If the device indicates javascript support then return true. - /// - /// The match result for the current request. - /// True if javascript is supported. - private object GetJavascriptSupport(Result result) - { - int value = result.GetFirstPropertyValueStringIndex(Javascript); - if (value < 0) - return null; - return value == this.True[0] || value == this.True[1]; - } - - /// - /// Get the javascript version or null if not provided or invalid. - /// - /// The match result for the current request. - /// - private string GetJavascriptVersion(Result result) - { - int index = result.GetFirstPropertyValueStringIndex(JavascriptVersion); - if (index < 0) - return null; - - string value = _provider.Strings.Get(index); - - // Check if the version value is valid in the version - // class. If not then return null. -#if VER4 - Version version; - if (Version.TryParse(value, out version)) - return value; - return null; -#else - try - { - new Version(value); - return value; - } - catch - { - return null; - } -#endif - } - - private string GetPlatform(Result result) - { - return _provider.Strings.Get(result.GetFirstPropertyValueStringIndex(PlatformName)); - } - - private string GetBrowser(Result result) - { - return _provider.Strings.Get(result.GetFirstPropertyValueStringIndex(BrowserName)); - } - - /// - /// If the data set does not contain the IsCrawler property null is returned. - /// If it is present and contains the value true or false then a value - /// is returned. - /// - /// The match result for the current request. - /// - private string GetIsCrawler(Result result) - { - int value = result.GetFirstPropertyValueStringIndex(IsCrawler); - if (value == this.True[0] || value == this.True[1]) - return bool.TrueString.ToLowerInvariant(); - if (value == this.False[0] || value == this.False[1]) - return bool.FalseString.ToLowerInvariant(); - return null; - } - - private string GetAdapters(Result result) - { - return _provider.Strings.Get(result.GetFirstPropertyValueStringIndex(Adapters)); - } - - private string GetIsMobileDevice(Result result) - { - int value = result.GetFirstPropertyValueStringIndex(IsMobile); - if (value == this.True[0] || value == this.True[1]) - return bool.TrueString.ToLowerInvariant(); - return bool.FalseString.ToLowerInvariant(); - } - - private string GetScreenPixelsHeight(Result result) - { - int size; - string value = _provider.Strings.Get(result.GetFirstPropertyValueStringIndex(ScreenPixelsHeight)); - if (int.TryParse(value, out size)) - return value; - return null; - } - - private string GetScreenPixelsWidth(Result result) - { - int size; - string value = _provider.Strings.Get(result.GetFirstPropertyValueStringIndex(ScreenPixelsWidth)); - if (int.TryParse(value, out size)) - return value; - return null; - } - - private string GetIsColor(Result result) - { - long bitsPerPixel = GetBitsPerPixel(result); - if (bitsPerPixel >= 4) - return bool.TrueString.ToLowerInvariant(); - return bool.FalseString.ToLowerInvariant(); - } - - private string GetMobileDeviceModel(Result result) - { - string value = _provider.Strings.Get(result.GetFirstPropertyValueStringIndex(HardwareModel)); - if (String.IsNullOrEmpty(value)) - value = _provider.Strings.Get(result.GetFirstPropertyValueStringIndex(HardwareName)); - return value; - } - - private string GetMobileDeviceManufacturer(Result result) - { - return _provider.Strings.Get(result.GetFirstPropertyValueStringIndex(HardwareVendor)); - } - - private string GetPreferredImageMime(Result result) - { - List mimeTypes = result.GetPropertyValueStringIndexes(CcppAccept); - // Look at the database and return the 1st one that matches in order - // of preference. - if (Contains(mimeTypes, ImagePng)) - return "image/png"; - if (Contains(mimeTypes, ImageJpeg)) - return "image/jpeg"; - if (Contains(mimeTypes, ImageGif)) - return "image/gif"; - return null; - } - - /// - /// Compares two lists to see if they contain at least one value that is the same. - /// - /// - /// - /// - private static bool Contains(IList list1, IList list2) - { - if (list1 == null || list2 == null) - return false; - - foreach (int a in list1) - foreach (int b in list2) - if (a == b) - return true; - return false; - } - - /// - /// Returns the number of bits per pixel as a long, or 16 if not found. - /// - /// The match result for the current request. - /// - private long GetBitsPerPixel(Result result) - { - long bitsPerPixel = 1; - if (long.TryParse( - _provider.Strings.Get(result.GetFirstPropertyValueStringIndex(BitsPerPixel)), - out bitsPerPixel)) - return bitsPerPixel; - return 16; - } - - #endregion - - #region Static Methods - - /// - /// Returns the current capabilities value if it exists, otherwise - /// uses the provided default values. - /// - /// The property key to be returned. - /// The current capabilities found by .NET. - /// A default value. - protected static string GetDefaultValue(string key, IDictionary currentCapabilities) - { - string currentValue = currentCapabilities[key] as string; - if (currentValue != null) - return currentValue; - return GetDefaultValue(key); - } - - /// - /// Returns the default value for the key to use if one can not be - /// found. - /// - /// The property key to be returned. - /// The hardcoded default value. - protected static string GetDefaultValue(string key) - { - for (int i = 0; i < Constants.DefaultPropertyValues.Length; i++) - if (Constants.DefaultPropertyValues[i, 0] == key) - return Constants.DefaultPropertyValues[i, 1]; - return null; - } - - /// - /// Sets the javascript boolean string in the capabilities dictionary. - /// - /// Capabilities dictionary. - /// The value of the jaavscript keys. - protected static void SetJavaScript(IDictionary capabilities, bool javaScript) - { - SetValue(capabilities, "javascript", javaScript.ToString().ToLowerInvariant()); - SetValue(capabilities, "Javascript", javaScript.ToString().ToLowerInvariant()); - } - - /// - /// Sets the key in the capabilities dictionary to the object provided. If the key - /// already exists the previous value is replaced. If not a new entry is added - /// to the Dictionary. - /// - /// Dictionary of capabilities to be changed. - /// Key to be changed or added. - /// New entry value. - internal static void SetValue(IDictionary capabilities, string key, object value) - { - // Ignore new values that are empty strings. - if (value == null || - String.IsNullOrEmpty(value as string)) - return; - - // Change or add the new capability. - if (capabilities.Contains(key) == false) - { - capabilities.Add(key, value); - } - else - { - capabilities[key] = value; - } - } - - /// - /// Returns the class to use as a text writer for the output stream. - /// - /// Dictionary of device capabilities. - /// A string containing the text writer class name. - private static string GetTagWriter(IDictionary capabilities) - { - switch (capabilities["preferredRenderingType"] as string) - { - case "xhtml-mp": - case "xhtml-basic": - return "System.Web.UI.XhtmlTextWriter"; - - case "chtml10": - return "System.Web.UI.ChtmlTextWriter"; - - case "html4": - return "System.Web.UI.HtmlTextWriter"; - - case "html32": - return "System.Web.UI.Html32TextWriter"; - - default: - return "System.Web.UI.Html32TextWriter"; - } - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/MobileCapabilitiesProvider.cs b/Foundation/Mobile/Detection/MobileCapabilitiesProvider.cs deleted file mode 100644 index b54812e..0000000 --- a/Foundation/Mobile/Detection/MobileCapabilitiesProvider.cs +++ /dev/null @@ -1,121 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#if VER4 - -using System; -using System.Collections; -using System.Web; -using System.Web.Configuration; -using System.Diagnostics; -using System.Text; - -namespace FiftyOne.Foundation.Mobile.Detection -{ - - /// - /// Used to add additional 51Degrees.mobi based properties to the browser capabilities. - /// - public class MobileCapabilitiesProvider : HttpCapabilitiesDefaultProvider - { - private HttpCapabilitiesDefaultProvider _parent = null; - - /// - /// Constructs an instance of . - /// Sets the cache key length to a value of 256 to allow for mobile - /// useragents that can often be longer than the default 64 characters. - /// - public MobileCapabilitiesProvider() - : base() - { - EventLog.Debug("Constructing MobileCapabilitiesProvider - Default"); -#if DEBUG - LogStackTrace(); -#endif - base.UserAgentCacheKeyLength = 256; - } - - /// - /// Constructs an instance of . - /// Sets the cache key length to a value of 256 to allow for mobile - /// useragents that can often be longer than the default 64 characters. - /// - public MobileCapabilitiesProvider(HttpCapabilitiesDefaultProvider parent) - : base(parent) - { - EventLog.Debug("Constructing MobileCapabilitiesProvider - HttpCapabilitiesDefaultProvider"); -#if DEBUG - LogStackTrace(); -#endif - _parent = parent; - base.UserAgentCacheKeyLength = 256; - } - - // If in debug compilation record the stake trace as this class is constructed - // before the debugger can become active. -#if DEBUG - private void LogStackTrace() - { - StringBuilder trace = new StringBuilder().AppendLine("Constructor Stack Trace:"); - foreach (StackFrame frame in new StackTrace().GetFrames()) - trace.AppendLine(frame.ToString()); - EventLog.Debug(trace.ToString()); - } -#endif - - /// - /// Provides information to the web server about the requesting device. - /// - /// An HttpRequest that provides information about the source device. - /// A HttpBrowserCapabilities object containing information relevent to the device - /// sources from 51Degrees.mobi. - public override HttpBrowserCapabilities GetBrowserCapabilities(HttpRequest request) - { - // Get the base capabilities. - System.Web.HttpBrowserCapabilities baseCapabilities = GetBaseCapabilities(request); - - // Get the new and overridden capabilities. - IDictionary overrideCapabilities = Create(request, baseCapabilities.Capabilities); - - if (overrideCapabilities != null) - // Create a new browser capabilities instance combining the two. - return new FiftyOneBrowserCapabilities(baseCapabilities, overrideCapabilities); - - // We couldn't get any new values so return the current ones unaltered. - return baseCapabilities; - } - - /// - /// Returns the .NET base browser capabilities. - /// - /// An HttpRequest that provides information about the source device. - /// .NET base browser capabilities - protected virtual System.Web.HttpBrowserCapabilities GetBaseCapabilities(HttpRequest request) - { - return - _parent == null - ? base.GetBrowserCapabilities(request) - : _parent.GetBrowserCapabilities(request); - } - - /// - /// Create the new capabilities for the request. - /// - /// An HttpRequest that provides information about the source device. - /// Current capabilities for the request. - /// A new list of capabilities. - protected virtual IDictionary Create(HttpRequest request, IDictionary capabilities) - { - return Factory.Create(request, capabilities); - } - } -} -#endif diff --git a/Foundation/Mobile/Detection/NewDevice.cs b/Foundation/Mobile/Detection/NewDevice.cs deleted file mode 100644 index 59df4c4..0000000 --- a/Foundation/Mobile/Detection/NewDevice.cs +++ /dev/null @@ -1,343 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Net; -using System.Net.Cache; -using System.Security; -using System.Text; -using System.Threading; -using System.Web; -using System.Xml; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Class used to record new device details. - /// - internal class NewDevice : IDisposable - { - #region Fields - - // Can be set to false if an exception occurs. - private static bool _enabled = true; - - // The number of times a timeout occured. - private static int _timeoutCount = 0; - - // Used to stop the thread. - private bool _stop = false; - - private readonly Uri _newDevicesUrl; - private readonly NewDeviceDetails _newDeviceDetail; - private readonly Queue _queue; - private readonly Thread _thread; - private readonly AutoResetEvent _wait; - - #endregion - - #region Constructor - - /// - /// Sets the enabled state of the class. - /// - internal NewDevice(string newDevicesUrl, NewDeviceDetails newDeviceDetail) - { -#if DEBUG - EventLog.Debug("Constructing NewDevice Instance"); -#endif - if (_enabled && - Configuration.Manager.ShareUsage && - Uri.TryCreate(newDevicesUrl, UriKind.RelativeOrAbsolute, out _newDevicesUrl)) - { - _newDeviceDetail = newDeviceDetail; - _queue = new Queue(); - _wait = new AutoResetEvent(false); - _thread = new Thread(Run); - _thread.Priority = ThreadPriority.Lowest; - _thread.IsBackground = true; - _thread.Start(); - } - else - { -#if DEBUG - EventLog.Debug("Disabling NewDevice Instance"); -#endif - _enabled = false; - } - } - - #endregion - - #region Dispose Method - - /// - /// Disposes of the queue and ensures everything is shutdown. - /// - public void Dispose() - { - if (_thread != null && _thread.ThreadState != ThreadState.Stopped) - { -#if DEBUG - EventLog.Debug("Disposing NewDevice Instance"); -#endif - _stop = true; - _wait.Set(); - _thread.Join(); - } - } - - #endregion - - #region Properties - - /// - /// Returns if the new device recording functionality is enabled. - /// - internal bool Enabled - { - get { return _enabled; } - } - - #endregion - - #region Methods - - /// - /// Adds the request details to the queue for processing - /// by the background thread. - /// - /// The request used to indentify the new device. - internal void RecordNewDevice(HttpRequest request) - { - // Get the new device details. - byte[] data = GetContent(request, _newDeviceDetail); - - if (data != null && data.Length > 0) - { - // Add the new details to the queue for later processing. - _queue.Enqueue(data); - - // Signal the background thread to check to see if it should - // send queued data. - _wait.Set(); - } - } - - /// - /// Provides the xml writer settings. - /// - /// - private static XmlWriterSettings GetXmlSettings() - { - XmlWriterSettings settings = new XmlWriterSettings(); - settings.OmitXmlDeclaration = false; - settings.ConformanceLevel = ConformanceLevel.Document; - settings.Encoding = Encoding.UTF8; - settings.CheckCharacters = true; - settings.NewLineHandling = NewLineHandling.None; - settings.CloseOutput = true; - return settings; - } - - /// - /// Sends all the data on the queue. - /// - private void SendData(Stream stream) - { - using (GZipStream compressed = new GZipStream(stream, CompressionMode.Compress)) - { - using (XmlWriter writer = XmlWriter.Create(compressed, GetXmlSettings())) - { - writer.WriteStartDocument(); - writer.WriteStartElement("Devices"); - while (_queue.Count > 0) - { - byte[] item = _queue.Dequeue(); - if (item != null && item.Length > 0) - writer.WriteRaw( - ASCIIEncoding.UTF8.GetString( - item)); - } - writer.WriteEndElement(); - writer.WriteEndDocument(); - } - } - } - - private void Run(object state) - { - do - { - try - { - // Wait for something to happen. - _wait.WaitOne(-1); - - // If there are enough items in the queue, or the thread is being - // stopped send the data. - if (_queue.Count >= Constants.NewDeviceQueueLength || - (_stop == true && _queue.Count > 0)) - { -#if DEBUG - EventLog.Debug("Sending NewDevice Queue"); -#endif - // Prepare the request including all currently queued items. - HttpWebRequest request = WebRequest.Create(_newDevicesUrl) as HttpWebRequest; - request.ReadWriteTimeout = Constants.NewUrlTimeOut; - request.Method = "POST"; - request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); - request.ContentType = "text/xml"; - request.Headers.Add(HttpRequestHeader.ContentEncoding, "gzip"); - SendData(request.GetRequestStream()); - - // Get the response and record the content if it's valid. If it's - // not valid consider turning off the functionality. - HttpWebResponse response = request.GetResponse() as HttpWebResponse; - if (response != null) - { - switch (response.StatusCode) - { - case HttpStatusCode.OK: - using (StreamReader reader = new StreamReader(response.GetResponseStream())) - { - string content = reader.ReadToEnd(); -#if DEBUG - EventLog.Debug(content); -#endif - } - - // Reset the timeout counter. - _timeoutCount = 0; - break; - case HttpStatusCode.RequestTimeout: - // Could be temporary, increase the count. - _timeoutCount++; - - // If more than X timeouts have occured disable the - // feature. - if (_timeoutCount > Constants.NewUrlMaxTimeouts) - { - EventLog.Debug( - String.Format( - "Stopping usage sharing as remote name '{0}' timeout count exceeded '{1}'.", - _newDevicesUrl, - Constants.NewUrlMaxTimeouts)); - _enabled = false; - _stop = true; - } - break; - default: - // Turn off functionality. - EventLog.Debug( - String.Format( - "Stopping usage sharing as remote name '{0}' returned status description '{1}'.", - _newDevicesUrl, response.StatusDescription)); - _enabled = false; - _stop = true; - break; - } - } - - // Release the HttpWebResponse - response.Close(); - } - } - catch (Exception ex) { HandleException(ex); } - } while (_stop == false); -#if DEBUG - EventLog.Debug("Finished NewDevice Thread"); -#endif - } - - private void HandleException(Exception ex) - { - if (ex is SecurityException) - { - EventLog.Debug( - String.Format( - "Stopping usage sharing as insufficient permission to send device information to '{0}'.", - _newDevicesUrl)); - _enabled = false; - _stop = true; - } - else if (ex is WebException) - { - try - { - if (ex.Message.StartsWith("The remote name could not be resolved:")) - { - EventLog.Debug( - String.Format( - "Stopping usage sharing as remote name '{0}' could not be resolved.", - _newDevicesUrl)); - _enabled = false; - _stop = true; - } - if (ex.Message.StartsWith("The remote server returned an error:")) - { - EventLog.Debug( - String.Format( - "Stopping usage sharing as call to '{0}' returned exception '{1}'.", - _newDevicesUrl, ex.Message)); - _enabled = false; - _stop = true; - } - else - { - EventLog.Debug( - String.Format( - "Could not write device information to URL '{0}'. Exception '{1}'", - _newDevicesUrl, ex.Message)); - } - } - catch - { - // Do nothing as there is nothing we can do. - } - } - else - { - EventLog.Debug(ex); - } - } - - /// - /// Returns a byte array containing the content of the request. - /// - /// The current request. - /// The level of detail to include. - private static byte[] GetContent(HttpRequest request, NewDeviceDetails newDeviceDetail) - { - // If the headers contain 51D as a setting or the request is to a - // web service then do not send the data. - bool ignore = request.Headers["51D"] != null || - request.Url.Segments[request.Url.Segments.Length - 1].EndsWith("asmx"); - - if (ignore == false) - return RequestHelper.GetContent( - request, - newDeviceDetail == NewDeviceDetails.Maximum, - true); - - return null; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/NewDeviceDetails.cs b/Foundation/Mobile/Detection/NewDeviceDetails.cs deleted file mode 100644 index 7da8924..0000000 --- a/Foundation/Mobile/Detection/NewDeviceDetails.cs +++ /dev/null @@ -1,30 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Enumeration containing the different levels of request - /// details that can be sent to 51Degrees.mobi. Cookie headers - /// are never sent to 51Degrees.mobi. - /// - internal enum NewDeviceDetails - { - /// - /// Sends only UserAgent and UAProf header fields. - /// - Minimum = 0, - /// - /// Sends all headers except cookies. - /// - Maximum = 1 - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Property.cs b/Foundation/Mobile/Detection/Property.cs deleted file mode 100644 index a3cc129..0000000 --- a/Foundation/Mobile/Detection/Property.cs +++ /dev/null @@ -1,162 +0,0 @@ -/* ********************************************************************* - * 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 System.Collections.Generic; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Describes a property which can be assigned to a device. - /// - public class Property : PropertyValue - { - #region Fields - - private List _values = new List(); - private bool _isList = false; - private bool _isMandatory = false; - private bool _showValues = false; - private Provider.Components _component = Provider.Components.Unknown; - - #endregion - - #region Constructors - - internal Property(Provider provider, string name) : base(provider, name) { } - - internal Property(Provider provider, string name, string description) : base(provider, name, description) { } - - internal Property(Provider provider, string name, string description, string url) : base(provider, name, description, url) { } - - internal Property(Provider provider, string name, string description, string url, bool isMandatory, bool isList, bool showValues) - : base(provider, name, description, url) - { - _isMandatory = isMandatory; - _isList = isList; - _showValues = showValues; - } - - #endregion - - #region Internal Methods - - /// - /// Sets the value of the component the property relates to. Used - /// by the extension to the data structures to include component - /// information in the data file. - /// - /// The type of component the property relates to. - internal void SetComponent(Provider.Components component) - { - _component = component; - } - - #endregion - - #region Internal Properties - - /// - /// Returns the type of the component the property relates to. Values include; - /// Hardware, Software, Browser and Crawler. - /// - internal Provider.Components Component - { - get { return _component; } - } - - #endregion - - #region Public Properties - - /// - /// Returns true if the property is available in the CMS data set. - /// - public bool IsCms - { - get - { -#if VER4 || VER35 - return UI.Constants.CMS.FirstOrDefault(i => - i == Name) != null; -#else - foreach (string property in UI.Constants.CMS) - if (property == Name) - return true; - return false; -#endif - } - } - - /// - /// Returns true if the property is only available in the Premium - /// data set. - /// - public bool IsPremium - { - get - { -#if VER4 || VER35 - return Provider.EmbeddedProvider.Properties.Values.FirstOrDefault(i => - i.Name == Name) == null; -#else - foreach (Property property in Provider.EmbeddedProvider.Properties.Values) - if (property.Name == Name) - return false; - return true; -#endif - } - } - - /// - /// Returns a list of possible values the property can have. - /// - public List Values - { - get { return _values; } - } - - /// - /// Returns true if the property is mandatory and should be - /// returned for every device. - /// - public bool IsMandatory - { - get { return _isMandatory; } - } - - /// - /// Returns true if the property is a list type and multiple - /// values will be returned. - /// - public bool IsList - { - get { return _isList; } - } - - /// - /// Returns true if the values associated with the property are suitable - /// to be displayed. Will return false if they're numeric and do not generally - /// present well when shown as a list. - /// - public bool ShowValues - { - get { return _showValues; } - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/PropertyValue.cs b/Foundation/Mobile/Detection/PropertyValue.cs deleted file mode 100644 index 3519705..0000000 --- a/Foundation/Mobile/Detection/PropertyValue.cs +++ /dev/null @@ -1,108 +0,0 @@ -/* ********************************************************************* - * 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 System; - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Describes a name that can be assigned to a property. - /// - public class PropertyValue - { - #region Fields - - private int _nameStringIndex = -1; - private string _name; - private string _description; - private Uri _url; - private Provider _provider; - - #endregion - - #region Constructors - - /// - /// Constructs an instance of . - /// - /// The provider the property was created from. - /// The string name. - internal PropertyValue(Provider provider, string name) - { - _provider = provider; - _name = name; - } - - /// - /// Constructs an instance of . - /// - /// The provider the property was created from. - /// The string name. - /// The description of the name. - internal PropertyValue(Provider provider, string name, string description) - : this(provider, name) - { - _description = description; - } - - /// - /// Constructs an instance of . - /// - /// The provider the property was created from. - /// The string name. - /// The description of the name. - /// An optional URL linking to more information about the name. - internal PropertyValue(Provider provider, string name, string description, string url) - : this(provider, name, description) - { - Uri.TryCreate(url, UriKind.Absolute, out _url); - } - - #endregion - - #region Properties - - /// - /// Returns the string index of the name. - /// - internal int NameStringIndex - { - get - { - if (_nameStringIndex < 0) - _nameStringIndex = _provider.Strings.Add(Name); - return _nameStringIndex; - } - } - - /// - /// The string name. - /// - public string Name { get { return _name; } } - - /// - /// A description of the name. - /// - public string Description { get { return _description; } } - - /// - /// A url to more information about the name. - /// - public Uri Url { get { return _url; } } - - /// - /// The provider the property or value is associated with. - /// - public Provider Provider { get { return _provider; } } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Provider.cs b/Foundation/Mobile/Detection/Provider.cs deleted file mode 100644 index a135081..0000000 --- a/Foundation/Mobile/Detection/Provider.cs +++ /dev/null @@ -1,685 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Reflection; -using FiftyOne.Foundation.Mobile.Detection.Matchers; -using Matcher = FiftyOne.Foundation.Mobile.Detection.Matchers.Final.Matcher; -using System.IO; -using FiftyOne.Foundation.Mobile.Detection.Handlers; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Represents all device data and capabilities. - /// - public class Provider - { - #region Enumerations - - /// - /// Possible components properties can be related to. - /// - internal enum Components - { - Unknown = 0, - Hardware = 1, - Software = 2, - Browser = 3, - Crawler = 4 - } - - #endregion - - #region Fields - - /// - /// A list of handlers used to match devices. - /// - private readonly List _handlers = new List(); - - /// - /// Collection of all strings used by the provider. - /// - internal readonly Strings Strings = new Strings(); - - /// - /// Hashtable of all devices keyed on device hash code. - /// - internal readonly SortedDictionary> AllDevices = - new SortedDictionary>(); - - /// - /// A list of string indexes used for user agent profile properties. - /// - private List _userAgentProfileStringIndexes; - - /// - /// List of all the actual devices ignoring parents, or those - /// children added to handle useragent strings. - /// - private List _actualDevices = null; - - /// - /// Used to lock the list of devices during load. - /// - private object _lockDevices = new object(); - - /// - /// A list of properties and associated values which can be - /// returned by the provider and it's data source. Keyed on - /// the string index of the property name. - /// - private readonly SortedList _properties = new SortedList(); - - /// - /// The date and time the 1st data source used to create the - /// provider was created. - /// - internal DateTime _publishedDate = DateTime.MinValue; - - /// - /// Lock object used to create the embedded provider. - /// - internal static object _lock = new object(); - - /// - /// A static reference to a provider that contains the embedded - /// device data. - /// - internal static Provider _embeddedProvider = null; - - /// - /// The name of the data set the provider is using. - /// - internal string _dataSetName = "Unknown"; - - #endregion - - #region Internal Constructors - - /// - /// Constructs a new instance of . - /// - internal Provider() : base() - { - } - - #endregion - - #region Public Properties - - /// - /// A list of handlers being used by the provider. - /// - public List Handlers - { - get { return _handlers; } - } - - /// - /// Returns a list of all devices available to the provider which - /// have properties assigned to them. This is needed to ignore devices - /// which are only present to represent a useragent and do not have - /// any properties assigned to them. - /// - public List Devices - { - get - { - if (_actualDevices == null) - { - lock (_lockDevices) - { - if (_actualDevices == null) - { - lock (AllDevices) - { - _actualDevices = new List(); - string[] seperator = new string[] { Constants.ProfileSeperator }; - foreach (int key in AllDevices.Keys) - foreach (BaseDeviceInfo device in AllDevices[key]) - if (device.DeviceId.Split( - seperator, - StringSplitOptions.RemoveEmptyEntries).Length == 4) - _actualDevices.Add(device); - } - } - } - } - return _actualDevices; - } - } - - /// - /// Returns the a provider initialised with the data contained in the - /// device data file embedded in the assembly. - /// - public static Provider EmbeddedProvider - { - get - { - if (_embeddedProvider == null) - { - lock (_lock) - { - if (_embeddedProvider == null) - { - EventLog.Debug(String.Format("Creating provider from embedded device data '{0}'.", - Binary.BinaryConstants.EmbeddedDataResourceName)); - - using (Stream stream = Assembly.GetExecutingAssembly() - .GetManifestResourceStream( - Binary.BinaryConstants.EmbeddedDataResourceName)) - _embeddedProvider = Binary.Reader.Create(stream); - - EventLog.Info(String.Format("Created provider from embedded device data '{0}'.", - Binary.BinaryConstants.EmbeddedDataResourceName)); - } - } - } - return _embeddedProvider; - } - } - - /// - /// A list of properties and associated values which can be - /// returned by the provider and it's data source. Keyed on the - /// string index of the property name. - /// - public SortedList Properties - { - get { return _properties; } - } - - /// - /// Returns the date and time the data used to create the provider - /// was published. - /// - public DateTime PublishedDate - { - get { return _publishedDate; } - } - - /// - /// Returns the name of the data set used to create the provider. - /// - public string DataSetName - { - get { return _dataSetName; } - } - - #endregion - - #region Internal Properties - - /// - /// Returns a list of the string indexes for user agent profile properties. - /// - internal List UserAgentProfileStringIndexes - { - get - { - if (_userAgentProfileStringIndexes == null) - { - _userAgentProfileStringIndexes = new List(); - foreach (string value in Constants.UserAgentProfiles) - _userAgentProfileStringIndexes.Add(Strings.Add(value)); - } - return _userAgentProfileStringIndexes; - } - } - - #endregion - - #region Internal & Private Methods - - /// - /// Sets the property whose name is provided to relate to the component - /// provided. - /// - /// Name of the property to set. - /// The type of component to relate the property to. - private void SetComponent(string propertyName, Components component) - { - Property property = null; - if (Properties.TryGetValue(Strings.Add(propertyName), out property)) - property.SetComponent(component); - } - - /// - /// Sets the list of properties provided to the component. - /// - /// List of properties to be set - /// Component to set them to - private void SetDefaultComponents(string[] properties, Components component) - { - foreach (string propertyName in properties) - SetComponent(propertyName, component); - } - - /// - /// Sets the component properties relate to to their default values. - /// Used for data formats that don't include this information in the data file. - /// - internal void SetDefaultComponents() - { - SetDefaultComponents(UI.Constants.Hardware, Components.Hardware); - SetDefaultComponents(UI.Constants.Software, Components.Software); - SetDefaultComponents(UI.Constants.Browser, Components.Browser); - } - - /// - /// Find all the devices that match the request. - /// - /// List of http headers associated with the request. - /// The closest matching device. - internal Matchers.Results GetMatches(NameValueCollection headers) - { - // Get a user agent string with common issues removed. - string userAgent = GetUserAgent(headers); - if (String.IsNullOrEmpty(userAgent) == false) - { - // Using the handler for this userAgent find the device. - return GetMatches(headers, GetHandlers(headers)); - } - return null; - } - - /// - /// Find all the devices that match the useragent string. - /// - /// Useragent string associated with the mobile device. - /// The closest matching device. - internal Matchers.Results GetMatches(string userAgent) - { - if (String.IsNullOrEmpty(userAgent) == false) - { - // Using the handler for this userAgent find the device. - return GetMatches(userAgent, GetHandlers(userAgent)); - } - return null; - } - - /// - /// Use the HttpRequest fields to determine devices that match. - /// - /// Collection of Http headers associated with the request. - /// Handlers capable of finding devices for the request. - /// The closest matching device or null if one can't be found. - private static Matchers.Results GetMatches(NameValueCollection headers, IEnumerable handlers) - { - Matchers.Results results = new Matchers.Results(); - - foreach (Handler handler in handlers) - { - // Find the closest matching devices. - Matchers.Results temp = handler.Match(headers); - // If some results have been found. - if (temp != null) - // Combine the results with results from previous - // handlers. - results.AddRange(temp); - } - - return results; - } - - /// - /// Use the HttpRequest fields to determine devices that match. - /// - /// The useragent string of the device being sought. - /// Handlers capable of finding devices for the request. - /// The closest matching device or null if one can't be found. - private static Matchers.Results GetMatches(string useragent, IEnumerable handlers) - { - Matchers.Results results = new Matchers.Results(); - - foreach (Handler handler in handlers) - { - // Find the closest matching devices. - Matchers.Results temp = handler.Match(useragent); - // If some results have been found. - if (temp != null) - // Combine the results with results from previous - // handlers. - results.AddRange(temp); - } - - return results; - } - - /// - /// Returns an array of handlers that will be supported by the request. - /// Is used when a request is available so that header fields other - /// than Useragent can also be used in matching. For example; the - /// Useragent Profile fields. - /// - /// Collection of Http headers associated with the request. - /// An array of handlers able to match the request. - private Handler[] GetHandlers(NameValueCollection headers) - { - byte highestConfidence = 0; - List handlers = new List(); -#if VER4 || VER35 - foreach (Handler handler in Handlers.Where(handler => handler.CanHandle(headers))) - { - GetHandlers(ref highestConfidence, handlers, handler); - } -#else - foreach (Handler handler in Handlers) - { - // If the handler can support the request and it's not the - // catch all handler add it to the list we'll use for matching. - if (handler.CanHandle(headers)) - GetHandlers(ref highestConfidence, handlers, handler); - } -#endif - return handlers.ToArray(); - } - - /// - /// Adds the handler to the list of handlers if the handler's confidence - /// is higher than or equal to the current highest handler confidence. - /// - /// Highest confidence value to far. - /// List of handlers. - /// Handler to be considered for adding. - /// The new highest confidence value. - private static void GetHandlers(ref byte highestConfidence, List handlers, Handler handler) - { - if (handler.Confidence > highestConfidence) - { - handlers.Clear(); - handlers.Add(handler); - highestConfidence = handler.Confidence; - } - else if (handler.Confidence == highestConfidence) - handlers.Add(handler); - } - - /// - /// Records the device in the indexes used by the API. If a device - /// with the same ID already exists the previous one is overwritten. - /// The device is also assigned to a handler based on the useragent, - /// and supported root devices of the handler. - /// - /// The new device being added. - internal virtual void Set(BaseDeviceInfo device) - { - // Does the device already exist? - lock (AllDevices) - { - // Reset the list of devices. - _actualDevices = null; - - // Add the device to the list using the ID hashcode as key. - int hashCode = device.DeviceId.GetHashCode(); - if (AllDevices.ContainsKey(hashCode)) - { - // Yes. Add this device to the list. - AllDevices[hashCode].Add(device); - } - else - { - // No. So add the new device. - AllDevices.Add( - hashCode, - new List(new BaseDeviceInfo[] { device })); - } - } - - // Add the new device to handlers that can support it. - if (String.IsNullOrEmpty(device.UserAgent) == false) - { -#if VER4 || VER35 - foreach (Handler handler in GetHandlers(device.UserAgent).Where(handler => handler != null)) - { - handler.Set(device); - } -#else - foreach (Handler handler in GetHandlers(device.UserAgent)) - if (handler != null) - handler.Set(device); -#endif - } - } - - /// - /// Returns the main user agent string for the request. - /// - /// Collection of Http headers associated with the request. - /// The main user agent string for the request - internal static string GetUserAgent(NameValueCollection headers) - { - return headers[Detection.Constants.UserAgentHeader]; - } - - /// - /// Used to check other header fields in case a device user agent is being used - /// and returns the devices useragent string. - /// - /// Collection of Http headers associated with the request. - /// The useragent string of the device. - internal static string GetDeviceUserAgent(NameValueCollection headers) - { - foreach (string current in Detection.Constants.DeviceUserAgentHeaders) - if (headers[current] != null) - return headers[current]; - return null; - } - - /// - /// Returns the closest matching device from the result set to the target userAgent. - /// - /// The result set to find a device from. - /// Target useragent. - /// The closest matching result. - private Result GetRequestClosestMatch(Results results, string userAgent) - { - if (results == null || results.Count == 0) - return null; - - if (results.Count == 1) - return results[0]; - - results.Sort(); - Result result = Matcher.Match(userAgent, results); - if (result != null) - return result; - - return null; - } - - #endregion - - #region Public Methods - - /// - /// Using the unique device id returns the device. Very quick return - /// when the device id is known. - /// - /// Unique internal ID of the device. - /// BaseDeviceInfo object. - public BaseDeviceInfo GetDeviceInfoByID(string deviceID) - { - List list; - if (AllDevices.TryGetValue(deviceID.GetHashCode(), out list) == true) - { - // Return the first matching element. -#if VER35 || VER4 - return list.Find(i => i.DeviceId == deviceID); -#else - foreach (BaseDeviceInfo device in list) - if (device.DeviceId == deviceID) - return device; -#endif - } - return null; - } - - /// - /// Gets an array of handlers that will support the useragent string. - /// - /// Useragent string associated with the HTTP request. - /// A list of all handlers that can handle this device. - public Handler[] GetHandlers(string userAgent) - { - byte highestConfidence = 0; - List handlers = new List(); -#if VER4 || VER35 - - foreach (Handler handler in Handlers.Where(handler => handler.CanHandle(userAgent))) - { - GetHandlers(ref highestConfidence, handlers, handler); - } -#else - foreach (Handler handler in Handlers) - { - if (handler.CanHandle(userAgent)) - GetHandlers(ref highestConfidence, handlers, handler); - } -#endif - return handlers.ToArray(); - } - - /// - /// Gets an array of devices that match this useragent string. - /// - /// Useragent string associated with the device to be found. - /// An array of matching devices. - public List GetMatchingDeviceInfo(string userAgent) - { - List list = new List(); - Results results = GetMatches(userAgent); - if (results != null) - { - foreach (Result result in results) - list.Add(result.Device); - } - return list; - } - - /// - /// Gets the closest matching result for the headers. - /// - /// Collection of HTTP headers associated with the request. - /// The closest matching result. - public Result GetResult(NameValueCollection headers) - { - Result result = GetRequestClosestMatch( - GetMatches(headers), GetUserAgent(headers)); - string secondaryUserAgent = GetDeviceUserAgent(headers); - if (result != null && - String.IsNullOrEmpty(secondaryUserAgent) == false) - { - Result secondaryResult = GetResult(secondaryUserAgent); - if (secondaryResult != null) - result.SetSecondaryDevice(secondaryResult.DevicePrimary); - } - return result; - } - - /// - /// Gets the closest matching device based on the HTTP headers. - /// - /// Collection of Http headers associated with the request. - /// The closest matching device. - public BaseDeviceInfo GetDeviceInfo(NameValueCollection headers) - { - Result result = GetResult(headers); - if (result != null) - return result.Device; - return null; - } - - /// - /// Returns the closest matching result for the user agent provided. - /// - /// Useragent string associated with the device to be found. - /// The closest matching result. - public Result GetResult(string userAgent) - { - return GetRequestClosestMatch( - GetMatches(userAgent), userAgent); - } - - /// - /// Gets the single most likely device to match the useragent provided. - /// - /// Useragent string associated with the device to be found. - /// The closest matching device. - public BaseDeviceInfo GetDeviceInfo(string userAgent) - { - Result result = GetResult(userAgent); - if (result != null) - return result.Device; - return null; - } - - /// - /// Returns all the devices that match the property and value passed - /// into the method. - /// - /// The property required. - /// The value the property must contain to be matched. - /// A list of matching devices. An empty list will be returned if no matching devices are found. - public List FindDevices(string property, string value) - { - List list = new List(); - int propertyIndex = Strings.Add(property); - int requiredValueIndex = Strings.Add(value); - foreach (BaseDeviceInfo device in Devices) - { - foreach (int valueIndex in device.GetPropertyValueStringIndexes(propertyIndex)) - if (requiredValueIndex == valueIndex) - list.Add(device); - } - return list; - } - - /// - /// Returns a list of devices based on the profile id provided. - /// - /// The profile id of the devices required. - /// A list of matching devices. An empty list will be returned if no matching devices are found. - public List FindDevices(string profileID) - { - List list = new List(); - foreach (BaseDeviceInfo device in Devices) - { - foreach (string id in device.ProfileIDs) - { - if (profileID == id) - { - list.Add(device); - break; - } - } - } - return list; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/RequestHelper.cs b/Foundation/Mobile/Detection/RequestHelper.cs deleted file mode 100644 index d3bd930..0000000 --- a/Foundation/Mobile/Detection/RequestHelper.cs +++ /dev/null @@ -1,321 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Reflection; -using System.Text; -using System.Web; -using System.Xml; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection -{ - internal static class RequestHelper - { - #region Constants - - /// - /// IP Addresses of local host device. - /// - private static readonly IPAddress[] LOCALHOSTS = new IPAddress[] - { - IPAddress.Parse("127.0.0.1"), - IPAddress.Parse("::1") - }; - - /// - /// The content of fields in this array should not be included in the request information - /// information sent to 51degrees. - /// - private static readonly string[] IgnoreHeaderFieldValues = new string[] { - "Referer", - "cookie", - "AspFilterSessionId", - "Akamai-Origin-Hop", - "Cache-Control", - "Cneonction", - "Connection", - "Content-Filter-Helper", - "Content-Length", - "Cookie", - "Cookie2", - "Date", - "Etag", - "If-Last-Modified", - "If-Match", - "If-Modified-Since", - "If-None-Match", - "If-Range", - "If-Unmodified-Since", - "IMof-dified-Since", - "INof-ne-Match", - "Keep-Alive", - "Max-Forwards", - "mmd5", - "nnCoection", - "Origin", - "ORIGINAL-REQUEST", - "Original-Url", - "Pragma", - "Proxy-Connection", - "Range", - "Referrer", - "Script-Url", - "Unless-Modified-Since", - "URL", - "UrlID", - "URLSCAN-ORIGINAL-URL", - "UVISS-Referer", - "X-ARR-LOG-ID", - "X-Cachebuster", - "X-Discard", - "X-dotDefender-first-line", - "X-DRUTT-REQUEST-ID", - "X-Initial-Url", - "X-Original-URL", - "X-PageView", - "X-REQUEST-URI", - "X-REWRITE-URL", - "x-tag", - "x-up-subno", - "X-Varnish" }; - - #endregion - - #region Internal Static Methods - - /// - /// Provides the content as XML for the HttpRequest. - /// - /// HttpRequest containing the required information. - /// The amount of detail to provided. - /// byte array in XML string form of request content. - internal static byte[] GetContent(HttpRequest request, bool maximumDetail) - { - return GetContent(request, maximumDetail, false); - } - - /// - /// Provides the content as XML for the HttpRequest. - /// - /// HttpRequest containing the required information. - /// The amount of detail to provided. - /// True if only a fragment should be returned, otherwise false for a document. - /// byte array in XML string form of request content. - internal static byte[] GetContent(HttpRequest request, bool maximumDetail, bool fragment) - { - using (MemoryStream ms = new MemoryStream()) - { - using (XmlWriter writer = XmlWriter.Create(ms, GetXmlSettings(fragment))) - { - writer.WriteStartElement("Device"); - writer.WriteElementString("DateSent", DateTime.UtcNow.ToString("s")); - - // Record details about the assembly for diagnosis purposes. - WriteAssembly(writer); - - // Record either the IP address of the client if not local or the IP - // address of the machine. - if (request.IsLocal == false || - IsLocalHost(IPAddress.Parse(request.UserHostAddress)) == false) - { - writer.WriteElementString("ClientIP", request.UserHostAddress); - } - else - { - WriteHostIP(writer); - } - - foreach (string key in request.Headers.AllKeys) - { - // Determine if the field should be treated as a blank. - bool blank = IsBlankField(key); - - // Include all header values if maximumDetail is enabled, or - // header values related to the useragent or any header - // key containing profile or information helpful to determining - // mobile devices. - if (maximumDetail || - key == "User-Agent" || - key == "Host" || - key.Contains("profile") || - blank) - { - // Record the header content if it's not a cookie header. - if (blank) - WriteHeader(writer, key); - else - WriteHeaderValue(writer, key, request.Headers[key]); - } - } - writer.WriteEndElement(); - writer.Flush(); - } - return ms.ToArray(); - } - } - - #endregion - - #region Private Static Methods - - /// - /// Returns true if the request is from the local host IP address. - /// - /// The IP address to be checked. - /// True if from the local host IP address. - private static bool IsLocalHost(IPAddress address) - { -#if VER4 - return LOCALHOSTS.Any(host => host.Equals(address)); -#else - foreach (IPAddress host in LOCALHOSTS) - { - if (host.Equals(address)) - return true; - } - return false; -#endif - } - - /// - /// Writes details about the host IP address. - /// - /// - private static void WriteHostIP(XmlWriter writer) - { - IPAddress[] addresses = Dns.GetHostAddresses(Dns.GetHostName()); -#if VER4 || VER35 - foreach (IPAddress address in - addresses.Where(address => !IsLocalHost(address) && address.AddressFamily == AddressFamily.InterNetwork)) - { - writer.WriteElementString("ClientIP", address.ToString()); - return; - } - - foreach (IPAddress address in addresses.Where(address => !IsLocalHost(address))) - { - writer.WriteElementString("ClientIP", address.ToString()); - return; - } -#else - foreach (IPAddress address in addresses) - { - if (IsLocalHost(address) == false && address.AddressFamily == AddressFamily.InterNetwork) - { - writer.WriteElementString("ClientIP", address.ToString()); - return; - } - } - foreach (IPAddress address in addresses) - { - if (IsLocalHost(address) == false) - { - writer.WriteElementString("ClientIP", address.ToString()); - return; - } - } -#endif - } - - /// - /// Returns true if the field provided is one that should not have it's contents - /// sent to 51degrees for consideration a device matching piece of information. - /// - /// The name of the Http header field. - /// True if the field should be passed as blank. - private static bool IsBlankField(string field) - { - foreach (string key in IgnoreHeaderFieldValues) - { - if (field.IndexOf(key, 0, StringComparison.InvariantCultureIgnoreCase) >= 0) - return true; - } - return false; - } - - /// - /// Writes details about the assembly to the output stream. - /// - /// - private static void WriteAssembly(XmlWriter writer) - { - Assembly assembly = Assembly.GetExecutingAssembly(); - if (assembly != null) - { - object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(false); - foreach (object attribute in attributes) - { - if (attribute is AssemblyFileVersionAttribute) - writer.WriteElementString("Version", ((AssemblyFileVersionAttribute) attribute).Version); - if (attribute is AssemblyTitleAttribute) - writer.WriteElementString("Product", ((AssemblyTitleAttribute) attribute).Title); - } - } - } - - /// - /// Writer an XML header element with no value content. - /// - /// Writer for the output stream. - /// Name of the header. - private static void WriteHeader(XmlWriter writer, string key) - { - writer.WriteStartElement("Header"); - writer.WriteAttributeString("Name", key); - writer.WriteEndElement(); - } - - /// - /// Writes an XML header element with a value using CData. - /// - /// Writer for the output stream. - /// Name of the header. - /// Value of the header. - private static void WriteHeaderValue(XmlWriter writer, string key, string value) - { - writer.WriteStartElement("Header"); - writer.WriteAttributeString("Name", key); - writer.WriteCData(value); - writer.WriteEndElement(); - } - - /// - /// Provides the xml writer settings. - /// - /// - private static XmlWriterSettings GetXmlSettings(bool fragment) - { - XmlWriterSettings settings = new XmlWriterSettings(); - settings.OmitXmlDeclaration = fragment; - settings.ConformanceLevel = fragment ? ConformanceLevel.Fragment : ConformanceLevel.Document; - settings.Encoding = Encoding.UTF8; - settings.CheckCharacters = true; - settings.NewLineHandling = NewLineHandling.None; - settings.CloseOutput = true; - return settings; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Strings.cs b/Foundation/Mobile/Detection/Strings.cs deleted file mode 100644 index 266dcda..0000000 --- a/Foundation/Mobile/Detection/Strings.cs +++ /dev/null @@ -1,188 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Collections.Generic; - -#if VER4 - -using System.Linq; - -#endif - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Rather than store a copy of every string held in the data files a list of strings - /// is used and the index of the string is held in the data classes. - /// - internal class Strings - { - #region Fields - - /// - /// Index containing the hashcode of the string as the index and either the index in the _values - /// list as the value or a list of values that match the hashcode. It is possible for several - /// different values to share the same hashcode. - /// - private readonly Dictionary _index = new Dictionary(); - - /// - /// All the strings used in the 51Degrees.mobi file are held in this stack. - /// - internal readonly List _values = new List(); - - #endregion - - #region Properties - - /// - /// The number of items in the list. - /// - internal int Count - { - get { return _values.Count; } - } - - #endregion - - #region Internal Methods - - /// - /// Adds a new string value to the list of strings. If the value already exists - /// then it's index is returned. If it doesn't then a new entry is added. - /// - /// String value to add. - /// Index of the string in the _values list. Used the Get method to retrieve the string value later. - internal int Add(string value) - { - int hashcode = value.GetHashCode(); - int result = IndexOf(value, hashcode); - - // If the string does not exist lock the index and then check it - // still does not exist before adding to the index and values. - if (result == -1) - { - lock (_index) - { - result = IndexOf(value, hashcode); - if (result == -1) - { - // This hashcode does not exist so add a new entry to the list. - result = AddValue(value); - _index.Add(hashcode, result); - return result; - } - } - } - - // If this isn't the value we're looking for because another string - // shares the same hashcode add it's position to the index after the - // new string has been added to the values list. - if (_values[result] != value) - { - // Create the new list for the indexes. - List newList = null; - lock (_index) - { - object obj = _index[hashcode]; - if (obj is int) - newList = new List(new int[] { (int) obj }); - else - newList = new List((int[]) obj); - - // This is a new value for an existing hashcode. Add it to - // the list of strings before updating the index. - result = AddValue(value); - newList.Add(result); - _index[hashcode] = newList.ToArray(); - } - } - - return result; - } - - #endregion - - #region Internal Methods - - /// - /// Returns the string at the index position provided. If the index is - /// invalid then return null. - /// - /// Index of string required. - /// String value at the specified index. - internal string Get(int index) - { - if (index < 0) return null; - return _values[index]; - } - - #endregion - - #region Private Methods - - /// - /// Adds a value to the list and returns it's index in the list. - /// - /// - /// - private int AddValue(string value) - { - int result; - lock (_values) - { - result = _values.Count; - _values.Add(value); - } - return result; - } - - /// - /// Gets the index of the value and hashcode. The hashcode is provided - /// to avoid calculating when it already exists from the string. - /// - /// The value who's index is required from the list. - /// The hashcode of the value. - /// The integer index of the string value in the list, otherwise -1. - private int IndexOf(string value, int hashcode) - { - object obj = null; - // Does the hashcode exist in the list. - if (_index.TryGetValue(hashcode, out obj)) - { - // If the object is an integer return the index. - if (obj is int) - return (int) obj; - - // If it's an array of objects, which is very rare because the hashcodes - // will have to match return the 1st item if only one exists, or one that - // matches the string value passed into the method. - int[] list = (int[]) obj; - if (list.Length == 1) - { - return list[0]; - } - - // Find the matching index. - foreach (int index in list) - if (_values[index] == value) - return index; - } - return -1; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/UserAgentParser.cs b/Foundation/Mobile/Detection/UserAgentParser.cs deleted file mode 100644 index a47f7c9..0000000 --- a/Foundation/Mobile/Detection/UserAgentParser.cs +++ /dev/null @@ -1,118 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System.Collections.Generic; -using System.Text.RegularExpressions; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Used to manipulate user agent strings prior to matching. - /// - public class UserAgentParser - { - #region Classes - - /// - /// Filter used to identify a section of a user agent to be replaced. - /// - private class ReplaceFilter - { - private readonly Regex _regex; - private readonly string _replacement; - - /// - /// Constructs a new instance of . - /// - /// Regular expression to use for the replace. - /// String to use to replace. - internal ReplaceFilter(string expression, string replacement) - { - _regex = new Regex(expression, RegexOptions.Compiled | RegexOptions.CultureInvariant); - _replacement = replacement; - } - - /// - /// Processes the useragent passed returning a clean string. - /// - /// User agent string to clean. - /// Returns a clearned user agent string. - internal string ParseString(string useragent) - { - return _regex.Replace(useragent, _replacement); - } - } - - #endregion - - #region Static Fields - - private static readonly List ReplaceFilters = new List(); - - #endregion - - #region Private Methods - - /// - /// Create the regular expressions that are used to filter out common - /// problems with useragent strings. - /// - private static void InitReplaceFilters() - { - if (ReplaceFilters.Count != 0) return; - { - lock (ReplaceFilters) - { - if (ReplaceFilters.Count != 0) return; - // Removes UP.Link from user agents strings. - ReplaceFilters.Add(new ReplaceFilter(@"UP.Link/[\d\.]+", "")); - // Removes IMEI numbers. - ReplaceFilters.Add(new ReplaceFilter(@"/IMEI/SN[\d|X]+|/SN[\d|X]+", "")); - // Removes leading and trailing spaces. - ReplaceFilters.Add(new ReplaceFilter(@"^\s+|\s+$", "")); - // Removes STM substrings. - ReplaceFilters.Add(new ReplaceFilter(@"STM/[\d-\.]+", "")); - // Removes the UNTRUSTED substring. - ReplaceFilters.Add(new ReplaceFilter(@"UNTRUSTED/\d\.\d", "")); - // Removes the [TFXXXXXX] substring from LG strings. - ReplaceFilters.Add(new ReplaceFilter(@"\[TF\d+\]", "")); - // Removes IMEI/XXXXXXXXXXXX with a preceding space substring. - ReplaceFilters.Add(new ReplaceFilter(@"\s+IMEI/\d+", "")); - // Removes any sequence of numbers longer than 5 digits. - ReplaceFilters.Add(new ReplaceFilter(@"\d{6,}", "X")); - } - } - } - - #endregion - - #region Public Methods - - /// - /// Check the user agent string for common errors that hinder matching. - /// - /// A useragent string to be cleaned. - /// A cleaned useragent string. - public static string Parse(string userAgent) - { - InitReplaceFilters(); - foreach (ReplaceFilter filter in ReplaceFilters) - userAgent = filter.ParseString(userAgent); - return userAgent.Trim(); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/UserAgentProfileUrlParser.cs b/Foundation/Mobile/Detection/UserAgentProfileUrlParser.cs deleted file mode 100644 index a7b519f..0000000 --- a/Foundation/Mobile/Detection/UserAgentProfileUrlParser.cs +++ /dev/null @@ -1,33 +0,0 @@ -/* ********************************************************************* - * 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 System; - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Class used to manipulate a user agent profile url. - /// - public class UserAgentProfileUrlParser - { - /// - /// Removes any speech marks from the user agent profile url string. - /// - /// - /// - public static string CleanUserAgentProfileUrl(string value) - { - if (String.IsNullOrEmpty(value) == false) - return value.Split(',')[0].Replace("\"", ""); - return value; - } - } -} diff --git a/Foundation/Mobile/Detection/Value.cs b/Foundation/Mobile/Detection/Value.cs deleted file mode 100644 index bc594db..0000000 --- a/Foundation/Mobile/Detection/Value.cs +++ /dev/null @@ -1,153 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; - -#if VER4 - -using System.Linq; - -#endif - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// A possible value associated with a property. - /// - public class Value : PropertyValue, IComparable - { - #region Fields - - /// - /// Lock used when calculating the devices associated with the value. - /// - private static readonly object _lock = new object(); - - /// - /// The property the value is associted with. - /// - private Property _property; - - /// - /// A list of devices associated with the value. - /// - private List _devices = null; - - #endregion - - #region Constructors - - /// - /// Constructs an instance of . - /// - /// The property the value is associated with. - /// The string name. - internal Value(Property property, string name) - : base(property.Provider, name) - { - _property = property; - } - - /// - /// Constructs an instance of . - /// - /// The property the value is associated with. - /// The string name. - /// The description of the name. - internal Value(Property property, string name, string description) - : base(property.Provider, name, description) - { - _property = property; - } - - /// - /// Constructs an instance of . - /// - /// The property the value is associated with. - /// The string name. - /// The description of the name. - /// An optional URL linking to more information about the name. - internal Value(Property property, string name, string description, string url) - : base(property.Provider, name, description, url) - { - _property = property; - } - - #endregion - - #region Properties - - /// - /// Returns the property the value is associated with. - /// - public Property Property - { - get { return _property; } - } - - /// - /// Returns a list of devices associated with the value. - /// - public List Devices - { - get - { - if (_devices == null) - { - lock (_lock) - { - if (_devices == null) - { -#if VER4 - _devices = Provider.Devices.Where(i => - i.GetPropertyValueStringIndexes(_property.NameStringIndex).Contains(NameStringIndex)).ToList(); -#else - _devices = new List(); - foreach (BaseDeviceInfo device in Provider.Devices) - { - // Get all the values this property has for the current device. - foreach (int index in device.GetPropertyValueStringIndexes(_property.NameStringIndex)) - { - // If the value of the device property and this value match - // then add the device to the list and move to the next device. - if (index == NameStringIndex) - { - _devices.Add(device); - break; - } - } - } -#endif - } - } - } - return _devices; - } - } - - #endregion - - #region Interface Implementation - - /// - /// Compares this instance with another. - /// - /// An object of type PropertyValue - /// - public int CompareTo(Value other) - { - return Name.CompareTo(other.Name); - } - - #endregion - } -} diff --git a/Foundation/Mobile/Detection/Xml/DeviceInfo.cs b/Foundation/Mobile/Detection/Xml/DeviceInfo.cs deleted file mode 100644 index b31bc7a..0000000 --- a/Foundation/Mobile/Detection/Xml/DeviceInfo.cs +++ /dev/null @@ -1,107 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; - -namespace FiftyOne.Foundation.Mobile.Detection.Xml -{ - /// - /// Represents a device and holds all its settings. - /// - public class DeviceInfo : BaseDeviceInfo - { - - #region Constructors - - /// - /// Creates an instance of . - /// - /// User agent string used to identify this device. - /// A unique Identifier of the device. - /// A reference to the complete index of devices. - internal DeviceInfo( - Provider provider, - string deviceId, - string userAgent) - : base(provider, deviceId, userAgent) - { - } - - /// - /// Creates an instance of . - /// - /// A unique Identifier of the device. - /// A reference to the complete index of devices. - internal DeviceInfo( - Provider provider, - string deviceId) - : base(provider, deviceId) - { - } - - #endregion - - #region Methods - - /// - /// Gets the capability values index list for the static Strings collection for this device - /// based on the index of the capability name. - /// - /// Capability name index. - /// Capability index value in the String collection, or null if the capability does not exist. - internal protected override List GetPropertyValueStringIndexes(int index) - { - List value = base.GetPropertyValueStringIndexes(index); - if (value != null) - return value; - - if (_parent != null) - return _parent.GetPropertyValueStringIndexes(index); - - return null; - } - - /// - /// Gets the list of capabilities as a pipe seperated string. - /// - /// - /// - internal protected string GetCapabilityAsString(int index) - { - // Get the string indexes for the capabilities values. - List valueIndexes = GetPropertyValueStringIndexes(index); - if (valueIndexes == null) - return null; - - // Convert the values list into strings. - string[] values = new string[valueIndexes.Count]; - for (int i = 0; i < valueIndexes.Count; i++) - values[i] = _provider.Strings.Get(valueIndexes[i]); - - // Return a seperated list of strings. - return String.Join(Detection.Constants.ValueSeperator, values); - } - - /// - /// Checks if another DeviceInfo is equal to this one. - /// - /// Other DeviceInfo. - /// True if the object instances are the same. - internal bool Equals(DeviceInfo other) - { - return base.Equals(other) && - Parent.DeviceId.Equals(other.Parent.DeviceId); - } - - #endregion - } -} diff --git a/Foundation/Mobile/Detection/Xml/HandlersReader.cs b/Foundation/Mobile/Detection/Xml/HandlersReader.cs deleted file mode 100644 index aeb0daf..0000000 --- a/Foundation/Mobile/Detection/Xml/HandlersReader.cs +++ /dev/null @@ -1,182 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.IO; -using System.Text.RegularExpressions; -using System.Xml; -using FiftyOne.Foundation.Mobile.Detection.Handlers; - -namespace FiftyOne.Foundation.Mobile.Detection.Xml -{ - /// - /// Used to read the handlers information from the xml source. - /// - public static class HandlersReader - { - /// - /// Passed an xml string and returns a list of handlers. - /// - public static IList ProcessHandlers(string xml, Provider provider) - { - // Use different code to handle the DTD in the Xml if present. -#if VER4 - using (XmlReader reader = XmlReader.Create(new StringReader(xml), GetXmlReaderSettings())) -#else - xml = Regex.Replace(xml, "", ""); - using (XmlReader reader = XmlReader.Create(new StringReader(xml))) -#endif - { - return ProcessHandlers(reader, provider); - } - } - - /// - /// Passed an open XML reader and returns a list of handlers. - /// - /// - /// - /// - public static IList ProcessHandlers(XmlReader reader, Provider provider) - { - List handlers = new List(); - while (reader.Read()) - { - if (reader.NodeType == XmlNodeType.Element && - reader.IsStartElement(Constants.HandlerElementName)) - { - ProcessHandler( - handlers, - CreateHandler(reader, provider), - reader.ReadSubtree()); - } - } - return handlers; - } - -#if VER4 - /// - /// Returns an XML reader settings object that will ignore DTD. - /// - /// - private static XmlReaderSettings GetXmlReaderSettings() - { - var settings = new XmlReaderSettings(); - settings.DtdProcessing = DtdProcessing.Ignore; - return settings; - } -#endif - - /// - /// Processes the current handler and adds it to the list of handlers. - /// - /// The list of all handers to be added to. - /// The current handler object. - /// The XML stream reader. - private static void ProcessHandler(List handlers, Handler handler, XmlReader reader) - { - while (reader.Read()) - { - if (reader.Depth > 0 && reader.IsStartElement()) - { - switch (reader.Name) - { - case Constants.CanHandleElementName: - handler.CanHandleRegex.AddRange(ProcessRegex(reader.ReadSubtree())); - break; - case Constants.CantHandleElementName: - handler.CantHandleRegex.AddRange(ProcessRegex(reader.ReadSubtree())); - break; - case Constants.RegexSegmentsElementName: - if (handler is RegexSegmentHandler) - ProcessRegexSegments((RegexSegmentHandler)handler, reader.ReadSubtree()); - break; - } - } - } - handlers.Add(handler); - } - - /// - /// Adds the segments to the regular expression handler. - /// - /// Regular expression handler. - /// The XML stream reader. - private static void ProcessRegexSegments(RegexSegmentHandler handler, XmlReader reader) - { - while (reader.Read()) - { - if (reader.Depth > 0) - { - string pattern = reader.GetAttribute(Constants.PatternAttributeName); - int weight = 0; - if (String.IsNullOrEmpty(pattern) == false && - int.TryParse(reader.GetAttribute(Constants.WeightAttributeName), out weight)) - handler.AddSegment(pattern, weight); - } - } - } - - /// - /// Returns a list of regexs used to evaluate the handler to see if it can - /// be used to handle the requested useragent. - /// - /// The XML stream reader. - /// A list of regexes. - private static List ProcessRegex(XmlReader reader) - { - List regexs = new List(); - while (reader.Read()) - { - if (reader.Depth > 0 && reader.IsStartElement(Constants.RegexPrefix)) - { - HandleRegex regex = new HandleRegex(reader.GetAttribute(Constants.PatternAttributeName)); - regex.Children.AddRange(ProcessRegex(reader.ReadSubtree())); - regexs.Add(regex); - } - } - return regexs; - } - - /// - /// Creates a new handler based on the attributes of the current element. - /// - /// The XML stream reader. - /// The provider the handler will be associated with. - /// A new handler object. - private static Handler CreateHandler(XmlReader reader, Provider provider) - { - bool checkUAProf; - byte confidence; - string name = reader.GetAttribute(Constants.NameAttributeName); - string type = reader.GetAttribute(Constants.TypeAttributeName); - bool.TryParse(reader.GetAttribute(Constants.CheckUserAgentProfileAttibuteName), out checkUAProf); - byte.TryParse(reader.GetAttribute(Constants.ConfidenceAttributeName), out confidence); - - switch (type) - { - case "editDistance": - return new Handlers.EditDistanceHandler( - provider, name, String.Empty, confidence, checkUAProf); - case "reducedInitialString": - return new Handlers.ReducedInitialStringHandler( - provider, name, String.Empty, confidence, - checkUAProf, reader.GetAttribute(Constants.ToleranceAttributeName)); - case "regexSegment": - return new Handlers.RegexSegmentHandler( - provider, name, String.Empty, confidence, checkUAProf); - } - - throw new XmlException(String.Format("Type '{0}' is invalid.", type)); - } - } -} diff --git a/Foundation/Mobile/Detection/Xml/Reader.cs b/Foundation/Mobile/Detection/Xml/Reader.cs deleted file mode 100644 index 814627c..0000000 --- a/Foundation/Mobile/Detection/Xml/Reader.cs +++ /dev/null @@ -1,441 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Xml; -using System.Xml.Schema; - -#if VER4 - -using System.Linq; - -#endif - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Xml -{ - /// - /// Constains all methods needed to process the xmls file. - /// - public static class Reader - { - #region Static Public Methods - - /// - /// Creates a new provider and adds the data from the streams to the provider. - /// - /// Array of stream readers. - /// - public static Provider Create(IList streams) - { - Provider provider = new Provider(); - Add(provider, streams); - return provider; - } - - /// - /// Creates a new provider and adds the xml files specified to the provider. - /// - /// List of files to be processed. - public static Provider Create(IList files) - { - Provider provider = new Provider(); - Add(provider, files); - return provider; - } - - /// - /// Adds the xml files provided to the provider. If the file is compressed - /// it will be uncompressed before being processed because the reader needs - /// to be able to seek within the file which is not possible with compressed - /// file access. - /// - /// The provider to be modified. - /// List of files to be processed. - public static void Add(Provider provider, IList files) - { - List streams = new List(); - try - { - foreach (string file in files) - { - FileInfo fileInfo = new FileInfo(file); - if (fileInfo.Exists) - { - if (Detection.Constants.CompressedFileExtensions.Contains(fileInfo.Extension)) - { - // This is a compressed file. It needs to be copied to a memory stream - // to enable multiple passes of the data. - - // Create a 1mb buffer to hold data before writing to the memory stream. - byte[] buffer = new byte[0x100000]; - - // Create a memory stream and read the data from the compressed file. - MemoryStream ms = new MemoryStream(); - using (GZipStream gz = new GZipStream( - new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read), - CompressionMode.Decompress)) - ReadStream(gz, buffer, ms); - - // Add the memory stream to the list of streams for later processing. - streams.Add(ms); - } - else - // A raw file stream supports seeking so does not need to be copied to - // a memory stream. - streams.Add(new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read)); - } - } - Add(provider, streams); - } - finally - { - foreach (Stream stream in streams) - stream.Dispose(); - } - - // A lot of data has just been moved around. Force garbage collection including large objects. - // See: http://msdn.microsoft.com/en-us/magazine/cc534993.aspx - GC.Collect(); - } - - /// - /// Reads the content of one stream into another. - /// - /// The forward only stream to read from. - /// The preallocated memory buffer to read from. - /// The destination stream to write data to. - private static void ReadStream(Stream source, byte[] buffer, Stream destination) - { - int bytes = source.Read(buffer, 0, buffer.Length); - while (bytes > 0) - { - destination.Write(buffer, 0, bytes); - bytes = source.Read(buffer, 0, buffer.Length); - } - } - - /// - /// Adds the data from the streams to the provider. - /// - /// Array of stream readers. - /// The provider to be modified. - /// - public static void Add(Provider provider, IList streams) - { - try - { - // Read the streams provided looking for handlers. - foreach (Stream stream in streams) - { - if (stream.CanSeek == false) - throw new XmlException(String.Format("Stream must support seek operations.")); - - // Ensure we're at the start of the stream before reading starts. - stream.Position = 0; - using (XmlReader reader = XmlReader.Create(stream, GetXmlReaderSettings())) - { - if (reader.ReadToDescendant(Constants.HandlersElementName) || - (reader.ReadToDescendant(Constants.TopLevelElementName) && - reader.ReadToDescendant(Constants.HandlersElementName))) - provider.Handlers.AddRange( - HandlersReader.ProcessHandlers( - reader.ReadSubtree(), - provider)); - } - } - - // Parse the data for devices. - foreach (Stream stream in streams) - { - // Ensure we're at the start of the stream before reading. - stream.Position = 0; - using (XmlReader reader = XmlReader.Create(stream, GetXmlReaderSettings())) - { - if (reader.ReadToDescendant(Constants.TopLevelElementName) && - reader.ReadToDescendant(Constants.ProfilesElementName)) - { - ProcessDevices(provider, reader.ReadSubtree()); - break; - } - } - } - - // Read the manifest properties from the file. - foreach (Stream stream in streams) - { - // Ensure we're at the start of the stream before reading. - stream.Position = 0; - using (XmlReader reader = XmlReader.Create(stream, GetXmlReaderSettings())) - { - if (reader.ReadToDescendant(Constants.TopLevelElementName) && - reader.ReadToDescendant(Constants.PropertiesElementName)) - { - ProcessManifest(provider, reader.ReadSubtree()); - break; - } - } - } - - // Read the date the files were created and the name of the dataset. - foreach (Stream stream in streams) - { - // Ensure we're at the start of the stream before reading. - stream.Position = 0; - using (XmlReader reader = XmlReader.Create(stream, GetXmlReaderSettings())) - { - if (reader.ReadToDescendant(Constants.TopLevelElementName) && - reader.ReadToDescendant(Constants.HeaderElementName)) - { - if (ProcessHeaders(provider, reader.ReadSubtree())) - break; - } - } - } - - // Set the components properties relate to. - provider.SetDefaultComponents(); - } - catch (System.Xml.XmlException ex) - { - throw new XmlException( - String.Format("XML exception creating provider."), - ex); - } - catch (IOException ex) - { - throw new XmlException( - String.Format("IO exception creating provider."), - ex); - } - catch (Exception ex) - { - throw new XmlException( - String.Format("Exception creating provider."), - ex); - } - } - - /// - /// Returns XML settings that allows the xml streams to be processed without errors. - /// - /// XMLReaderSettings - private static XmlReaderSettings GetXmlReaderSettings() - { - XmlReaderSettings settings = new XmlReaderSettings(); - - settings.IgnoreComments = true; - settings.IgnoreWhitespace = true; - settings.ConformanceLevel = ConformanceLevel.Document; - settings.ValidationType = ValidationType.Schema; - settings.ValidationFlags = XmlSchemaValidationFlags.ProcessSchemaLocation; - - return settings; - } - - #endregion - - #region Manifest Methods - - /// - /// Processes the properties manifest section of the xml. - /// - /// Provider to have data loaded into. - /// XmlReader for the source data stream. - private static void ProcessManifest(Provider provider, XmlReader reader) - { - Property property = null; - while (reader.Read()) - { - if (reader.NodeType == XmlNodeType.Element) - { - switch (reader.Name) - { - case Constants.PropertyElementName: - if (property != null) - provider.Properties.Add(property.NameStringIndex, property); - property = new Property( - provider, - reader.GetAttribute(Constants.NameAttributeName), - reader.GetAttribute(Constants.DescriptionAttributeName), - reader.GetAttribute(Constants.UrlAttributeName), - bool.Parse(reader.GetAttribute(Constants.MandatoryAttributeName)), - bool.Parse(reader.GetAttribute(Constants.ListAttributeName)), - bool.Parse(reader.GetAttribute(Constants.ShowValuesAttributeName))); - break; - case Constants.ValueElementName: - property.Values.Add(new Value( - property, - reader.GetAttribute(Constants.NameAttributeName), - reader.GetAttribute(Constants.DescriptionAttributeName), - reader.GetAttribute(Constants.UrlAttributeName))); - break; - } - } - } - provider.Properties.Add(property.NameStringIndex, property); - } - - #endregion - - #region Header Methods - - /// - /// Processes the xml header section. - /// - /// Provider to have data loaded into. - /// XmlReader for the source data stream. - /// Returns true if the headers elements are processed correctly. - private static bool ProcessHeaders(Provider provider, XmlReader reader) - { - int found = 0; - while (reader.EOF == false && found < 2) - { - if (reader.NodeType == XmlNodeType.Element) - { - switch (reader.Name) - { - case Constants.PublishedDateAttributeName: - string date = reader.ReadElementContentAsString(); - DateTime.TryParse(date, out provider._publishedDate); - found++; - break; - case Constants.DataSetNameAttributeName: - provider._dataSetName = reader.ReadElementContentAsString(); - found++; - break; - default: - reader.Read(); - break; - } - } - else - reader.Read(); - } - return found >= 2; - } - - #endregion - - #region Device Methods - - /// - /// Uses the xml reader to load data into the provider. - /// - /// Provider to have data loaded into. - /// XmlReader for the source data stream. - private static void ProcessDevices(Provider provider, XmlReader reader) - { - BaseDeviceInfo device = null; - - while (reader.Read()) - { - if (reader.NodeType == XmlNodeType.Element) - { - switch (reader.Name) - { - case Constants.ProfileElementName: - // Load Device Data - if (reader.IsStartElement()) - { - // If a device has already been created ensure it's saved. - if (device != null) - provider.Set(device); - // Create or get the device related to the current XML element. - device = LoadDevice(provider, reader); - } - break; - - case Constants.PropertyElementName: - // Load the device capability. - if (reader.IsStartElement()) - { - LoadCapabilityData( - reader, - device); - } - break; - } - } - } - - // If a device has not been written ensure it's added to the device dataset. - if (device != null) - provider.Set(device); - } - - /// - /// Processes the XML element containing the device attributes. - /// - /// A list of loaded devices. - /// The XML stream readers. - /// An empty device. - private static BaseDeviceInfo LoadDevice(Provider provider, XmlReader reader) - { - // Create the next device using the fallback device if available. - string deviceId = reader.GetAttribute(Constants.IdAttributeName, string.Empty); - string userAgent = reader.GetAttribute(Constants.UserAgentAttributeName, string.Empty); - string fallbackDeviceId = reader.GetAttribute(Constants.ParentAttributeName, string.Empty); - - // If the device already exists then use the previous one. This may happen - // when an earlier device referenced a fallback device that had not yet - // been created. - BaseDeviceInfo device = provider.GetDeviceInfoByID(deviceId); - if (device == null) - { - // Create the new device. - device = new BaseDeviceInfo(provider, deviceId, userAgent ?? String.Empty); - } - else if (userAgent != null) - { - // Ensure the correct UserAgent string is assigned to this device. - device.InternalUserAgent = userAgent; - provider.Set(device); - } - - // Check the fallback device is different to the device being loaded. - if (fallbackDeviceId != null && device.DeviceId != fallbackDeviceId) - { - // Does the fallback device already exist? - device.Parent = provider.GetDeviceInfoByID(fallbackDeviceId); - if (device.Parent == null) - { - // No. So create new fallback device. - device.Parent = new BaseDeviceInfo(provider, fallbackDeviceId); - // Add it to the available devices. - provider.Set(device.Parent); - } - } - return device; - } - - private static void LoadCapabilityData( - XmlReader reader, - BaseDeviceInfo device) - { - string capabilityName = reader.GetAttribute(Constants.NameAttributeName, string.Empty); - string capabilityValue = reader.GetAttribute(Constants.ValueAttributeName, string.Empty); - - // Ensure the capability is set to the current value. - device.Properties.Set(capabilityName, capabilityValue.Split( - new string[] { Detection.Constants.ValueSeperator }, - StringSplitOptions.RemoveEmptyEntries)); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Detection/Xml/XmlException.cs b/Foundation/Mobile/Detection/Xml/XmlException.cs deleted file mode 100644 index eed7933..0000000 --- a/Foundation/Mobile/Detection/Xml/XmlException.cs +++ /dev/null @@ -1,61 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Runtime.Serialization; - -#endregion - -namespace FiftyOne.Foundation.Mobile.Detection.Xml -{ - /// - /// Represents Xml exceptions. - /// - [Serializable] - internal class XmlException : MobileException - { - /// - /// Initializes a new instance of - /// - internal XmlException() - { - } - - /// - /// Initializes a new instance of - /// - /// The human readable message explaining the exception. - internal XmlException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of - /// - /// The human readable message explaining the exception. - /// The exception that caused the new one. - internal XmlException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of - /// - protected XmlException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/Foundation/Mobile/MobileException.cs b/Foundation/Mobile/MobileException.cs deleted file mode 100644 index 9fa3c64..0000000 --- a/Foundation/Mobile/MobileException.cs +++ /dev/null @@ -1,64 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Runtime.Serialization; - -#endregion - -namespace FiftyOne.Foundation.Mobile -{ - /// - /// - /// The generic Exception class for all exceptions generated from the Mobile - /// Toolkit. - /// - /// - [Serializable] - public class MobileException : Exception - { - /// - /// Initializes a new instance of . - /// - internal MobileException() - { - } - - /// - /// Initializes a new instance of . - /// - /// The human readable message explaining the exception. - public MobileException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of . - /// - /// The human readable message explaining the exception. - /// The exception that caused the new one. - public MobileException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of . - /// - protected internal MobileException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Redirection/Azure/RequestEntity.cs b/Foundation/Mobile/Redirection/Azure/RequestEntity.cs deleted file mode 100644 index 8b98a8c..0000000 --- a/Foundation/Mobile/Redirection/Azure/RequestEntity.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#if AZURE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.WindowsAzure.StorageClient; - - -namespace FiftyOne.Foundation.Mobile.Redirection.Azure -{ - /// - /// Used internally to represent a requesting device. - /// - public class RequestEntity : TableServiceEntity - { - /// - /// Constructs an instance of RequestDataModel without any - /// data defined. - /// - public RequestEntity() { } - - /// - /// Constructs an instance of RequestDataModel using the unique - /// request ID of the device as the primary key, and the last - /// date the device related to the request was active. - /// - internal RequestEntity(RequestRecord record) : - base(record.PartitionKey, record.RowKey) - { - LastActiveDate = record.LastActiveDateAsDateTime; - } - - /// - /// The last time the device was active in the web application. - /// - internal DateTime LastActiveDate { get; set; } - } -} - -#endif diff --git a/Foundation/Mobile/Redirection/Azure/RequestHistory.cs b/Foundation/Mobile/Redirection/Azure/RequestHistory.cs deleted file mode 100644 index c03b742..0000000 --- a/Foundation/Mobile/Redirection/Azure/RequestHistory.cs +++ /dev/null @@ -1,295 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#if AZURE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Web; -using Microsoft.WindowsAzure; -using Microsoft.WindowsAzure.StorageClient; -using System.Threading; -using FiftyOne.Foundation.Mobile.Configuration; -using System.Data.Services.Client; -using System.Text.RegularExpressions; - -namespace FiftyOne.Foundation.Mobile.Redirection.Azure -{ - internal class RequestHistory : IRequestHistory - { - // Stores the name of the table. - private readonly string _tableName; - - /// - /// The Azure storage account. - /// - CloudStorageAccount _storageAccount = null; - - /// - /// Context for accessing the Azure table. - /// - TableServiceContext _serviceContext = null; - - // The next time this process should service the sync file. - private DateTime _nextServiceTime = DateTime.MinValue; - - // True if the recording of device details is enabled. - private readonly bool _enabled; - - /// - /// The number of minutes that should elapse before the record of - /// previous access for the device should be removed from all - /// possible storage mechanisims. - /// - private readonly int _redirectTimeout = 0; - - internal RequestHistory() - { - // Get the timeout used to remove devices. - _redirectTimeout = Manager.Redirect.Timeout; - - // Get the table name. - _tableName = Regex.Replace(Manager.Redirect.DevicesFile, "[^A-Za-z]+", String.Empty); - - // Determine if the functionality should be enabled. - _enabled = String.IsNullOrEmpty(_tableName) == false; - - if (_enabled) - { - // Initialise the Azure table service creating the table if it does not exist. - _storageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(Mobile.Constants.AZURE_STORAGE_NAME)); - _serviceContext = new TableServiceContext(_storageAccount.TableEndpoint.ToString(), _storageAccount.Credentials); - _serviceContext.IgnoreResourceNotFoundException = false; - _storageAccount.CreateCloudTableClient().CreateTableIfNotExist(_tableName); - } - } - - #region Private Methods - - /// - /// Returns the entity if present from the table service. Should only be called after - /// checking the entity is not already present in the context. - /// - /// Request record of the entity being sought. - /// The entity if present in the table service. - private RequestEntity GetEntityFromTable(RequestRecord record) - { - // Create query to return all matching entities for this record. - CloudTableQuery query = (from entity - in _serviceContext.CreateQuery(_tableName) - where entity.PartitionKey == record.PartitionKey && entity.RowKey == record.RowKey - select entity).AsTableServiceQuery(); - // Return the first or default entity found. - try - { - return query.Execute().FirstOrDefault(); - } - catch (DataServiceQueryException ex) - { - //If an exception occurs checked for a 404 error code meaning the resource was not found. - if (ex.Response.StatusCode == 404) - return null; - throw ex; - } - } - - /// - /// Returns the entity if present from the current context. - /// - /// Request record of the entity being sought. - /// The entity if present in the context. - private RequestEntity GetEntityFromContext(RequestRecord record) - { - var descripter = _serviceContext.Entities.FirstOrDefault( - i => - i.State != EntityStates.Deleted && - ((RequestEntity)i.Entity).PartitionKey == record.PartitionKey && - ((RequestEntity)i.Entity).RowKey == record.RowKey); - if (descripter != null) - return descripter.Entity as RequestEntity; - return null; - } - - /// - /// Removes the request device details from the table, and then removes - /// from memory once the table has been updated. - /// - /// Request record of the entity being removed. - private void Remove(RequestRecord record) - { - lock (_serviceContext) - { - // Get the entity matching the record held in the context. - RequestEntity entity = GetEntityFromContext(record); - if (entity == null) - // Get the entity from the table if it exists. - entity = GetEntityFromTable(record); - - // If the entity has been found remove it from the context and the table. - if (entity != null) - { - _serviceContext.DeleteObject(entity); - _serviceContext.SaveChanges(); - } - } - } - - /// - /// Adds the record to the table storage service, or if it already exists - /// updates the last active date and time. - /// - /// Request record of the entity being added or updated. - private void Set(RequestRecord record) - { - lock (_serviceContext) - { - // Get the entity if it exists. - RequestEntity entity = GetEntityFromContext(record); - if (entity == null) - entity = GetEntityFromTable(record); - - if (entity == null) - { - // Add the new entity to the table storage. - _serviceContext.AddObject( - _tableName, - new RequestEntity(record)); - } - else - { - // Update the last active time. - entity.LastActiveDate = record.LastActiveDateAsDateTime; - _serviceContext.UpdateObject(entity); - } - - // Commit the changes back to the table service. - _serviceContext.SaveChanges(); - } - - CheckIfServiceRequired(); - } - - /// - /// If the last time the devices file was serviced to remove old entries - /// is older than 1 minute start a thread to service the devices file and - /// remove old entries. If the redirect timeout is 0 indicating infinite - /// then nothing should be purged. - /// - private void CheckIfServiceRequired() - { - if (_nextServiceTime < DateTime.UtcNow) - { - // Service the request history storage. - ThreadPool.QueueUserWorkItem( - ServiceRequestHistory, - DateTime.UtcNow.AddMinutes(-_redirectTimeout)); - - // Set the next time to service the sync file using a random offset to - // attempt to avoid conflicts with other processes. - _nextServiceTime = DateTime.UtcNow.AddMinutes(1).AddSeconds(new Random().Next(30)); - } - } - - /// - /// Removes old entries that are held within this context from the table store using a single - /// save changes operation. This means the service happens using one HTTP request which saves - /// a lot of money with Azure. Unfortunately it does mean that there is a possibility request - /// data not known to this instance will not be removed. - /// - /// - /// Date as a DateTime used to determine if a request history - /// record is old and can be removed. - /// - private void ServiceRequestHistory(object value) - { - // Remove the old records from the table. - DateTime purgeDate = (DateTime)value; - - lock (_serviceContext) - { - // Get all entities in the context that are older than the purgeDate. - var entities = from i in _serviceContext.Entities - where ((RequestEntity)i.Entity).LastActiveDate < purgeDate && - i.State == EntityStates.Unchanged - select i; - - if (entities != null && entities.Count() > 0) - { - // Delete all the entities found. - foreach (var entity in entities) - _serviceContext.DeleteObject(entity.Entity); - _serviceContext.SaveChanges(); - } - } - } - - #endregion - - #region IRequestHistory Members - - /// - /// Determines if the device making the request has been seen by the web site previously. - /// - /// The request from the device. - /// True if the device has been seen before, otherwise false. - public bool IsPresent(HttpRequest request) - { - if (_enabled == false) - return false; - - RequestRecord record = new RequestRecord(request); - - lock (_serviceContext) - { - // Get the entity if it exists. - RequestEntity entity = GetEntityFromContext(record); - if (entity == null) - entity = GetEntityFromTable(record); - - // If the entity isn't null and the last active time is within the timeout period. - return entity != null && - entity.LastActiveDate.AddMinutes(_redirectTimeout) >= record.LastActiveDateAsDateTime; - } - } - - /// - /// Sets the last active time for the device making the request. - /// - /// The request from the device. - public void Set(HttpRequest request) - { - if (_enabled == false) - return; - - RequestRecord record = new RequestRecord(request); - Set(record); - } - - /// - /// Removes the device behind the request. - /// - /// The request from the device. - public void Remove(HttpRequest request) - { - if (_enabled == false) - return; - - RequestRecord record = new RequestRecord(request); - Remove(record); - } - - #endregion - } -} - -#endif \ No newline at end of file diff --git a/Foundation/Mobile/Redirection/Azure/RequestRecord.cs b/Foundation/Mobile/Redirection/Azure/RequestRecord.cs deleted file mode 100644 index 32eba24..0000000 --- a/Foundation/Mobile/Redirection/Azure/RequestRecord.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#if AZURE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Web; - -namespace FiftyOne.Foundation.Mobile.Redirection.Azure -{ - /// - /// A sub class which breaks the unique key of the request record into a partition - /// key and a row key. - /// - internal class RequestRecord : Redirection.RequestRecord - { - /// - /// If the IP address is IPv4 (4 bytes) then use the ip address as the high order - /// bytes of the value and the hashcode as the low order bytes. - /// If the IP address is IPv6 (8 bytes) then covert the bytes to a 64 bit - /// integer. - /// If anything else which we can't imagine use a hashcode of the string value. - /// - /// - protected internal RequestRecord(HttpRequest request) - : base (request) - { - } - - /// - /// Returns the first byte as a string. - /// - internal string PartitionKey - { - get { return BitConverter.GetBytes(base.Key)[0].ToString(); } - } - - /// - /// Returns the full 8 bytes as a string. - /// - internal string RowKey - { - get { return Key.ToString(); } - } - } -} - -#endif \ No newline at end of file diff --git a/Foundation/Mobile/Redirection/Filter.cs b/Foundation/Mobile/Redirection/Filter.cs deleted file mode 100644 index 00ab737..0000000 --- a/Foundation/Mobile/Redirection/Filter.cs +++ /dev/null @@ -1,165 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Text.RegularExpressions; -using System.Web; - -namespace FiftyOne.Foundation.Mobile.Redirection -{ - internal class Filter - { - - #region Fields - - private readonly string _capability; - private readonly Regex _expression; - - #endregion - - #region Constructor - - internal Filter(string capability, string expression) - { - _capability = capability; - _expression = new Regex(expression, RegexOptions.Compiled | RegexOptions.IgnoreCase); - } - - #endregion - - #region Internal Methods - - /// - /// Determines if this filter matches the requesting device. - /// - /// Context of the requesting device. - /// True if the capability matches, otherwise false. - internal bool GetIsMatch(HttpContext context) - { - string value = GetPropertyValue(context, _capability); - if (String.IsNullOrEmpty(value)) - return false; - return _expression.IsMatch(value); - } - - #endregion - - #region Private Members - - /// - /// Returns the value for the property requested. - /// - /// The property name to be returned. - /// The context associated with the request. - /// - private static string GetPropertyValue(HttpContext context, string property) - { - string value; - - // Check for special properties. - value = GetSpecialPropertyValue(property, context); - if (String.IsNullOrEmpty(value) == false) - return value; - - // Try the standard properties of the browser object. Use a try/catch block - // incase there is a security exception accessing the reflection methods. - try - { - value = GetHttpBrowserCapabilitiesPropertyValue(property, context.Request.Browser); - if (String.IsNullOrEmpty(value) == false) - return value; - } - catch (Exception ex) - { - EventLog.Warn(new MobileException(String.Format("Exception getting property value '{0}' from HttpBrowserCapabilities instance.", property), ex)); - } - - // Try the standard properties of the request object. Use a try/catch block - // incase there is a security exception accessing the reflection methods. - try - { - value = GetHttpRequestPropertyValue(property, context.Request); - if (String.IsNullOrEmpty(value) == false) - return value; - } - catch (Exception ex) - { - EventLog.Warn(new MobileException(String.Format("Exception getting property value '{0}' from HttpRequest instance.", property), ex)); - } - - // If not then try and return the value for the collection. - return context.Request.Browser[property]; - } - - /// - /// Checks the properties of the HttpBrowserCapabilities instance passed - /// into the method for the property name contained in the property parameters - /// string value. - /// - /// Property name to be found. - /// Capabilities collection to be used. - /// If the property exists then return the associated value, otherwise null. - private static string GetHttpBrowserCapabilitiesPropertyValue(string property, HttpBrowserCapabilities capabilities) - { - Type controlType = capabilities.GetType(); - System.Reflection.PropertyInfo propertyInfo = controlType.GetProperty(property); - if (propertyInfo != null && propertyInfo.CanRead) - return propertyInfo.GetValue(capabilities, null).ToString(); - - // Try browser capabilities next. - string value = capabilities[property]; - if (value != null) - return value; - - return null; - } - - /// - /// Checks the properties of the HttpRequest instance passed - /// into the method for the property name contained in the property parameters - /// string value. - /// - /// Property name to be found. - /// HttpRequest to be used. - /// If the property exists then return the associated value, otherwise null. - private static string GetHttpRequestPropertyValue(string property, HttpRequest request) - { - // Try the properties of the request. - Type controlType = request.GetType(); - System.Reflection.PropertyInfo propertyInfo = controlType.GetProperty(property); - if (propertyInfo != null && propertyInfo.CanRead) - return propertyInfo.GetValue(request, null).ToString(); - - return null; - } - - /// - /// Checks the items collection of the HttpContent instance passed - /// into the method for the property name contained in the property parameters - /// string value. - /// - /// Property name to be found. - /// HttpContext to be used. - /// If the property exists then return the associated value, otherwise null. - private static string GetSpecialPropertyValue(string property, HttpContext context) - { - switch(property) - { - case Constants.OriginalUrlSpecialProperty: - return context.Items[Constants.OriginalUrlKey] as string; - } - return null; - } - - #endregion - - } -} diff --git a/Foundation/Mobile/Redirection/IRequestHistory.cs b/Foundation/Mobile/Redirection/IRequestHistory.cs deleted file mode 100644 index 0953190..0000000 --- a/Foundation/Mobile/Redirection/IRequestHistory.cs +++ /dev/null @@ -1,22 +0,0 @@ -/* ********************************************************************* - * 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 System.Web; - -namespace FiftyOne.Foundation.Mobile.Redirection -{ - interface IRequestHistory - { - bool IsPresent(HttpRequest request); - void Set(HttpRequest request); - void Remove(HttpRequest request); - } -} diff --git a/Foundation/Mobile/Redirection/Location.cs b/Foundation/Mobile/Redirection/Location.cs deleted file mode 100644 index 771142f..0000000 --- a/Foundation/Mobile/Redirection/Location.cs +++ /dev/null @@ -1,92 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using System.Web; - -namespace FiftyOne.Foundation.Mobile.Redirection -{ - internal class Location - { - #region Fields - - internal static readonly Regex _regexReplaceEmptyTags = new Regex(@"{\d+}", RegexOptions.Compiled); - internal readonly string _name; - internal readonly string _url; - internal readonly List _filters = new List(); - internal readonly Regex _matchRegex; - - #endregion - - #region Constructors - - internal Location(string name, string url, string expression) - { - _name = name; - _url = url; - if (String.IsNullOrEmpty(expression) == false) - _matchRegex = new Regex(expression, RegexOptions.Compiled | RegexOptions.IgnoreCase); - } - - #endregion - - #region Properties - - internal List Filters - { - get { return _filters; } - } - - #endregion - - #region Methods - - internal string GetUrl(HttpContext context) - { - if (_matchRegex != null) - { - // A match regular expression has been found that should be used to - // extract all the items of interest from the original URL and place - // them and the positions contains in {} brackets in the URL property - // of the location. Removes any remaining {} brackets before returning - // the url for the location. - MatchCollection matches = _matchRegex.Matches(RedirectModule.GetOriginalUrl(context)); - string url = null; - if (matches.Count > 0) - { - string[] values = new string[matches.Count]; - for (int i = 0; i < matches.Count; i++) - values[i] = matches[i].Value; - url = String.Format(_url, values); - } - else - url = _url; - return _regexReplaceEmptyTags.Replace(url, String.Empty); - } - // Return the URL unformatted. - return _url; - } - - internal bool GetIsMatch(HttpContext context) - { - foreach (Filter filter in _filters) - { - if (filter.GetIsMatch(context) == false) - return false; - } - return true; - } - - #endregion - } -} diff --git a/Foundation/Mobile/Redirection/RedirectModule.cs b/Foundation/Mobile/Redirection/RedirectModule.cs deleted file mode 100644 index 9cf7dbc..0000000 --- a/Foundation/Mobile/Redirection/RedirectModule.cs +++ /dev/null @@ -1,748 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using System.Web; -using System.Web.Security; -using System.Web.UI; -using FiftyOne.Foundation.Mobile.Configuration; -using FiftyOne.Foundation.Mobile.Detection; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -namespace FiftyOne.Foundation.Mobile.Redirection -{ - /// - /// Class responsible for handling redirection based on predefined rules. - /// - public class RedirectModule : IHttpModule - { - #region Fields - - /// - /// Used to lock the initialisation of static fields. - /// - private static readonly object _lock = new object(); - - /// - /// Indicates if static field initialisation has been completed. - /// - private static bool _staticFieldsInitialised; - - /// - /// If set to true only the first eligable request received by the web - /// site will be redirected to the mobile landing page contained in - /// _mobileRedirectUrl. - /// - private static bool _firstRequestOnly = true; - - /// - /// The number of minutes that should elapse before the record of - /// previous access for the device should be removed from all - /// possible storage mechanisims. - /// - private static int _redirectTimeout = 0; - - /// - /// The login url for forms authentication. - /// - private static string _formsLoginUrl; - - /// - /// A collection of homepages that could be used for redirection. - /// Evaluated before the _mobileHomePageUrl value is used. - /// Initialised from the web.config file when the module - /// is created. - /// - private static readonly List _locations = new List(); - - /// - /// The URL to use to redirect a mobile device accessing - /// a non mobile web page to. Initialised from the web.config file - /// when the module is created. - /// - private static string _mobileHomePageUrl; - - /// - /// A regular expression that when applied to the current request Path - /// (context.Request.AppRelativeCurrentExecutionFilePath) will return true - /// if it should be considered a mobile page. Use this attribute to tell - /// redirection about mobile pages derived from base classes such as - /// System.Web.UI.Page. Redirection needs to be aware of mobile pages so - /// that requests to these pages can be ignored. Any page that derives from - /// System.Web.UI.MobileControls.MobilePage will automatically be treated - /// as a mobile page irrespective of this attribute. (Optional) - /// - private static Regex _mobilePageRegex; - - /// - /// If set to true the original URL of the request is added to the redirected - /// querystring in a paramter called origUrl. - /// - private static bool _originalUrlAsQueryString; - - /// - /// If set to true redirection is enabled. - /// - private static bool _redirectEnabled; - - /// - /// The request history provider to use with the redirect module. - /// - private static IRequestHistory _requestHistory; - - /// - /// Class used to record new devices. - /// - private NewDevice _newDevice; - - #endregion - - #region Initialisers - - /// - /// Initiliases the HttpMobile registering this modules interest in - /// all new requests and handler mappings. - /// - /// HttpApplication object for the web application. - public virtual void Init(HttpApplication application) - { - EventLog.Debug("Initialising redirection module"); - - StaticFieldInit(application); - - // Initialise the request history processor if required. - if (_firstRequestOnly == true) - { -#if AZURE - _requestHistory = new Azure.RequestHistory(); -#else - _requestHistory = new RequestHistory(); -#endif - } - - RegisterEventHandlersInit(application); - - _newDevice = new NewDevice( - Detection.Constants.NewDevicesUrl, - Detection.Constants.NewDeviceDetail); - } - - /// - /// Registers the event handlers if they've not done so already. - /// - /// HttpApplication object for the web application. - private void RegisterEventHandlersInit(HttpApplication application) - { - // Record the original requesting URL. - application.BeginRequest += OnBeginRequest; - - // Intercept request event after the hander and the state have been assigned - // to redirect the page. - application.PostAcquireRequestState += OnPostAcquireRequestState; - } - - /// - /// Initialises the static fields. - /// - private static void StaticFieldInit(HttpApplication application) - { - if (_staticFieldsInitialised == false) - { - lock (_lock) - { - if (_staticFieldsInitialised == false) - { - EventLog.Debug("Initialising redirection module static fields."); - - // Fetch the redirect url, first time redirect indicator and wire up the - // events if a url has been provided. - if (Manager.Redirect != null && Manager.Redirect.Enabled) - { - _redirectEnabled = true; - _mobileHomePageUrl = Manager.Redirect.MobileHomePageUrl; - _firstRequestOnly = Manager.Redirect.FirstRequestOnly; - if (_firstRequestOnly == true) - _redirectTimeout = Manager.Redirect.Timeout; - if (String.IsNullOrEmpty(Manager.Redirect.MobilePagesRegex) == false) - _mobilePageRegex = new Regex(Manager.Redirect.MobilePagesRegex, - RegexOptions.Compiled | RegexOptions.IgnoreCase); -#if VER4 - _formsLoginUrl = FormsAuthentication.IsEnabled ? FormsAuthentication.LoginUrl : String.Empty; -#else - _formsLoginUrl = FormsAuthentication.LoginUrl; -#endif - _originalUrlAsQueryString = Manager.Redirect.OriginalUrlAsQueryString; - - foreach (LocationElement homePage in Manager.Redirect.Locations) - { - if (homePage.Enabled) - { - Location current = new Location(homePage.Name, homePage.Url, homePage.MatchExpression); - foreach (FilterElement filter in homePage) - { - if (filter.Enabled) - current.Filters.Add(new Filter(filter.Property, filter.MatchExpression)); - } - _locations.Add(current); - } - } - } - - // Indicate initialisation is complete. - _staticFieldsInitialised = true; - } - } - } - } - - #endregion - - #region Events - - /// - /// Record the original requesting URL. - /// - /// HttpApplication related to the request. - /// EventArgs related to the event. Not used. - private static void OnBeginRequest(object sender, EventArgs e) - { - if (sender is HttpApplication) - { - HttpContext context = ((HttpApplication)sender).Context; - if (context != null) - { - context.Items[Constants.OriginalUrlKey] = context.Request.Url.ToString(); - } - } - } - - /// - /// If the handler assigned to the request isn't a mobile one and the browser that - /// is accessing the page is a wireless device then redirect the browser to the - /// mobile home page for the site. The redirect is done through the resposne to - /// ensure a fresh request is made to the server. - /// - /// HttpApplication related to the request. - /// EventArgs related to the event. Not used. - public void OnPostAcquireRequestState(object sender, EventArgs e) - { - if (sender is HttpApplication) - { - // Initialise the static fields if required. - StaticFieldInit((HttpApplication)sender); - - HttpContext context = ((HttpApplication)sender).Context; - - if (context != null) - { - - RecordNewDevice(context); - - // Check to see if the request should be redirected. - if (_redirectEnabled && ShouldRequestRedirect(context)) - { - string newUrl = GetLocationUrl(context); - if (_originalUrlAsQueryString) - // Use an encoded version of the requesting Url - // as the query string. - if (newUrl.Contains("?")) - { - // Url already has a query string, so add requesting Url to it with a '&'. - newUrl = String.Format("{0}&origUrl={1}", - newUrl, - HttpUtility.UrlEncode(context.Request.Url.ToString())); - } - else - { - // Url has no query string so create one now. - newUrl = String.Format("{0}?origUrl={1}", - newUrl, - HttpUtility.UrlEncode(context.Request.Url.ToString())); - } - - if (EventLog.IsDebug) - EventLog.Debug(String.Format("Redirecting device with useragent '{0}' from url '{1}' to '{2}' due to '{3}'.", - context.Request.UserAgent, - context.Items[Constants.OriginalUrlKey], - newUrl, - GetLocationName(context))); - - context.Response.Redirect(newUrl, true); - } - } - } - } - - #endregion - - #region Public Methods - - /// - /// Returns true if the current handler relates to a mobile web page. - /// - /// The context associated with the Http request. - public static bool IsMobilePage(HttpContext context) - { - return IsMobileType(context.Handler.GetType()) || - IsMobileRegexPage(context); - } - - /// - /// Determines if this is the first request received from the device assuming first - /// request only is set in the configuration. - /// - /// Context of the request. - /// True if this request is the first from the device. Otherwise false. - public static bool IsFirstTime(HttpContext context) - { - // If the parameter indicating only the first request should be redirect - // is false then return true as the implication is all requests should - // be redirected. - if (_firstRequestOnly == false) - return true; - - // Check the various methods of recording previous requests - // and return the revised value. - return IsFirstTime(context, Constants.AllowAlreadyAccessedCookie); - } - - /// - /// Determines if this is the first request received from the device. - /// - /// Context of the request. - /// True if the first time routine is allowed to use response cookies. - /// True if this request is the first from the device. Otherwise false. - public static bool IsFirstTime(HttpContext context, bool cookies) - { - // Try the context collection for the key. - object isFirstTime = context.Items[Constants.IsFirstTimeKey]; - - if (isFirstTime == null) - { - // If not set, get it and store. - isFirstTime = GetIsFirstTime(context, cookies); - context.Items[Constants.IsFirstTimeKey] = isFirstTime; - } - - // Return the value found. - return (bool)isFirstTime; - } - - /// - /// Sends any queued data and records the module being - /// disposed if debug enabled. - /// - public virtual void Dispose() - { - EventLog.Debug("Disposing Redirection Module"); - _newDevice.Dispose(); - } - - #endregion - - #region Internal and Private Methods - - /// - /// Record the new device if we're as certain as we can be that it is - /// not one we've processed already. - /// - /// Context of the request. - private void RecordNewDevice(HttpContext context) - { - try - { - if (_newDevice.Enabled && - context.Request.HttpMethod == "GET" && - context.Handler != null && - IsPageType(context.Handler.GetType()) && - IsFirstTime(context, false)) - _newDevice.RecordNewDevice(context.Request); - } - catch (Exception ex) - { - EventLog.Debug(ex); - } - } - - /// - /// Returns the Url stored in the context when the request first began before - /// other modules may have changed it. If not available returns the Url - /// using the current request value. - /// - /// The Context of the request. - /// The original Url of the request. - internal static string GetOriginalUrl(HttpContext context) - { - string originalUrl = context.Items[Constants.OriginalUrlKey] as string; - if (String.IsNullOrEmpty(originalUrl) == false) - return originalUrl; - return context.Request.Url.ToString(); - } - - /// - /// Evaluates the location that should be used when redirecting - /// the requesting context. If the locations collection does - /// not provide a location then the mobile home page url will - /// be used only if the device is a mobile. - /// - /// Context of the request. - /// The url to redirect the request to, if any. - private static string GetLocationUrl(HttpContext context) - { - string locationUrl = context.Items[Constants.LocationUrlKey] as string; - if (locationUrl == null) - { - // Use the mobileHomePageUrl setting as the default if this is a - // mobile device. - if (context.Request.Browser.IsMobileDevice) - locationUrl = _mobileHomePageUrl; - - // Try the locations collection first. - Location current = GetLocation(context); - if (current != null) - locationUrl = current.GetUrl(context); - - // Store so that the value does not need to be calculated next time. - context.Items[Constants.LocationUrlKey] = locationUrl; - } - return locationUrl; - } - - /// - /// Gets the name of the currently active location if one is being used. Only - /// used for debugging. - /// - /// Context of the request. - /// The name of the location. - private static string GetLocationName(HttpContext context) - { - Location current = GetLocation(context); - if (current != null) - return current._name; - return "default"; - } - - /// - /// Returns the location object to be used for the request if any. - /// - /// Context of the request. - /// Null if no location available, or the location object. - private static Location GetLocation(HttpContext context) - { - foreach (Location location in _locations) - { - if (location.GetIsMatch(context)) - return location; - } - return null; - } - - /// - /// Returns true if the request should be redirected. - /// - /// The HttpContext of the request. - /// True if the request should be redirected. - private static bool ShouldRequestRedirect(HttpContext context) - { - return context.Handler != null && - String.IsNullOrEmpty(GetLocationUrl(context)) == false && - IsPage(context) && - IsMobilePage(context) == false && - IsFirstTime(context) && - IsRestrictedPageForRedirect(context) == false; - } - - /// - /// Checks the page being requested to determine if it is eligable - /// for redirection. The mobile home page and the forms authentication - /// login page are restricted from redirection. If the response - /// is already being redirected it should be ignored. - /// - /// The context of the request. - /// True if the page is restricted from being redirected. - private static bool IsRestrictedPageForRedirect(HttpContext context) - { - Page page = context.Handler as Page; - string originalUrl = GetOriginalUrl(context); - bool value = context.Response.IsRequestBeingRedirected || - String.IsNullOrEmpty(context.Response.RedirectLocation) == false; - - string currentPage = null; - - if (page != null) - { - // Process a standard page derived from System.Web.UI.Page. - currentPage = page.ResolveUrl(context.Request.AppRelativeCurrentExecutionFilePath); - value = value || - page.ResolveUrl(GetLocationUrl(context)) == currentPage || - page.ResolveUrl(_formsLoginUrl) == currentPage || - page.ResolveUrl(GetLocationUrl(context)) == originalUrl || - page.ResolveUrl(_formsLoginUrl) == originalUrl; - } - - EventLog.Debug(String.Format("Request for '{0}' with handler type '{1}' and current page '{2}' is {3} restricted page for redirect.", - originalUrl, - context.Handler.GetType().FullName, - currentPage, - value ? "a" : "not a")); - - return value; - } - - /// - /// Determines if this is the first request received from the device. Should - /// only be called once pre request. - /// - /// Context of the request. - /// True is the method is allowed to use cookies. - /// True if this request is the first from the device. Otherwise false. - private static bool GetIsFirstTime(HttpContext context, bool cookies) - { - // Check to see if the Referrer URL contains the same host name - // as the current page request. If there is a match this request has - // come from another web page on the same host and is not the 1st request. - // The logic is only applied if an infinite timeout value is provided - // because using this method there is no way of knowing when the referrer - // url details were populated. - if (_redirectTimeout == 0 && - context.Request.UrlReferrer != null && - context.Request.UrlReferrer.Host == context.Request.Url.Host) - { - // In some situations the same web application may be split across - // different host names. Record the first time details using other - // methods to ensure this method returns the correct value when - // used with subsequent requests from the same device. - RecordFirstTime(context, cookies); - return false; - } - - // If the session is available and it's timeout is greater then or equal to - // the timeout to be used for redirection check to see if we have a - // session parameter indicating an expiry time for the current device. - // If the expiry time has not elpased then reset it and return a value - // indicating this is not the first time the device has been seen. - if (_redirectTimeout != 0 && - context.Session != null && - context.Session.Timeout >= _redirectTimeout && - context.Session[Constants.ExpiryTime] != null && - (long)context.Session[Constants.ExpiryTime] >= DateTime.UtcNow.Ticks) - { - // Update the session key to indicate a new expiry time. - SetSession(context); - - // Remove our own cookie from the response as it's not - // needed because the session is working. - if (cookies && context.Request.Cookies[Constants.AlreadyAccessedCookieName] != null) - WipeResponseCookie(context, context.Request.Cookies[Constants.AlreadyAccessedCookieName]); - - return false; - } - - // Check to see if our cookie is present from a previous request, that - // we're allowed to use cookies and that the expiry time is not passed. - // If it is present ensure it's expiry time is updated in the response. - HttpCookie alreadyAccessed = context.Request.Cookies[Constants.AlreadyAccessedCookieName]; - if (alreadyAccessed != null && - cookies && - long.Parse(alreadyAccessed.Value) >= DateTime.UtcNow.Ticks) - { - SetResponseCookie(context, alreadyAccessed); - - // Remove from the devices cache file as cookie can be used. - if (_requestHistory != null) - _requestHistory.Remove(context.Request); - - return false; - } - - // Check to see if the requested IP address and HTTP headers hashcode is - // on record as having been seen before. - if (_requestHistory != null && - _requestHistory.IsPresent(context.Request)) - { - // Update the cache and other methods in case they can - // be used in the future. - RecordFirstTime(context, cookies); - return false; - } - - // The url referrer, session and cookie checks have all failed. - // Record the device information using the session if available, a cookie and the - // request history cache file. - RecordFirstTime(context, cookies); - - return true; - } - - /// - /// Returns a long value representing the expiry date time to be used - /// for the current request. - /// - /// - private static long GetExpiryDateTime() - { - if (_redirectTimeout == 0) - return DateTime.MaxValue.Ticks; - return DateTime.UtcNow.AddMinutes(_redirectTimeout).Ticks; - } - - /// - /// Sets the session key to the expiry time for the current device. - /// - /// - private static void SetSession(HttpContext context) - { - context.Session[Constants.ExpiryTime] = GetExpiryDateTime(); - } - - /// - /// Removes the cookie from the browser by setting it's expiry time to a date - /// in the past. - /// - /// The context of the request. - /// The already accessed cookie. - private static void WipeResponseCookie(HttpContext context, HttpCookie alreadyAccessed) - { - alreadyAccessed.Expires = DateTime.MinValue; - context.Response.Cookies.Add(alreadyAccessed); - } - - /// - /// Sets the response cookie expiry time. - /// - /// The context of the request. - /// The already accessed cookie. - private static void SetResponseCookie(HttpContext context, HttpCookie alreadyAccessed) - { - alreadyAccessed.Expires = DateTime.MaxValue; - alreadyAccessed.Value = GetExpiryDateTime().ToString(); - context.Response.Cookies.Add(alreadyAccessed); - } - - /// - /// Records in the session (if present) and in a cookie - /// the requesting devices first request. This ensures subsequent calls - /// to IsFirstTime return the correct value. - /// - /// True if response cookies can be used. - /// The context of the request. - private static void RecordFirstTime(HttpContext context, bool cookies) - { - // Add a parameter to the session if available indicating the time that - // the device date should be remvoed from the session. - if (context.Session != null) - SetSession(context); - - // Add a cookie to the response setting the expiry time to the - // redirection timeout. - // Modified to check for existance of cookie to avoid recreating. - if (cookies) - SetResponseCookie(context, new HttpCookie(Constants.AlreadyAccessedCookieName)); - - // Add to the request history cache. - if (_requestHistory != null) - _requestHistory.Set(context.Request); - } - - /// - /// Checks the value is contained in the array. - /// - /// Value string. - /// Array of strings to be checked against. - /// True if the string is present. False if not. - private static bool IsInArray(string value, string[] array) - { -#if VER4 || VER35 - return array.Any(current => value == current); -#else - foreach (string current in array) - { - if (value == current) - return true; - } - return false; -#endif - } - - /// - /// Checks the array of page types to determine if the type past into the method - /// is in the array. Also checks basetypes where available. - /// - /// The type to be checked. - /// True is the request relates to a page. - internal static bool IsPageType(Type type) - { - if (type != null) - { - if (IsInArray(type.FullName, Constants.Pages)) - return true; - if (type.BaseType != null) - return IsPageType(type.BaseType); - } - return false; - } - - /// - /// Returns true if the request relates to a handler that relates to web page. - /// - /// The context associated with the Http request. - private static bool IsPage(HttpContext context) - { - if (context.Handler != null) - return IsPageType(context.Handler.GetType()); - return false; - } - - /// - /// Checks the type to see if it's one that matches a mobile web page. - /// - /// Type of class to check. - /// True if the type is a mobile web page. - internal static bool IsMobileType(Type type) - { - if (type != null) - { - if (IsInArray(type.FullName, Constants.MobilePages)) - return true; - if (type.BaseType != null) - return IsMobileType(type.BaseType); - } - return false; - } - - /// - /// Checks to see if the regular expression provided matches either the - /// relative executing path or the Url of the request. - /// - /// The HttpContext to be checked. - /// True if this request should be considered associated with - /// a page designed for mobile. - private static bool IsMobileRegexPage(HttpContext context) - { - if (_mobilePageRegex != null) - { - string originalUrl = GetOriginalUrl(context); - return _mobilePageRegex.IsMatch(context.Request.AppRelativeCurrentExecutionFilePath) || - _mobilePageRegex.IsMatch(originalUrl); - } - return false; - } - - #endregion - } -} diff --git a/Foundation/Mobile/Redirection/RequestHistory.cs b/Foundation/Mobile/Redirection/RequestHistory.cs deleted file mode 100644 index 76292bb..0000000 --- a/Foundation/Mobile/Redirection/RequestHistory.cs +++ /dev/null @@ -1,477 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -#region Usings - -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading; -using System.Web; -using FiftyOne.Foundation.Mobile.Configuration; - -#if VER4 - -using System.Linq; - -#endif - -#endregion - -namespace FiftyOne.Foundation.Mobile.Redirection -{ - /// - /// Class used to record details of devices that have already accessed the - /// mobile web site to determine if the request is the 1st one or a - /// subsequent one. - /// - internal class RequestHistory : IRequestHistory - { - #region Private Classes - - #region Nested type: PreviousRequests - - /// - /// Contains details of the previous devices held in the request history. - /// - private class PreviousRequests - { - internal readonly SortedList Requests = new SortedList(); - internal RequestRecord lastRequest = new RequestRecord(); - } - - #endregion - - #endregion - - #region Constants - - // The length of each request history record. - private const int RECORD_LENGTH = 16; - - // Number of ms to wait to open a file stream. - private const int TIMEOUT = 10000; - - // The number of minutes to wait between trimming the - // request history file. - - #endregion - - #region Fields - - // Stores the path for the devices synchronisation file. - private readonly string _syncFilePath; - - // Record the file exists to avoid a costly call to the file system. - private bool _syncFileExists = false; - - // The next time this process should service the sync file. - private DateTime _nextServiceTime = DateTime.MinValue; - - // The last time the sync file was modified. - private DateTime _lastWriteTime = DateTime.MinValue; - - /// - /// The number of minutes that should elapse before the record of - /// previous access for the device should be removed from all - /// possible storage mechanisims. - /// - private readonly int _redirectTimeout = 0; - - /// - /// Details about previous requests held in memory. - /// - private readonly PreviousRequests _previous = new PreviousRequests(); - - #endregion - - #region Constructor - - internal RequestHistory() - { - // Get the timeout used to remove devices. - _redirectTimeout = Manager.Redirect.Timeout; - - // Get the request history file and set to null it - // it's empty. - _syncFilePath = Support.GetFilePath(Manager.Redirect.DevicesFile); - if (_syncFilePath == String.Empty) - _syncFilePath = null; - - // Process the syncfile. - if (_syncFilePath != null) - ProcessSyncFile(); - } - - #endregion - - #region Internal Methods - - /// - /// Checks to find out if the device associated with the HttpRequest - /// has already been seen by the application. Always returns false - /// if the sync file has not been specified. - /// - /// HttpRequest to be checked. - /// True if the device associated with the request has been seen. - public bool IsPresent(HttpRequest request) - { - if (_syncFilePath != null) - { - RequestRecord record = new RequestRecord(request); - - // Check to see if new request data needs to be loaded. - RefreshSyncFile(); - - long expiryDateTime; - if (_previous.Requests.TryGetValue(record.Key, out expiryDateTime)) - { - // If redirect timeout is zero then simply check to see if the - // device is present in the list of previous devices. - if (_redirectTimeout == 0) - return true; - - // Is it still valid? - return (new DateTime(expiryDateTime).AddMinutes(_redirectTimeout)).Ticks >= - record.LastActiveDate; - } - } - return false; - } - - /// - /// Adds this device request to the previous devices list. - /// - /// HttpRequest of the device. - public void Set(HttpRequest request) - { - if (_syncFilePath != null) - { - RequestRecord record = new RequestRecord(request); - - // Get the latest data. - RefreshSyncFile(); - - // Add this most recent request to the sync file. - Add(record); - - // Check if the sync file needs to be serviced. - CheckIfServiceRequired(); - } - } - - /// - /// Removes this device request from the previous devices list. - /// - /// HttpRequest of the device. - public void Remove(HttpRequest request) - { - if (_syncFilePath != null) - { - RequestRecord record = new RequestRecord(request); - - // Get the latest data. - RefreshSyncFile(); - - // Does the device exist in the previous devices list? - if (_previous.Requests.ContainsKey(record.Key)) - { - // Set the last active date to zero so that it will be - // removed when the sync file is serviced. - record.LastActiveDate = 0; - - // Add this most recent request to the sync file. - Add(record); - } - } - } - - #endregion - - #region Private Methods - - /// - /// Checks to determine if new records need to be processed and if so - /// loads them into memory. - /// - private void RefreshSyncFile() - { - FileInfo info = new FileInfo(_syncFilePath); - if (info != null && info.LastWriteTimeUtc > _lastWriteTime) - { - ProcessSyncFile(); - _lastWriteTime = info.LastAccessTimeUtc; - } - } - - /// - /// Adds the current request record to the file containing details of - /// all the available requests. - /// - /// Record of the request to be set. - private void Add(object record) - { - if (record is RequestRecord) - { - using (FileStream stream = OpenSyncFilePath(FileMode.Append, FileAccess.Write, FileShare.ReadWrite)) - { - if (stream != null) - { - ((RequestRecord) record).Write(stream); - stream.Flush(); - stream.Close(); - } - } - } - } - - private void ProcessSyncFile() - { - // Record if the sync file exists to avoid repeated calls - // to the operating system. - if (_syncFileExists == false) - _syncFileExists = File.Exists(_syncFilePath); - - if (_syncFileExists) - { - // Used to indicate if the process should be repeated. - bool repeatProcess = false; - - // Lock the list of devices we're about to update to ensure they can't be - // changed by subsequent requests to this callback. - lock (_previous.Requests) - { - // Open the sync file for read access ensuring it's disposed - // as soon as possible. - using (FileStream stream = OpenSyncFilePath(FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - if (stream != null) - { - // Record the length of the file so that if it changes we can abandon this - // update and rely on a subsequent call to this methd to complete - // processing. - long length = stream.Length; - BinaryReader reader = new BinaryReader(stream); - RequestRecord record = new RequestRecord(); - RequestRecord firstDevice = null; - long rows = length/RECORD_LENGTH; - for (long row = 0; row < rows; row++) - { - // Read the current row in reverse order. Capture EOF exceptions - // in case the file length has changed since we started processing. - try - { - stream.Position = ((rows - row)*RECORD_LENGTH) - RECORD_LENGTH; - record.Read(reader); - } - catch (EndOfStreamException ex) - { - // The file has been trimmed by another process. Break and - // allow the resulting call to this event to complete - // processing. - EventLog.Debug(ex); - break; - } - - // If the current record is the same as the last one we got last time - // this method was called then stop processing more records. - if (record.CompareTo(_previous.lastRequest) == 0) - break; - - // Update the memory version. - if (record.LastActiveDate == 0) - { - // Remove from the device as the last active date is zero. - _previous.Requests.Remove(record.Key); - } - else - { - // Update or insert a new record. - if (_previous.Requests.ContainsKey(record.Key)) - _previous.Requests[record.Key] = record.LastActiveDate; - else - _previous.Requests.Add(record.Key, record.LastActiveDate); - } - - if (firstDevice == null) - firstDevice = new RequestRecord(record); - } - // If the length of the file hasn't changed during the processing - // then update the last device record to limit the number of rows - // examined in future file changes. - if (length == stream.Length && firstDevice != null) - _previous.lastRequest = firstDevice; - - // Signal to all the method again if the length of the file - // has changed during processing. - repeatProcess = length != stream.Length; - - reader.Close(); - stream.Close(); - } - } - } - // If the file was altered during the processing then call the method - // again to capture any new records. - if (repeatProcess) - ProcessSyncFile(); - } - } - - /// - /// Opens the file for read and if an exception is thrown will return null rather - /// than the exception. - /// - /// - private FileStream OpenSyncFilePath(FileMode mode, FileAccess access, FileShare share) - { - FileStream stream = null; - Random rnd = null; - if (_syncFilePath != null) - { - DateTime timeout = DateTime.UtcNow.AddMilliseconds(TIMEOUT); - { - try - { - stream = File.Open(_syncFilePath, mode, access, share); - } - catch (IOException ex) - { - EventLog.Info(ex); - stream = null; - if (rnd == null) - rnd = new Random(_lastWriteTime.GetHashCode()); - Thread.Sleep(rnd.Next(5)); - } - } - while (stream == null && DateTime.UtcNow < timeout); - if (stream == null) - throw new MobileException( - String.Format( - "Could not open request history file '{0}' in mode '{1}', with access '{2}' and share '{3}'.", - _syncFilePath, mode, access, share)); - } - return stream; - } - - /// - /// If the last time the devices file was serviced to remove old entries - /// is older than 1 minute start a thread to service the devices file and - /// remove old entries. If the redirect timeout is 0 indicating infinite - /// then nothing should be purged. - /// - private void CheckIfServiceRequired() - { - if (_nextServiceTime < DateTime.UtcNow) - { - long purgeDate; - - // If the last device has no active date use the current time for the purge date. - if (_previous.lastRequest.LastActiveDate == DateTime.MinValue.Ticks) - purgeDate = DateTime.UtcNow.Ticks - (TimeSpan.TicksPerMinute*_redirectTimeout); - // Otherwise use the last active devices active date for the purge date. - else - purgeDate = _previous.lastRequest.LastActiveDate - - (TimeSpan.TicksPerMinute*_redirectTimeout); - - ThreadPool.QueueUserWorkItem( - ServiceRequestHistory, - purgeDate); - } - } - - /// - /// Removes entries from the memory version and sync file that - /// are older than the purgeDate specified. - /// - /// - /// Date as a long used to determine if a request history - /// record is old and can be removed. - /// - private void ServiceRequestHistory(object purgeDate) - { - using (FileStream stream = OpenSyncFilePath(FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) - { - if (stream != null) - { - // Trim the sync file if it needs trimming and it has not - // been changed since the service routine started. - long originalLength = stream.Length; - byte[] buffer = ReadRecords(stream, (long) purgeDate); - if (buffer != null && stream.Length == originalLength) - { - stream.Position = 0; - stream.Write(buffer, 0, buffer.Length); - stream.Flush(); - stream.SetLength(buffer.Length); - stream.Flush(); - EventLog.Info(String.Format("Trimmed request history file '{0}' by removing {1} bytes.", - _syncFilePath, originalLength - buffer.Length)); - } - stream.Close(); - } - } - - // Remove old records from the memory version. - lock (_previous.Requests) - { - int index = 0; - while (index < _previous.Requests.Count) - { - if (_previous.Requests.Values[index] <= (long)purgeDate) - _previous.Requests.RemoveAt(index); - else - index++; - } - } - - // Set the next time to service the sync file using a random offset to - // attempt to avoid conflicts with other processes. - _nextServiceTime = DateTime.UtcNow.AddMinutes(1).AddSeconds(new Random().Next(30)); - } - - /// - /// Read the records that should be retained in the sync file. - /// - /// Stream for the sync file. - /// Date before which records should be removed. - /// - private static byte[] ReadRecords(FileStream stream, long purgeDate) - { - byte[] buffer = null; - long offset = 0; - BinaryReader reader = new BinaryReader(stream); - RequestRecord record = new RequestRecord(); - stream.Position = 0; - for (offset = 0; offset < stream.Length; offset += RECORD_LENGTH) - { - record.Read(reader); - // Check to see if the current record is newer than the purgeDate - // and isn't equal to zero. Zero date indicates the record should be - // removed from the history. - if (record.LastActiveDate > purgeDate && record.LastActiveDate != 0) - break; - } - - if (offset > 0 && offset < stream.Length) - { - int length = (int) (stream.Length - offset); - buffer = new byte[length]; - stream.Position = offset; - stream.Read(buffer, 0, length); - } - - return buffer; - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Mobile/Redirection/RequestRecord.cs b/Foundation/Mobile/Redirection/RequestRecord.cs deleted file mode 100644 index 8ceddf1..0000000 --- a/Foundation/Mobile/Redirection/RequestRecord.cs +++ /dev/null @@ -1,283 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.IO; -using System.Net; -using System.Text; -using System.Web; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -namespace FiftyOne.Foundation.Mobile.Redirection -{ - /// - /// Class used to convert a HttpRequest into a single long value that is - /// almost unique for the requesting device. Two devices that share the same - /// external IP address and HTTP headers will calculate to the same long value - /// so it may not always be unique. The number of handsets that fall into this - /// category should be sufficiently small enough for it not to present a - /// practical problem. - /// The date and time the request was received is also recorded to enable - /// out of date records to be removed from the list. - /// - internal class RequestRecord : IComparable - { - #region Constants - - // Headers used to create a hashcode based on their values when present. - private static readonly string[] ADDITIONAL_HEADERS = new string[] - { - // Common headers - "Accept-Language", - "Host", - "Via", - "UA", // Another user agent field - - // Common x headers - "x-forwarded-for", - // Originating IP of a client connection to the server - "x-source-id", - // Could be an internal MNO IP address - "x-wap-profile", - // A reference to the user-agent profile - "x-forwarded-host", // Origination host name - "x-forwarded-server", - // Originating server name - - // OpenWave gateway headers: - "x-up-calling-line-id", - // End users phone number - - // Nokia gateway headers: - "x-nokia-alias", - //The end users phone number. encrypted. - "x-nokia-msisdn", - // The users phone number in plain text. - "x-nokia-ipaddress", // Internal IP address - "x-nokia-imsi", // Imsi value - - // Other headers: - "x-imsi", - // The imsi number. Identifies the end user. - "x-msisdn", // The end users phone number - - // AvantGo headers. - "x-avantgo-userid" - // Identifying the end user. - }; - - #endregion - - #region Fields - - // The key for this device record. - private long _key; - - // The date and time the device was last active. - private long _lastActiveDate; - - #endregion - - #region Constructors - - /// - /// Creates a new empty instance of class. - /// - protected internal RequestRecord() - { - } - - /// - /// Constructs a new instance of class. - /// Copies the values of the provided to - /// the new instance. - /// - /// - protected internal RequestRecord(RequestRecord recordToCopy) - { - _key = recordToCopy.Key; - _lastActiveDate = recordToCopy.LastActiveDate; - } - - /// - /// If the IP address is IPv4 (4 bytes) then use the ip address as the high order - /// bytes of the value and the hashcode as the low order bytes. - /// If the IP address is IPv6 (8 bytes) then covert the bytes to a 64 bit - /// integer. - /// If anything else which we can't imagine use a hashcode of the string value. - /// - /// - protected internal RequestRecord(HttpRequest request) - { - byte[] buffer = new byte[8]; - byte[] address = IPAddress.Parse(request.UserHostAddress).GetAddressBytes(); - - // If 4 bytes use these as the high order bytes and a hashcode from the - // HTTP header as the low order bytes. - if (address.Length == 4) - { - for (int i = 0; i < 4; i++) - buffer[7 - i] = address[i]; - SetHashCode(buffer, request); - _key = BitConverter.ToInt64(buffer, 0); - } - - else if (address.Length == 8) - { - // Use the value unaltered as a 64 bit value. - _key = BitConverter.ToInt64(address, 0); - } - - else - { - // Create hashcode from the address. - int hashcode = 0; - foreach (byte current in address) - hashcode += current; - - // Merge the address hashcode and the request hashcode. - byte[] hashcodeArray = BitConverter.GetBytes(hashcode); - for (int i = 0; i < 4; i++) - buffer[4 + i] = hashcodeArray[i]; - SetHashCode(buffer, request); - - _key = BitConverter.ToInt64(buffer, 0); - } - - // Set the last time this request was seen. - _lastActiveDate = DateTime.UtcNow.Ticks; - } - - protected internal RequestRecord(BinaryReader reader) - { - _key = reader.ReadInt64(); - _lastActiveDate = reader.ReadInt64(); - } - - #endregion - - #region Properties - - /// - /// The unique key for the device. - /// - protected internal long Key - { - get { return _key; } - } - - /// - /// The date and device was last seen as active expressed - /// as a long value. - /// - protected internal long LastActiveDate - { - get { return _lastActiveDate; } - set { _lastActiveDate = value; } - } - - /// - /// The date and device was last seen as active expressed - /// as a DateTime value. - /// - protected internal DateTime LastActiveDateAsDateTime - { - get { return new DateTime(_lastActiveDate); } - set { _lastActiveDate = value.Ticks; } - } - - #endregion - - #region Methods - - protected internal void Read(BinaryReader reader) - { - _key = reader.ReadInt64(); - _lastActiveDate = reader.ReadInt64(); - } - - protected internal void Write(Stream stream) - { - BinaryWriter writer = new BinaryWriter(stream); - writer.Write(_key); - writer.Write(_lastActiveDate); - } - - /// - /// Adds the hashcode of the relevent header fields as the low order - /// bytes of the array. - /// - /// Buffer used to set the bytes. - /// HttpRequest to calculate a hashcode from. - private static void SetHashCode(byte[] buffer, HttpRequest request) - { - StringBuilder headers = new StringBuilder(); - headers.Append(request.UserAgent); - -#if VER4 || VER35 - foreach (string key in ADDITIONAL_HEADERS.Where(key => request.Headers[key] != null)) - { - headers.Append(key).Append(request.Headers[key]); - } -#else - foreach (string key in ADDITIONAL_HEADERS) - { - if (request.Headers[key] != null) - headers.Append(key).Append(request.Headers[key]); - } -#endif - - int hashCode = headers.ToString().GetHashCode(); - buffer[0] = (byte)(hashCode); - buffer[1] = (byte)(hashCode >> 8); - buffer[2] = (byte)(hashCode >> 16); - buffer[3] = (byte)(hashCode >> 24); - } - - #endregion - - #region IComparable Members - - /// - /// Compares one request to another to determine if they are the same. - /// - /// The object being compared. - /// If the object contains the same value as this instance. - public int CompareTo(object obj) - { - RequestRecord candidate = obj as RequestRecord; - if (candidate != null) - { - if (candidate.LastActiveDate < LastActiveDate) - return -1; - if (candidate.LastActiveDate > LastActiveDate) - return 1; - if (candidate.Key < Key) - return -1; - if (candidate.Key > Key) - return 1; - return 0; - } - throw new MobileException( - String.Format( - "Can not compare object of type '{0}' with '{1}'.", - obj.GetType(), - GetType())); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/PDA.ico b/Foundation/PDA.ico deleted file mode 100644 index 9c599a6..0000000 Binary files a/Foundation/PDA.ico and /dev/null differ diff --git a/Foundation/Properties/AssemblyInfo.cs b/Foundation/Properties/AssemblyInfo.cs deleted file mode 100644 index 78157be..0000000 --- a/Foundation/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,43 +0,0 @@ -#region Usings - -using System.Reflection; -using System.Resources; -using System.Runtime.InteropServices; -using System.Security; - -#endregion - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("51degrees.mobi - Foundation")] -[assembly: AssemblyDescription("51degrees.mobi - Foundation Open Source")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("51 Degrees Mobile Experts Limited")] -[assembly: AssemblyProduct("51degrees.mobi - Foundation")] -[assembly: AssemblyCopyright("Copyright 51 Degrees Mobile Experts Limited 2009 - 2013")] -[assembly: AssemblyTrademark("51Degrees")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("71439680-d7e5-4497-96ff-3acfb9f68a72")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision - -[assembly: AssemblyVersion("2.1.19.4")] -[assembly: AssemblyFileVersion("2.1.19.4")] -[assembly: NeutralResourcesLanguage("en-GB")] -[assembly: AllowPartiallyTrustedCallers] diff --git a/Foundation/Properties/BinaryConstants.cs b/Foundation/Properties/BinaryConstants.cs deleted file mode 100644 index 6fe7050..0000000 --- a/Foundation/Properties/BinaryConstants.cs +++ /dev/null @@ -1,32 +0,0 @@ -/* ********************************************************************* - * 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 System; - -namespace FiftyOne.Foundation.Mobile.Detection.Binary -{ - /// - /// Constants used by the binary file format. - /// - public class BinaryConstants - { - /// - /// The format version of the binary data contained in the file header. This much match with the data - /// file for the file to be read. - /// - public static readonly Version FormatVersion = new Version(1, 0); - - /// - /// The name of the embedded resource containing the Lite device data compiled into the assembly. - /// - public const string EmbeddedDataResourceName = "FiftyOne.Foundation.Mobile.Detection.Binary.Resources.51Degrees.mobi-Lite.dat"; - } -} diff --git a/Foundation/Properties/Constants.cs b/Foundation/Properties/Constants.cs deleted file mode 100644 index 0d38fa6..0000000 --- a/Foundation/Properties/Constants.cs +++ /dev/null @@ -1,31 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile -{ - internal static class Constants - { - /// - /// Array of file locations to check for configuration information. - /// - internal static readonly string[] ConfigFileNames = new string[] { - "~/51Degrees.mobi.config", - "~/App_Data/51Degrees.mobi.config", - "~/Web.config" }; - -#if AZURE - /// - /// Name for Azure cloud storage - /// - internal const string AZURE_STORAGE_NAME = "fiftyonedegrees"; -#endif - } -} diff --git a/Foundation/Properties/DetectionConstants.cs b/Foundation/Properties/DetectionConstants.cs deleted file mode 100644 index b9ac2a4..0000000 --- a/Foundation/Properties/DetectionConstants.cs +++ /dev/null @@ -1,211 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; - -namespace FiftyOne.Foundation.Mobile.Detection -{ - /// - /// Constants used to control major aspects of redirection. - /// - public static class Constants - { - #region Public Constants - - /// - /// The default path to use for the binary data file. - /// - public const string DefaultBinaryFilePath = "~/App_Data/51Degrees-Premium.dat"; - - /// - /// The preferred name of the licence key file. - /// - public const string LicenceKeyFileName = "51Degrees.mobi.lic"; - - /// - /// The character used to seperate property values when concatenated as a single string. - /// - public const string ValueSeperator = "|"; - - /// - /// The character used to seperate profile integer values in the device id. - /// - public const string ProfileSeperator = "-"; - - /// - /// The key used to identify the list of 51Degrees.mobi properties in the - /// capabilities collection of the HttpBrowserCapabilities class. - /// - public const string FiftyOneDegreesProperties = "51Degrees.mobi"; - - /// - /// The length of time taken to locate the device returned. This property is - /// set in the MobileCapabilities class and is not part of the Providers. - /// - public const string DetectionTimeProperty = "DetectionTime"; - - /// - /// The confidence of the results found. - /// - public const string ConfidenceProperty = "MatchConfidence"; - - /// - /// The difference between the user agent requested and the one found. - /// - public const string DifferenceProperty = "MatchDifference"; - - /// - /// The name of the unique property key used to return the device id. - /// - public const string DeviceId = "Id"; - - /// - /// A regular expression used to valid licence key formats. - /// - public const string LicenceKeyValidationRegex = @"^[A-Z\d]+$"; - - #endregion - - #region Internal Constants - - /// - /// If premium data is being used with Foundation the licence key - /// can be provided in the following constant or in a file with the - /// extension .lic in the bin folder. - /// - internal const string PremiumLicenceKey = ""; - - /// - /// The URL to use to get the latest device data from if a Premium licence key is provided. - /// - internal const string AutoUpdateUrl = "https://51degrees.mobi/Products/Downloads/Premium.aspx"; - - /// - /// The length of time to wait before starting the auto update - /// process. Set to zero to disable auto update. - /// - internal static readonly TimeSpan AutoUpdateDelayedStart = - new TimeSpan(0, 0, 20); - - /// - /// The length of time to wait before checking for a newer - /// version of the device data file. - /// - internal static readonly TimeSpan AutoUpdateWait = - new TimeSpan(6, 0, 0, 0); - - /// - /// The length of time to sleep before checking for new device - /// data again. - /// - internal static readonly TimeSpan AutoUpdateSleep = - new TimeSpan(0, 0, 6, 0); - - /// - /// The length of time to wait before setting the local data file - /// check process. - /// - internal static readonly TimeSpan FileUpdateDelayedStart = - new TimeSpan(0, 0, 2, 0); - - /// - /// The length of time between local data file checks. - /// - internal static readonly TimeSpan FileUpdateSleep = - new TimeSpan(0, 0, 2, 0); - - /// - /// Length of time in ms the new devices thread should wait for a response from the - /// web server used to record new device information. - /// - internal const int NewUrlTimeOut = 10000; - - /// - /// The maximum number of continous timeouts that are allowed - /// before the new device function is disabled. - /// - internal const int NewUrlMaxTimeouts = 10; - - /// - /// Forces the useragent matcher to use a single thread if - /// multiple processors are available. - /// - internal const bool ForceSingleProcessor = false; - - /// - /// Improves performance of segment handlers by storing the results of - /// useragent segment matches to improve performance at the expense - /// of memory consumption. Set this to false to reduce memory consumption. - /// - internal const bool StoreSegmentResults = true; - - /// - /// Array of HTTP headers that represent the useragent string of the - /// device rather than the browser. - /// - internal static readonly string[] DeviceUserAgentHeaders = new string[] - { - "Device-Stock-UA", - "x-Device-User-Agent", - "X-Device-User-Agent", - "X-OperaMini-Phone-UA" - }; - - /// - /// The Http header field that contains the user agent. - /// - internal const string UserAgentHeader = "User-Agent"; - - /// - /// The URL usage sharing information should be sent to. - /// - internal const string NewDevicesUrl = "http://devices.51degrees.mobi/new.ashx"; - - /// - /// The detail that should be provided relating to new devices. - /// - internal const NewDeviceDetails NewDeviceDetail = NewDeviceDetails.Maximum; - - /// - /// The number of requests that should be held in the queue before - /// transmission. - /// - internal const int NewDeviceQueueLength = 50; - - /// - /// The name of the property which contains the user agent profile. - /// - internal static readonly string[] UserAgentProfiles = new string[] { "UserAgentProfile" }; - - /// - /// Extensions to indicate a file is compressed. - /// - internal static readonly List CompressedFileExtensions = new List(new string[] { ".gz" }); - - /// - /// A list of properties to exclude from the AllProperties results. - /// - internal static readonly List ExcludePropertiesFromAllProperties = new List(new string[] { "" }); - - /// - /// An array of default values for properties where they can't be found - /// and a value must be provided. - /// - internal static readonly string[,] DefaultPropertyValues = new string[,] { - { "screenPixelsHeight", "480" }, - { "screenPixelsWidth", "640" }, - { "screenCharactersHeight", "40" }, - { "screenCharactersWidth", "80" } }; - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/Properties/RedirectionConstants.cs b/Foundation/Properties/RedirectionConstants.cs deleted file mode 100644 index 986052d..0000000 --- a/Foundation/Properties/RedirectionConstants.cs +++ /dev/null @@ -1,80 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile.Redirection -{ - internal static class Constants - { - - /// - /// Full type names of classes representing mobile - /// page handlers. - /// - internal static readonly string[] MobilePages = new string[] { - "System.Web.UI.MobileControls.MobilePage", - "FiftyOne.Framework.Mobile.Page" - }; - - /// - /// Full type names of classes representing standard - /// page handlers. - /// - internal static readonly string[] Pages = new string[] - { - "System.Web.UI.Page", - "System.Web.Mvc.MvcHandler", - "System.Web.Mvc.MvcHttpHandler", - "System.Web.UI.MobileControls.MobilePage", - "System.Web.WebPages.WebPageHttpHandler", - "Orchard.Mvc.Routes.ShellRoute.HttpAsyncHandler" - }; - - /// - /// The key in the Items collection of the requesting context used to - /// store result of the is first time check. - /// - internal const string IsFirstTimeKey = "51D_Is_First_Time"; - - /// - /// The key in the Items collection of the requesting context used to - /// store the Url originally requested by the browser. - /// - internal const string OriginalUrlKey = "51D_Original_Url"; - - /// - /// The property name to use to access the original Url for the request. - /// - internal const string OriginalUrlSpecialProperty = "origUrl"; - - /// - /// The key in the Items collection of the requesting context used to - /// store the home page Url for a possible redirection. - /// - internal const string LocationUrlKey = "51D_Location_Url"; - - /// - /// Set the UTC date and time that details of the device should be removed - /// from all storage mechanisims. - /// - internal const string ExpiryTime = "51D_Expiry_Time"; - - /// - /// Used to indicate the device has already accessed the web site. - /// - internal const string AlreadyAccessedCookieName = "51D"; - - /// - /// Used to control if the already accessed cookie should be included - /// in the response. - /// - internal const bool AllowAlreadyAccessedCookie = true; - } -} diff --git a/Foundation/Properties/RetailerConstants.cs b/Foundation/Properties/RetailerConstants.cs deleted file mode 100644 index 96d7fe4..0000000 --- a/Foundation/Properties/RetailerConstants.cs +++ /dev/null @@ -1,26 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation -{ - internal static class RetailerConstants - { - /// - /// The default url to send customers to when they want to find out more and purchase. - /// - internal const string RetailerUrl = "http://51degrees.mobi/Purchase/PremiumData.aspx"; - - /// - /// The default name of the retailer. - /// - internal const string RetailerName = "Visit the 51Degrees.mobi store"; - } -} \ No newline at end of file diff --git a/Foundation/Properties/UIConstants.cs b/Foundation/Properties/UIConstants.cs deleted file mode 100644 index a75e279..0000000 --- a/Foundation/Properties/UIConstants.cs +++ /dev/null @@ -1,184 +0,0 @@ -/* ********************************************************************* - * 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 System.Collections.Generic; -namespace FiftyOne.Foundation.UI -{ - internal class Constants - { - /// - /// A list of all properties that need to be present in Premium data. - /// - internal static readonly string[] Premium = null; - - /// - /// List of properties included in the CMS product. - /// - internal static readonly string[] CMS = new string[] { - "IsConsole", - "IsEReader", - "IsTablet", - "IsSmartPhone", - "IsSmallScreen", - "SuggestedLinkSizePixels", - "SuggestedLinkSizePoints" }; - - /// - /// List of properties which are associated with the physical hardware. - /// - internal static readonly string[] Hardware = new string[] { - "HardwareVendor", - "HardwareModel", - "HardwareName", - "HardwareFamily", - "HardwareImages", - "BitsPerPixel", - "Has3DCamera", - "Has3DScreen", - "HasCamera", - "HasClickWheel", - "HasKeypad", - "HasQwertyPad", - "HasTouchScreen", - "HasTrackPad", - "HasVirtualQwerty", - "IsConsole", - "IsCrawler", - "IsEReader", - "IsMobile", - "IsTablet", - "IsSmartPhone", - "IsSmallScreen", - "ReleaseMonth", - "ReleaseYear", - "ScreenMMHeight", - "ScreenMMWidth", - "ScreenMMDiagonal", - "ScreenInchesHeight", - "ScreenInchesWidth", - "ScreenInchesDiagonal", - "ScreenPixelsHeight", - "ScreenPixelsWidth", - "SuggestedImageButtonHeightMms", - "SuggestedImageButtonHeightPixels", - "SuggestedLinkSizePixels", - "SuggestedLinkSizePoints", - "SupportedBearers", - "Popularity", - "HasNFC"}; - - /// - /// List of properties associated with the operating system - /// or software. - /// - internal static readonly string[] Software = new string[] { - "PlatformVendor", - "PlatformName", - "PlatformVersion", - "CLDC", - "MIDP"}; - - /// - /// List of properties associated with the browser. - /// - internal static readonly string[] Browser = new string[] { - "BrowserVendor", - "BrowserName", - "BrowserVersion", - "AjaxRequestType", - "CookiesCapable", - "HtmlVersion", - "IsEmailBrowser", - "Javascript", - "JavascriptCanManipulateCSS", - "JavascriptCanManipulateDOM", - "JavascriptGetElementById", - "JavascriptSupportsEventListener", - "JavascriptSupportsEvents", - "JavascriptSupportsInnerHtml", - "JavascriptVersion", - "jQueryMobileSupport", - "LayoutEngine", - "AnimationTiming", - "BlobBuilder", - "CssBackground", - "CssBorderImage", - "CssCanvas", - "CssColor", - "CssColumn", - "CssFlexbox", - "CssFont", - "CssImages", - "CssMediaQueries", - "CssMinMax", - "CssOverflow", - "CssPosition", - "CssText", - "CssTransforms", - "CssTransitions", - "CssUI", - "DataSet", - "DataUrl", - "DeviceOrientation", - "FileReader", - "FileSaver", - "FileWriter", - "FormData", - "Fullscreen", - "GeoLocation", - "History", - "Html5", - "Html-Media-Capture", - "Iframe", - "IndexedDB", - "Json", - "Masking", - "PostMessage", - "Progress", - "Prompts", - "Selector", - "Svg", - "TouchEvents", - "Track", - "Video", - "Viewport", - "SupportsTls/Ssl" - }; - - /// - /// List of properties associated wtih the type of content - /// the browser/device can display. - /// - internal static readonly string[] Content = new string[] { - "CcppAccept", - "StreamingAccept" }; - - /// - /// The 51Degrees.mobi thumbnail logo. - /// - internal const string Logo = "http://download.51degrees.mobi/51Degrees%20Logo%20Small.png"; - - /// - /// Constructs the static class setting the Premium property - /// to include all the other string arrays. - /// - static Constants() - { - List temp = new List(); - temp.AddRange(Hardware); - temp.AddRange(Software); - temp.AddRange(Browser); - temp.AddRange(Content); - temp.Sort(); - Premium = temp.ToArray(); - } - } -} diff --git a/Foundation/Properties/XmlConstants.cs b/Foundation/Properties/XmlConstants.cs deleted file mode 100644 index 2cbba14..0000000 --- a/Foundation/Properties/XmlConstants.cs +++ /dev/null @@ -1,193 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.Mobile.Detection.Xml -{ - /// - /// Holds all constants and read only strings used throughout this library. - /// - public static class Constants - { - /// - /// The top level element name used to enclose all other elements. - /// - public const string TopLevelElementName = "fiftyOneDegrees"; - - /// - /// The element name of the properties section. - /// - public const string PropertiesElementName = "properties"; - - /// - /// The element name of the header section. - /// - public const string HeaderElementName = "header"; - - /// - /// Element name used to especify a property inside the xml file. - /// - public const string PropertyElementName = "property"; - - /// - /// Element name used to specify a value inside the xml file. - /// - public const string ValueElementName = "value"; - - /// - /// Attribute name used to indicate if the property supports multiple values. - /// - public const string ListAttributeName = "list"; - - /// - /// Attribute name used to indicate if the property is mandatory. - /// - public const string MandatoryAttributeName = "mandatory"; - - /// - /// Attribute name used to indicate if the values are suitable to be shown to customers. - /// - public const string ShowValuesAttributeName = "showValues"; - - /// - /// Attribute name used to indicate the description. - /// - public const string DescriptionAttributeName = "description"; - - /// - /// Attribute name used to indicate the url. - /// - public const string UrlAttributeName = "url"; - - /// - /// Element name used to specify all profiles inside the xml file. - /// - public const string ProfilesElementName = "profiles"; - - /// - /// Element names used to specify all handlers inside the xml file. - /// - public const string HandlersElementName = "handlers"; - - /// - /// Element name used to specify a profile inside the xml file. - /// - public const string ProfileElementName = "profile"; - - /// - /// Attribute name used to specify a fall back inside the xml file. - /// - public const string ParentAttributeName = "parent"; - - /// - /// Attribute name used to especify an id inside the xml file. - /// - public const string IdAttributeName = "id"; - - /// - /// Attribute name used to especify a name inside the xml file. - /// - public const string NameAttributeName = "name"; - - /// - /// The type of handler. - /// - public const string TypeAttributeName = "type"; - - /// - /// The relative confidence the handler should be given - /// compare to others. - /// - public const string ConfidenceAttributeName = "confidence"; - - /// - /// Attribute name used to determine if user agent profile should - /// also be checked when matching HTTP headers. - /// - public const string CheckUserAgentProfileAttibuteName = "checkUAProf"; - - /// - /// Element name for a list of patterns which are supported by - /// the handler. - /// - public const string CanHandleElementName = "canHandle"; - - /// - /// Element name for a list of patterns which indicate the handler - /// can't be used. - /// - public const string CantHandleElementName = "cantHandle"; - - /// - /// The tolerance to be used for the initial string match. - /// - public const string ToleranceAttributeName = "tolerance"; - - /// - /// A collection os segment patterns and weights. - /// - public const string RegexSegmentsElementName = "regexSegments"; - - /// - /// A specific segment to be used with a segmented handler. - /// - public const string RegexSegmentElementName = "regexSegment"; - - /// - /// Initial string used to indicate a regex element. - /// - public const string RegexPrefix = "regex"; - - /// - /// Attribute name used to provide a regular expression. - /// - public const string PatternAttributeName = "pattern"; - - /// - /// Attribute name used to provide the weight of an edit distance result. - /// - public const string WeightAttributeName = "weight"; - - /// - /// Attribute name used to specify a user agent inside the xml file. - /// - public const string UserAgentAttributeName = "UA"; - - /// - /// Attribute name used to specify a value inside the xml file. - /// - public const string ValueAttributeName = "value"; - - /// - /// Attribute name used to provide the date the XML file was published. - /// - public const string PublishedDateAttributeName = "date"; - - /// - /// Attribute name used to provide the data set name in the XML when publishing. - /// - public const string DataSetNameAttributeName = "DatasetName"; - - /// - /// The name of the element used to store the version of the data. - /// - public const string VersionElementName = "version"; - - /// - /// The name of the element used to store the copyright or licence. - /// - public const string CopyrightElementName = "copyright"; - - /// - /// The name of the element used to store each handler. - /// - public const string HandlerElementName = "handler"; - } -} \ No newline at end of file diff --git a/Foundation/UI/DataProvider.cs b/Foundation/UI/DataProvider.cs deleted file mode 100644 index 36fef78..0000000 --- a/Foundation/UI/DataProvider.cs +++ /dev/null @@ -1,579 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using FiftyOne.Foundation.Mobile.Detection; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -namespace FiftyOne.Foundation.UI -{ - /// - /// Static class providing UI optimised methods for accessing device data. - /// - public static class DataProvider - { - #region Fields - - // Lock used when loading the vendors. - private static readonly object _lock = new object(); - - // A list of hardware vendors and the number of devices assigned to each. - private static SortedList> _vendors = null; - private static List _devices; - - #endregion - - #region Properties - - /// - /// Returns the active provider for the factory. - /// - public static Provider Provider - { - get { return Factory.ActiveProvider; } - } - - /// - /// Returns a list of those properties that relate to the device hardware. - /// - public static IList HardwareProperties - { - get - { -#if VER4 || VER35 - return Provider.Properties.Values.Where(i => - Constants.Hardware.Contains(i.Name) && - i.Values.Count > 0).OrderBy(i => i.Name).ToList(); -#else - return GetProperties(Provider.Properties.Values, Constants.Hardware); -#endif - } - } - - /// - /// Returns a list of the properties that relate to the software. - /// - public static IList SoftwareProperties - { - get - { -#if VER4 || VER35 - return Provider.Properties.Values.Where(i => - Constants.Software.Contains(i.Name) && - i.Values.Count > 0).OrderBy(i => i.Name).ToList(); -#else - return GetProperties(Provider.Properties.Values, Constants.Software); -#endif - } - } - - /// - /// Returns a list of the properties that relate to the browser. - /// - public static IList BrowserProperties - { - get - { -#if VER4 || VER35 - return Provider.Properties.Values.Where(i => - Constants.Browser.Contains(i.Name) && - i.Values.Count > 0).OrderBy(i => i.Name).ToList(); -#else - return GetProperties(Provider.Properties.Values, Constants.Browser); -#endif - } - } - - /// - /// Returns a list of the properties that relate to the content. - /// - public static IList ContentProperties - { - get - { -#if VER4 || VER35 - return Provider.Properties.Values.Where(i => - Constants.Content.Contains(i.Name) && - i.Values.Count > 0).OrderBy(i => i.Name).ToList(); -#else - return GetProperties(Provider.Properties.Values, Constants.Content); -#endif - } - } - - /// - /// Returns true if cms data is being used by the active provider. - /// - public static bool IsCms - { - get - { - // Try the new data set name property first. - if (Provider.DataSetName.Equals("CMS")) - return true; - -#if VER4 || VER35 - return IsPremium == false && - (from i in Provider.Properties.Values select i.Name).Intersect(UI.Constants.CMS).Count() == UI.Constants.CMS.Length; -#else - if (IsPremium) - return false; - int count = 0; - foreach (string property in UI.Constants.CMS) - { - foreach (Property current in Provider.Properties.Values) - { - if (current.Name.Equals(property, StringComparison.InvariantCultureIgnoreCase)) - { - count++; - break; - } - } - } - return count == UI.Constants.CMS.Length; -#endif - } - } - - /// - /// Returns true if premium data is being used by the active provider. The number - /// of available properties is used to determine if this is true. - /// - public static bool IsPremium - { - get - { - // Try the new data set name property first. - if (Provider.DataSetName.Equals("Premium")) - return true; - -#if VER4 || VER35 - string[] shared = (from i in Provider.Properties.Values select i.Name). - Intersect(UI.Constants.Premium). - OrderBy(i => i).ToArray(); - return shared.Length == UI.Constants.Premium.Length; -#else - int count = 0; - foreach (string property in UI.Constants.Premium) - { - foreach (Property current in Provider.Properties.Values) - { - if (current.Name.Equals(property, StringComparison.InvariantCultureIgnoreCase)) - { - count++; - break; - } - } - } - return count == UI.Constants.Premium.Length; -#endif - } - } - - /// - /// Returns a list of all the devices. - /// - public static List Devices - { - get - { - if (_devices == null) - { - lock (_lock) - { - if (_devices == null) - { - _devices = new List(); - foreach (KeyValuePair> vendor in Vendors) - _devices.AddRange(vendor.Value); - } - } - } - return _devices; - } - } - - /// - /// Returns a list of the available hardware vendors. - /// - public static SortedList> Vendors - { - get - { - if (_vendors == null) - { - lock (_lock) - { - if (_vendors == null) - { - _vendors = new SortedList>(); -#if VER4 || VER35 - var property = Provider.Properties.Values.FirstOrDefault(i => - i.Name == "HardwareVendor"); - if (property != null) - { - foreach (var value in property.Values.Where(i => - i.Name != "Unknown" && - i.Devices.Count > 0)) - _vendors.Add(value, GetVendorDevices(value)); - } -#else - Property property = GetFirstWhereNameEquals(Provider.Properties.Values, "HardwareVendor"); - if (property != null) - { - foreach (Value value in property.Values) - if (value.Name != "Unknown" && - value.Devices.Count > 0) - _vendors.Add(value, GetVendorDevices(value)); - } -#endif - } - } - } - return _vendors; - } - } - - #endregion - - #region Public Methods - - /// - /// Returns the device ID for the device matching the user agent provided. - /// - /// - /// - public static string GetDeviceID(string userAgent) - { - BaseDeviceInfo device = Provider.GetDeviceInfo(userAgent); - if (device != null) - return device.DeviceId; - return null; - } - - /// - /// Get the property for the name provided. - /// - /// - /// - public static Property GetProperty(string name) - { -#if VER4 || VER35 - return Factory.ActiveProvider.Properties.Values.FirstOrDefault(i => - i.Name == name); -#else - return GetFirstWhereNameEquals(Factory.ActiveProvider.Properties.Values, name); -#endif - } - - /// - /// Returns properties based on the unique ID of the device. - /// - /// - /// - public static Device GetDeviceFromDeviceID(string deviceID) - { - BaseDeviceInfo device = Provider.GetDeviceInfoByID(deviceID); - if (device != null) - return new Device(device); - return null; - } - - /// - /// Returns the first device which contains the profile ID passed. - /// - /// - /// - public static Device GetDeviceFromProfileID(string profileID) - { - BaseDeviceInfo baseDevice = null; - - // Try the profiles without unknown software and browsers first. -#if VER4 || VER35 - baseDevice = Provider.FindDevices(profileID).FirstOrDefault(i => - i.ProfileIDs[0] == profileID && - new Device(i).SoftwareBrowserCaption.Contains("Unknown") == false); -#else - foreach (BaseDeviceInfo device in Provider.FindDevices(profileID)) - { - if (device.ProfileIDs[0] == profileID && - new Device(device).Caption.Contains("Unknown") == false) - { - baseDevice = device; - break; - } - } -#endif - - // If not found drop the requirement for no unknown browsers or software. - if (baseDevice == null) -#if VER4 || VER35 - baseDevice = Provider.FindDevices(profileID).FirstOrDefault(i => - i.ProfileIDs[0] == profileID); -#else - foreach (BaseDeviceInfo device in Provider.FindDevices(profileID)) - { - if (device.ProfileIDs[0] == profileID) - { - baseDevice = device; - break; - } - } -#endif - - return new Device(baseDevice); - } - - /// - /// Returns a device based on the hardware vendor and model seperated by a pipe sign. - /// - /// - /// - /// - public static Device GetDeviceFromModel(string vendor, string model) - { - BaseDeviceInfo device = null; - // Try the profiles without unknown software and browsers first. -#if VER4 || VER35 - device = Provider.Devices.FirstOrDefault(i => - new Device(i).HardwareVendor == vendor && - new Device(i).HardwareModel == model && - new Device(i).SoftwareBrowserCaption.Contains("Unknown") == false); -#else - foreach (BaseDeviceInfo item in Provider.Devices) - { - Device newDevice = new Device(item); - if (newDevice.HardwareVendor == vendor && - newDevice.HardwareModel == model && - newDevice.Caption.Contains("Unknown") == false) - { - device = item; - break; - } - } -#endif - - // If not found drop the requirement for no unknown browsers or software. -#if VER4 || VER35 - if (device == null) - device = Provider.Devices.FirstOrDefault(i => - new Device(i).HardwareVendor == vendor && - new Device(i).HardwareModel == model); -#else - foreach (BaseDeviceInfo item in Provider.Devices) - { - Device newDevice = new Device(item); - if (newDevice.HardwareVendor == vendor && - newDevice.HardwareModel == model) - { - device = item; - break; - } - } -#endif - // The device does not exist. - if (device == null) - return null; - - return new Device(device); - } - - /// - /// Get any device which has the same hardware model as the one provided. - /// - /// The device which others should relate to. - /// A list of related devices. - public static List GetRelatedInfo(Device device) - { - List list = new List(); - if (device.HardwareModel != null) - { -#if VER4 || VER35 - var related = (from i in Provider.FindDevices("HardwareModel", device.HardwareModel) - where i.DeviceId != device.DeviceID - select new Device(i)).ToArray(); - foreach (var item in related.Where(i => - CompareRelatedDevices(i, device))) - list.Add(item); -#else - foreach (BaseDeviceInfo item in Provider.FindDevices("HardwareModel", device.HardwareModel)) - { - Device newDevice = new Device(item); - if (CompareRelatedDevices(newDevice, device)) - list.Add(newDevice); - } -#endif - } - list.Sort(CompareDeviceNames); - return list; - } - - /// - /// Returns a list of devices that match the search value provided. - /// - /// - /// - public static List FindDevices(string value) - { -#if VER4 || VER35 - return Devices.Where(i => - (i.HardwareVendor != null && i.HardwareVendor.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0) || - (i.HardwareModel != null && i.HardwareModel.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0) || - (i.HardwareName != null && i.HardwareName.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0) || - (i.SoftwareCaption != null && i.SoftwareCaption.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0) || - (i.BrowserCaption != null && i.BrowserCaption.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0)).ToList(); -#else - List list = new List(); - foreach (Device item in Devices) - { - if ((item.HardwareVendor != null && item.HardwareVendor.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0) || - (item.HardwareModel != null && item.HardwareModel.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0) || - (item.HardwareName != null && item.HardwareName.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0) || - (item.SoftwareCaption != null && item.SoftwareCaption.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0) || - (item.BrowserCaption != null && item.BrowserCaption.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0)) - list.Add(item); - } - return list; -#endif - } - - /// - /// Determines if the two devices are identical. - /// - /// - /// - /// - private static bool CompareRelatedDevices(Device x, Device y) - { - return x.HardwareVendor == y.HardwareVendor && - x.IsUnknown == false && - String.IsNullOrEmpty(x.SoftwareBrowserCaption) == false && - x.DeviceID != y.DeviceID; - } - - /// - /// Compares two different devices by name and returns the sort order - /// for the list. - /// - /// - /// - /// - public static int CompareDeviceNames(Device x, Device y) - { - return x.SoftwareBrowserCaption.CompareTo(y.SoftwareBrowserCaption); - } - - #endregion - - #region Private Methods - -#if VER4 || VER35 - - /// - /// Returns a list of the hardware devices for the vendor requested. - /// - /// - /// - private static List GetVendorDevices(Value vendor) - { - var list = new List(); - foreach (var item in vendor.Devices) - { - var device = new Device(item); - if (list.FirstOrDefault(i => - i.HardwareModel == device.HardwareModel) == null) - list.Add(device); - } - return list.OrderBy(i => i.HardwareModel).ToList(); - } - -#else - - /// - /// Returns a list of the hardware devices for the vendor requested. - /// - /// - /// - private static List GetVendorDevices(Value vendor) - { - List list = new List(); - foreach (BaseDeviceInfo baseDevice in vendor.Devices) - { - Device device = new Device(baseDevice); - - bool found = false; - foreach (Device existingDevice in list) - { - if (existingDevice.HardwareModel == device.HardwareModel) - { - found = true; - } - } - - if (found == false) - list.Add(device); - } - list.Sort(CompareDevicesByHardwareModel); - return list; - } - - /// - /// Compares two device objects by hardware model. - /// - /// - /// - /// - private static int CompareDevicesByHardwareModel(Device x, Device y) - { - return x.HardwareModel.CompareTo(y.HardwareModel); - } - - /// - /// Checks to determine if the list of properties are included in the - /// matches list. - /// - /// A list of properties to be compared - /// - /// - private static IList GetProperties(IList properties, string[] matches) - { - List list = new List(); - List matchesList = new List(matches); - foreach (Property property in Provider.Properties.Values) - if (matchesList.Contains(property.Name)) - list.Add(property); - return list; - } - - /// - /// Returns the first property which matches the name provided. - /// - /// List of properties. - /// Property name required. - /// - private static Property GetFirstWhereNameEquals(IList properties, string name) - { - foreach (Property property in properties) - if (property.Name == name) - return property; - return null; - } -#endif - - #endregion - } -} diff --git a/Foundation/UI/Device.cs b/Foundation/UI/Device.cs deleted file mode 100644 index 242ddf1..0000000 --- a/Foundation/UI/Device.cs +++ /dev/null @@ -1,266 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Foundation.UI -{ - /// - /// Wraps a Foundation device exposing UI specific properties. - /// - public class Device - { - #region Constants - - private static readonly string[] UNKNOWN_FIELDS = new string[] { - "HardwareVendor", - "HardwareModel", - "PlatformVendor", - "PlatformName", - "BrowserVendor", - "BrowserName" }; - - private static readonly string[] HARDWARE_CAPTION = new string[] { - "HardwareVendor", - "HardwareModel" }; - - private static readonly string[] SOFTWARE_CAPTION = new string[] { - "PlatformVendor", - "PlatformName", - "PlatformVersion" }; - - private static readonly string[] BROWSER_CAPTION = new string[] { - "BrowserVendor", - "BrowserName", - "BrowserVersion" }; - - #endregion - - #region Fields - - /// - /// The device data properties are based on. - /// - private readonly BaseDeviceInfo _device = null; - - #endregion - - #region Constructor - - /// - /// Constructs a new instance of based on the - /// the core base device info passed into the method. - /// - /// - public Device(BaseDeviceInfo device) - { - if (device == null) - throw new ArgumentNullException("device"); - - _device = device; - } - - #endregion - - #region Properties - - /// - /// Provides a list of all possible properties. - /// - public SortedList> Properties - { - get { return _device.GetAllProperties(); } - } - - /// - /// Returns true if the device is only available in the - /// premium data set. - /// - public bool IsPremium - { - get { return _device.IsPremium; } - } - - /// - /// Returns true if the device is one that should be considered unknown. - /// - public bool IsUnknown - { - get - { - foreach (string key in UNKNOWN_FIELDS) - if (_device.GetFirstPropertyValue(key) == "Unknown") - return true; - return false; - } - } - - /// - /// Returns the caption for the device including only the software and browser - /// details. - /// - public string SoftwareBrowserCaption - { - get - { - return String.Format("{0} & {1}", - SoftwareCaption, - BrowserCaption); - } - } - - /// - /// Returns the full caption of the device. - /// - public string Caption - { - get - { - return String.Format("{0} & {1} & {2}", - HardwareCaption, - SoftwareCaption, - BrowserCaption); - } - } - - /// - /// Returns the hardware caption for the device. - /// - public string HardwareCaption - { - get - { - return GetCaption(HARDWARE_CAPTION); - } - } - - /// - /// Returns the software caption for the device. - /// - public string SoftwareCaption - { - get - { - return GetCaption(SOFTWARE_CAPTION); - } - } - - /// - /// Returns the browser caption for the device. - /// - public string BrowserCaption - { - get - { - return GetCaption(BROWSER_CAPTION); - } - } - - /// - /// Returns the seperate profile IDs for the device. - /// - public string[] ProfileIDs - { - get { return DeviceID.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries); } - } - - /// - /// Returns the name of the device. - /// - public string Name - { - get - { - return String.Format("{0},{1}", - HardwareVendor, - HardwareModel); - } - } - - /// - /// Returns the device ID. - /// - public string DeviceID - { - get { return _device.DeviceId; } - } - - /// - /// Returns the hardware vendor. - /// - public string HardwareVendor - { - get { return _device.GetFirstPropertyValue("HardwareVendor"); } - } - - /// - /// Returns the hardware model. - /// - public string HardwareModel - { - get { return _device.GetFirstPropertyValue("HardwareModel"); } - } - - /// - /// Returns the hardware name. - /// - public string HardwareName - { - get { return String.Join(", ", _device.GetPropertyValues("HardwareName").ToArray()); } - } - - /// - /// Returns the content suitable for the search system. - /// - public string Content - { - get - { - List list = new List(); - SortedList> all = _device.GetAllProperties(); - foreach (string key in all.Keys) - if (all[key].Count > 0) - list.Add(String.Format("{0} = {1}", - key, - String.Join(", ", all[key].ToArray()))); - return String.Join("
", list.ToArray()); - } - } - - #endregion - - #region Private Methods - - /// - /// Constructs a caption removing any Unknown values. - /// - /// - /// - private string GetCaption(string[] keys) - { - List list = new List(); - foreach (string key in keys) - { - List values = _device.GetPropertyValues(key); - if (values.Count != 0 && - values.Contains("Unknown") == false) - list.AddRange(values); - } - if (list.Count == 0) - return "Unknown"; - return String.Join(" - ", list.ToArray()); - } - - #endregion - } -} \ No newline at end of file diff --git a/Foundation/UI/Headings.xml b/Foundation/UI/Headings.xml deleted file mode 100644 index ae62637..0000000 --- a/Foundation/UI/Headings.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Foundation/UI/RedirectData.cs b/Foundation/UI/RedirectData.cs deleted file mode 100644 index 85befd3..0000000 --- a/Foundation/UI/RedirectData.cs +++ /dev/null @@ -1,236 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.IO; -using FiftyOne.Foundation.Mobile.Configuration; - -namespace FiftyOne.Foundation.UI -{ - internal class FilterData - { - internal string Property = String.Empty; - internal string MatchExpression = String.Empty; - internal bool Enabled = true; - - private LocationData _parent = null; - - internal LocationData Parent - { - get { return _parent; } - } - - internal FilterData(LocationData parent) - { - _parent = parent; - } - - internal FilterData(LocationData parent, BinaryReader reader) - : this (parent) - { - - Deserialize(reader); - } - - internal FilterData(LocationData parent, FilterElement element) - : this(parent) - { - Property = element.Property; - MatchExpression = element.MatchExpression; - Enabled = element.Enabled; - } - - internal FilterElement GetElement() - { - FilterElement element = new FilterElement(); - element.Property = Property; - element.MatchExpression = MatchExpression; - element.Enabled = Enabled; - return element; - } - - internal void Serialize(BinaryWriter writer) - { - writer.Write(Property); - writer.Write(MatchExpression); - writer.Write(Enabled); - } - - internal void Deserialize(BinaryReader reader) - { - Property = reader.ReadString(); - MatchExpression = reader.ReadString(); - Enabled = reader.ReadBoolean(); - } - } - - internal class LocationData : List - { - internal bool Enabled = true; - internal string Name = String.Empty; - internal string Url = String.Empty; - internal string MatchExpression = String.Empty; - internal bool ShowFilters = false; - - private RedirectData _parent = null; - - internal RedirectData Parent - { - get { return _parent; } - } - - internal LocationData(RedirectData parent) - { - _parent = parent; - } - - internal LocationData(RedirectData parent, BinaryReader reader) - : this (parent) - { - Deserialize(reader); - } - - internal LocationData(RedirectData parent, LocationElement element) - : this (parent) - { - Enabled = element.Enabled; - Name = element.Name; - Url = element.Url; - MatchExpression = element.MatchExpression; - - foreach (FilterElement item in element) - base.Add(new FilterData(this, item)); - } - - internal LocationElement GetElement() - { - LocationElement element = new LocationElement(); - element.Enabled = Enabled; - element.Name = Name; - element.Url = Url; - element.MatchExpression = MatchExpression; - - foreach (FilterData item in this) - element.Add(item.GetElement()); - - return element; - } - - internal void Serialize(BinaryWriter writer) - { - writer.Write(Enabled); - writer.Write(Name); - writer.Write(Url); - writer.Write(MatchExpression); - writer.Write(ShowFilters); - writer.Write(Count); - foreach (FilterData item in this) - item.Serialize(writer); - } - - internal void Deserialize(BinaryReader reader) - { - Enabled = reader.ReadBoolean(); - Name = reader.ReadString(); - Url = reader.ReadString(); - MatchExpression = reader.ReadString(); - ShowFilters = reader.ReadBoolean(); - Clear(); - int count = reader.ReadInt32(); - for (int i = 0; i < count; i++) - Add(new FilterData(this, reader)); - } - } - - internal class RedirectData : List - { - internal bool Enabled = true; - internal string DevicesFile = String.Empty; - internal int Timeout = 20; - internal bool FirstRequestOnly = true; - internal bool OriginalUrlAsQueryString = false; - internal string MobileHomePageUrl = String.Empty; - internal string MobilePagesRegex = String.Empty; - - internal RedirectData(BinaryReader reader) - { - Deserialize(reader); - } - - internal RedirectData(RedirectSection section) - { - Enabled = section.Enabled; - DevicesFile = section.DevicesFile; - Timeout = section.Timeout; - FirstRequestOnly = section.FirstRequestOnly; - OriginalUrlAsQueryString = section.OriginalUrlAsQueryString; - MobileHomePageUrl = section.MobileHomePageUrl; - MobilePagesRegex = section.MobilePagesRegex; - - foreach (LocationElement element in section.Locations) - base.Add(new LocationData(this, element)); - } - - internal RedirectSection GetElement() - { - System.Configuration.Configuration configuration = Support.GetConfigurationContainingSectionGroupName("fiftyOne/redirect"); - - if (configuration == null) - return null; - - RedirectSection element = configuration.GetSection("fiftyOne/redirect") as RedirectSection; - - if (element != null) - { - element.DevicesFile = DevicesFile; - element.Timeout = Timeout; - element.FirstRequestOnly = FirstRequestOnly; - element.OriginalUrlAsQueryString = OriginalUrlAsQueryString; - element.MobileHomePageUrl = MobileHomePageUrl; - element.MobilePagesRegex = MobilePagesRegex; - - element.Locations.Clear(); - foreach (LocationData item in this) - element.Locations.Add(item.GetElement()); - } - - return element; - } - - internal void Serialize(BinaryWriter writer) - { - writer.Write(DevicesFile); - writer.Write(Timeout); - writer.Write(FirstRequestOnly); - writer.Write(OriginalUrlAsQueryString); - writer.Write(MobileHomePageUrl); - writer.Write(MobilePagesRegex); - writer.Write(Count); - foreach (LocationData item in this) - item.Serialize(writer); - } - - internal void Deserialize(BinaryReader reader) - { - DevicesFile = reader.ReadString(); - Timeout = reader.ReadInt32(); - FirstRequestOnly = reader.ReadBoolean(); - OriginalUrlAsQueryString = reader.ReadBoolean(); - MobileHomePageUrl = reader.ReadString(); - MobilePagesRegex = reader.ReadString(); - Clear(); - int count = reader.ReadInt32(); - for (int i = 0; i < count; i++) - Add(new LocationData(this, reader)); - } - } -} diff --git a/Foundation/UI/Resources.Designer.cs b/Foundation/UI/Resources.Designer.cs deleted file mode 100644 index c950c6a..0000000 --- a/Foundation/UI/Resources.Designer.cs +++ /dev/null @@ -1,976 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.17929 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace FiftyOne.Foundation.UI { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FiftyOne.Foundation.UI.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Activate. - /// - internal static string ActivateButtonText { - get { - return ResourceManager.GetString("ActivateButtonText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}">{1} Data is active. Thank you.</div>. - /// - internal static string ActivatedMessageHtml { - get { - return ResourceManager.GetString("ActivatedMessageHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>Paste your data licence key into the textbox below. Select "Activate" to use the licence key with this web site.</p>. - /// - internal static string ActivateInstructionsHtml { - get { - return ResourceManager.GetString("ActivateInstructionsHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}"><p>The data source provided does not contain valid data.</p></div>. - /// - internal static string ActivationDataInvalidHtml { - get { - return ResourceManager.GetString("ActivationDataInvalidHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}"><p>The fiftyOne/detection element of the config file '{1}' could not be inserted. Please ensure the following text is present between the fiftyOne tags and try activating the licence key again.</p> - ///<br/> - ///<span style="margin-left: 0px !important;"> - ///<code style="color: #000000;">&lt;</code> - ///<code><span style="color: #006699;"><strong>detection</strong></span></code>&nbsp; - ///<code style="color: #808080;">binaryFilePath</code> - ///<code style="color: #000000;">=</code> - ///<code style="color: blue [rest of string was truncated]";. - /// - internal static string ActivationFailureCouldNotUpdateConfigHtml { - get { - return ResourceManager.GetString("ActivationFailureCouldNotUpdateConfigHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}"> - ///<p>The device data file '{1}' could not be saved. Check the user '{2}' has write access to the folder, or change the folder location to one with write access.</p> - ///</div>. - /// - internal static string ActivationFailureCouldNotWriteDataFileHtml { - get { - return ResourceManager.GetString("ActivationFailureCouldNotWriteDataFileHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}"><p>The licence file '{1}' could not be written to this web sites bin folder '{2}'. Create a text file with the extension .lic and paste the licence key into the file. Save the text file in the bin folder.</p></div>. - /// - internal static string ActivationFailureCouldNotWriteLicenceFileHtml { - get { - return ResourceManager.GetString("ActivationFailureCouldNotWriteLicenceFileHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}"><p>Whoops. There was a problem activating the licence key or uploading premium data. We're unsure why this happened. Please <a href="http://51degrees.mobi/AboutUs/ContactUs.aspx">Contact Us</a> providing details of your web site implementation, relevent entries from your log file, and we'll try and help you.</p></div>. - /// - internal static string ActivationFailureGenericHtml { - get { - return ResourceManager.GetString("ActivationFailureGenericHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}"><p>We were unable to reach the 51Degrees.mobi licence validation web site at the host '{1}'. This could be for one of the following reasons.</p> - ///<ul> - ///<li> - ///This web site is running in medium trust mode and the - ///<a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.trustsection.originurl(v=VS.80).aspx">originUrl</a> - ///attribute in the web.config does not allow access the host '{1}'. Change the originUrl to include '{1}'. Multiple host names can - ///be seperated by | sign [rest of string was truncated]";. - /// - internal static string ActivationFailureHttpHtml { - get { - return ResourceManager.GetString("ActivationFailureHttpHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}"><p>The licence key provided failed validation. Please check the license key is validate with your reseller.</p></div>. - /// - internal static string ActivationFailureInvalidHtml { - get { - return ResourceManager.GetString("ActivationFailureInvalidHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}"><p>The data source provided could not be read from.</p></div>. - /// - internal static string ActivationStreamFailureHtml { - get { - return ResourceManager.GetString("ActivationStreamFailureHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}"><p>Success. Select the "Refresh" button to reload the web page and and start using Device Data. Note: There may be a short delay as the application restarts.</p></div>. - /// - internal static string ActivationSuccessHtml { - get { - return ResourceManager.GetString("ActivationSuccessHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Other Vendors. - /// - internal static string BackButtonDevicesText { - get { - return ResourceManager.GetString("BackButtonDevicesText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Other {0} Devices. - /// - internal static string BackButtonDeviceText { - get { - return ResourceManager.GetString("BackButtonDeviceText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>Use the (?) icons to find out more information about the property or value.</p>. - /// - internal static string DeviceExplorerDeviceInstructionsHtml { - get { - return ResourceManager.GetString("DeviceExplorerDeviceInstructionsHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>Select a model to view its capabilities along with the different browser and software combinations.</p>. - /// - internal static string DeviceExplorerModelsInstructionsHtml { - get { - return ResourceManager.GetString("DeviceExplorerModelsInstructionsHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>Select a hardware vendor to view the device models they produce.</p>. - /// - internal static string DeviceExplorerVendorsHtml { - get { - return ResourceManager.GetString("DeviceExplorerVendorsHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} Devices. - /// - internal static string DevicesVendorHeading { - get { - return ResourceManager.GetString("DevicesVendorHeading", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to http://51degrees.mobi/Products/DeviceData. - /// - internal static string FiftyOneDegreesUrl { - get { - return ResourceManager.GetString("FiftyOneDegreesUrl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enter key word to search. - /// - internal static string FinderFreeTextLabelText { - get { - return ResourceManager.GetString("FinderFreeTextLabelText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enter the key word in the pattern "Nokia N95". Single word pattern will check against both Vendor and Model.. - /// - internal static string FinderFreeTextLabelToolTip { - get { - return ResourceManager.GetString("FinderFreeTextLabelToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Select Model. - /// - internal static string FinderModelLabelText { - get { - return ResourceManager.GetString("FinderModelLabelText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Select Device Model from the selected Vendor ex: N95. - /// - internal static string FinderModelLabelToolTip { - get { - return ResourceManager.GetString("FinderModelLabelToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Select Vendor. - /// - internal static string FinderVendorLabelText { - get { - return ResourceManager.GetString("FinderVendorLabelText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Select Device Vendor to search ex: Nokia. - /// - internal static string FinderVendorLabelToolTip { - get { - return ResourceManager.GetString("FinderVendorLabelToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to // constants to control animations - /// - internal static string ImageRotationScript { - get { - return ResourceManager.GetString("ImageRotationScript", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to function toggle(e, id, style) { - /// var profile = document.getElementById(id); - /// if (profile.style.display == 'block') { - /// profile.style.display = 'none'; - /// e.innerHTML = '+'; - /// } else { - /// profile.style.display = style; - /// e.innerHTML = '-'; - /// } - ///}. - /// - internal static string JavaScriptToggle { - get { - return ResourceManager.GetString("JavaScriptToggle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UserAgent Test Results. - /// - internal static string MatchCaption { - get { - return ResourceManager.GetString("MatchCaption", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>The list of properties and descriptions explain how to use the available device data. Use the [+] icon to display possible values associated with the property. Use the (?) icons to find out more information about the property or value.</p>. - /// - internal static string PropertyDictionaryInstructions { - get { - return ResourceManager.GetString("PropertyDictionaryInstructions", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <h1 class="{heading}">Legend</h1> - ///<p><strong>Property Fonts &amp; Colours</strong></p> - ///<p class="{property} {lite}" style="width:auto;float:none;">Property is included in <strong>both</strong> Lite and Premium data sets.</p> - ///<p class="{property} {cms}" style="width:auto;float:none;">Property is included in both CMS and the Premium data sets, but not the Lite data set.</p> - ///<p class="{property} {premium}" style="width:auto;float:none;">Property is included <strong>only</strong> in the Premium data sets.</ [rest of string was truncated]";. - /// - internal static string PropertyDictionaryLegend { - get { - return ResourceManager.GetString("PropertyDictionaryLegend", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <h3>General</h3>. - /// - internal static string RedirectBasicHeadingHtml { - get { - return ResourceManager.GetString("RedirectBasicHeadingHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Hide. - /// - internal static string RedirectButtonHideText { - get { - return ResourceManager.GetString("RedirectButtonHideText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to New Location. - /// - internal static string RedirectButtonNewLocationText { - get { - return ResourceManager.GetString("RedirectButtonNewLocationText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to New. - /// - internal static string RedirectButtonNewText { - get { - return ResourceManager.GetString("RedirectButtonNewText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove. - /// - internal static string RedirectButtonRemoveText { - get { - return ResourceManager.GetString("RedirectButtonRemoveText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Reset. - /// - internal static string RedirectButtonResetText { - get { - return ResourceManager.GetString("RedirectButtonResetText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Show. - /// - internal static string RedirectButtonShowText { - get { - return ResourceManager.GetString("RedirectButtonShowText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Update. - /// - internal static string RedirectButtonUpdateText { - get { - return ResourceManager.GetString("RedirectButtonUpdateText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A file used to store the details of devices that have previously accessed the web site to determine if they're making a subsequent request. Needed to ensure multiple worker processes have a consistent view of previous activity. (Optional – random behaviour will be experienced if not specified on web sites with more than one worker processes). In Windows Azure this value becomes the name of devices cloud table that will be used instead of a file.. - /// - internal static string RedirectDevicesFileToolTip { - get { - return ResourceManager.GetString("RedirectDevicesFileToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to If unchecked redirection will be disabled.. - /// - internal static string RedirectEnabledToolTip { - get { - return ResourceManager.GetString("RedirectEnabledToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Devices file must contain a valid file.. - /// - internal static string RedirectErrorMessageDevicesFileText { - get { - return ResourceManager.GetString("RedirectErrorMessageDevicesFileText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Duplicate unique destination location names '{0}' are not allowed.. - /// - internal static string RedirectErrorMessageDuplicatesText { - get { - return ResourceManager.GetString("RedirectErrorMessageDuplicatesText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Match expression must evaluate to a valid regular expression.. - /// - internal static string RedirectErrorMessageMatchExpressionText { - get { - return ResourceManager.GetString("RedirectErrorMessageMatchExpressionText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Mobile home page regex must evaluate to a valid regular expression.. - /// - internal static string RedirectErrorMessageMobileHomePageRegexText { - get { - return ResourceManager.GetString("RedirectErrorMessageMobileHomePageRegexText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Mobile home page URL must contain a valid absolute or relative URL.. - /// - internal static string RedirectErrorMessageMobileHomePageUrlText { - get { - return ResourceManager.GetString("RedirectErrorMessageMobileHomePageUrlText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Name field must be provided.. - /// - internal static string RedirectErrorMessageNameFieldText { - get { - return ResourceManager.GetString("RedirectErrorMessageNameFieldText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Timeout must be a numeric value greater than or equal to zero.. - /// - internal static string RedirectErrorMessageTimeOutText { - get { - return ResourceManager.GetString("RedirectErrorMessageTimeOutText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The URL is not in a valid format.. - /// - internal static string RedirectErrorMessageUrlFormatText { - get { - return ResourceManager.GetString("RedirectErrorMessageUrlFormatText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to If set to true only the first request received by the web site is redirected to the mobileUrl when the site is accessed from a mobile device. (Optional – defaults to true). - /// - internal static string RedirectFirstRequestOnlyToolTip { - get { - return ResourceManager.GetString("RedirectFirstRequestOnlyToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Devices File. - /// - internal static string RedirectLabelDevicesFileText { - get { - return ResourceManager.GetString("RedirectLabelDevicesFileText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enabled. - /// - internal static string RedirectLabelEnabledText { - get { - return ResourceManager.GetString("RedirectLabelEnabledText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Filters. - /// - internal static string RedirectLabelFiltersText { - get { - return ResourceManager.GetString("RedirectLabelFiltersText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to First Request Only. - /// - internal static string RedirectLabelFirstRequestOnlyText { - get { - return ResourceManager.GetString("RedirectLabelFirstRequestOnlyText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Match Expression. - /// - internal static string RedirectLabelMatchExpressionText { - get { - return ResourceManager.GetString("RedirectLabelMatchExpressionText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Mobile Home Page Url. - /// - internal static string RedirectLabelMobileHomePageUrlText { - get { - return ResourceManager.GetString("RedirectLabelMobileHomePageUrlText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Mobile Pages Regex. - /// - internal static string RedirectLabelMobilePagesRegexText { - get { - return ResourceManager.GetString("RedirectLabelMobilePagesRegexText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Original Url. - /// - internal static string RedirectLabelOriginalUrlAsQueryStringText { - get { - return ResourceManager.GetString("RedirectLabelOriginalUrlAsQueryStringText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Property. - /// - internal static string RedirectLabelPropertyText { - get { - return ResourceManager.GetString("RedirectLabelPropertyText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Redirect Url. - /// - internal static string RedirectLabelRedirectUrlText { - get { - return ResourceManager.GetString("RedirectLabelRedirectUrlText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Timeout. - /// - internal static string RedirectLabelTimeoutText { - get { - return ResourceManager.GetString("RedirectLabelTimeoutText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unique Name. - /// - internal static string RedirectLabelUniqueNameText { - get { - return ResourceManager.GetString("RedirectLabelUniqueNameText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Value. - /// - internal static string RedirectLabelValueText { - get { - return ResourceManager.GetString("RedirectLabelValueText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A regular expression used to evaluate the value of the property. (Mandatory). - /// - internal static string RedirectLocationFilterMatchExpressionToolTip { - get { - return ResourceManager.GetString("RedirectLocationFilterMatchExpressionToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The property of HttpRequest, HttpRequest.Browser or 51Degrees.mobi property to use when evaluating the matchExpression attribute. (Mandatory). - /// - internal static string RedirectLocationFilterPropertyToolTip { - get { - return ResourceManager.GetString("RedirectLocationFilterPropertyToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The location element contains a collection of criteria or filters that all need to match for the location to be used.. - /// - internal static string RedirectLocationFiltersToolTip { - get { - return ResourceManager.GetString("RedirectLocationFiltersToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Can be used to provide a regular expression which will take the requesting URL as input match segments to be used in place of numeric parameters contained within {} in the url attribute. (Optional). - /// - internal static string RedirectLocationMatchExpressionToolTip { - get { - return ResourceManager.GetString("RedirectLocationMatchExpressionToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A unique identifier for the location. Used for debugging in the log file.(Mandatory). - /// - internal static string RedirectLocationNameToolTip { - get { - return ResourceManager.GetString("RedirectLocationNameToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <h3>Redirect Locations</h3>. - /// - internal static string RedirectLocationsHeadingHtml { - get { - return ResourceManager.GetString("RedirectLocationsHeadingHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to URL of the redirect location to use if all the properties in the collection match. (Mandatory). - /// - internal static string RedirectLocationUrlToolTip { - get { - return ResourceManager.GetString("RedirectLocationUrlToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A regular expression that when applied to the current request Path (context.Request.AppRelativeCurrentExecutionFilePath) or the requesting Urlwill return true if it should be considered a mobile page. Use this attribute to tell redirection about mobile pages derived from base - /// classes such as System.Web.UI.Page. Redirection needs to be aware of mobile pages so that requests to these pages can be ignored. Any page that derives from System.Web.UI.MobileControls.MobilePage will automatically be treated as a m [rest of string was truncated]";. - /// - internal static string RedirectMobilePagesRegexToolTip { - get { - return ResourceManager.GetString("RedirectMobilePagesRegexToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A URL to direct mobile devices to instead of the normal web sites landing page. Will be used after all the locations have been evaluated if one did not match and a mobile device is present. (Optional). - /// - internal static string RedirectMobileRedirectUrlToolTip { - get { - return ResourceManager.GetString("RedirectMobileRedirectUrlToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to If set to true the redirected URL will have the original requesting Url encoded and included as the origUrl query string parameter in the redirected Url. This will enable the mobile home page to determine the original requested resource providing the option to display a mobile friendly version. (Optional [but highly recommended] – defaults to false). - /// - internal static string RedirectOriginalUrlAsQueryStringToolTip { - get { - return ResourceManager.GetString("RedirectOriginalUrlAsQueryStringToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The number of minutes of inactivity that should occur before the requesting device should be treated as making a new request to the web site for the purposes of redirection. If the session is available the session timeout will be used and override this value. (Optional -defaults to 20 minutes). - /// - internal static string RedirectTimeoutToolTip { - get { - return ResourceManager.GetString("RedirectTimeoutToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>{0}</p><p>{1}</p>. - /// - internal static string RedirectUpdateGeneralDetailedFailureHtml { - get { - return ResourceManager.GetString("RedirectUpdateGeneralDetailedFailureHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>Exception updating configuration '{0}'.</p><p>Check the web sites application pool identity can modify the configuration files. If operating in a Medium trust environment switch to Full trust to complete the configuration changes.</p><p>Alternatively cut and paste the following XML into your configuration file.</p><p><code>{1}</code></p>. - /// - internal static string RedirectUpdateGeneralFailureHtml { - get { - return ResourceManager.GetString("RedirectUpdateGeneralFailureHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>Configuration updated successfully.</p><p>The application may need to be restarted for the redirection rules to become active.</p>. - /// - internal static string RedirectUpdateSuccessHtml { - get { - return ResourceManager.GetString("RedirectUpdateSuccessHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Refresh. - /// - internal static string RefreshButtonText { - get { - return ResourceManager.GetString("RefreshButtonText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Related Browser & Software Combinations. - /// - internal static string RelatedDevicesHeading { - get { - return ResourceManager.GetString("RelatedDevicesHeading", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Search. - /// - internal static string SearchBoxButtonText { - get { - return ResourceManager.GetString("SearchBoxButtonText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Device Search: . - /// - internal static string SearchBoxInstructionText { - get { - return ResourceManager.GetString("SearchBoxInstructionText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}">There was a problem recording your share usage data preference. If the web site is operating in a medium trust environment or modify permission to the configuration file(s) is not granted to the application pool identity you will have to change this value in the configuration file manually. Find the fiftyOne/detection element in the config file and set the shareUsage attribute.</div>. - /// - internal static string ShareUsageErrorHtml { - get { - return ResourceManager.GetString("ShareUsageErrorHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}">We're sorry you've decided not to share usage data. We hope you'll reconsider as usage data helps us provide you a better product. Find out more <a href="http://51degrees.mobi/Support/FAQs/UsageData" target="_blank">here</a>.<br/>You may need to restart the web site for the change to become effective.</div>. - /// - internal static string ShareUsageFalseHtml { - get { - return ResourceManager.GetString("ShareUsageFalseHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Learn More. - /// - internal static string ShareUsageLinkText { - get { - return ResourceManager.GetString("ShareUsageLinkText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Share usage data with 51Degrees.mobi.. - /// - internal static string ShareUsageText { - get { - return ResourceManager.GetString("ShareUsageText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}">Thank you for sharing usage data and helping improve this product.<br/>You may need to restart the web site for the change to become effective.</div>. - /// - internal static string ShareUsageTrueHtml { - get { - return ResourceManager.GetString("ShareUsageTrueHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to http://51degrees.mobi/Support/FAQs/UsageData. - /// - internal static string ShareUsageUrl { - get { - return ResourceManager.GetString("ShareUsageUrl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <div class="{0}"><span>Data Version: <b>{1}</b></span> <span>Published: <b>{2:d}</b></span><span>Properties: <b>{3}</b></span></div>. - /// - internal static string StatsHtml { - get { - return ResourceManager.GetString("StatsHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Refresh Data. - /// - internal static string StatsRefreshButtonText { - get { - return ResourceManager.GetString("StatsRefreshButtonText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Show or hide available values. - /// - internal static string ToggleToolTip { - get { - return ResourceManager.GetString("ToggleToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>Displaying the top {0} latest devices.</p>. - /// - internal static string TopDevicesText { - get { - return ResourceManager.GetString("TopDevicesText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>Thank you for using Lite device data from 51Degrees.mobi. You can now upgrade to Premium data whenever you want, giving you a range of benefits that include:</p> - ///<p>- Automatically redirecting users to optimised web pages, enabling you to create separate sites for tablets, feature phones and smartphones.</p> - ///<p>- Enhancing the IsMobile and Screen Size properties in Lite data with over 50 device properties including IsTablet, screen size in millimetres, vendor, model, platform details, input methods and [rest of string was truncated]";. - /// - internal static string UpgradeHtml { - get { - return ResourceManager.GetString("UpgradeHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Upload. - /// - internal static string UploadButtonText { - get { - return ResourceManager.GetString("UploadButtonText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>Alternatively upload a Premium data file using the "Browse" and "Upload" buttons below.</p>. - /// - internal static string UploadInstructionsHtml { - get { - return ResourceManager.GetString("UploadInstructionsHtml", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Find Device. - /// - internal static string UserAgentTesterButtonText { - get { - return ResourceManager.GetString("UserAgentTesterButtonText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <p>Enter the User Agent String to test and press the Find Device button.</p>. - /// - internal static string UserAgentTesterInstructions { - get { - return ResourceManager.GetString("UserAgentTesterInstructions", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use the Browse button to select a Premium data file to upload.. - /// - internal static string ValidationFileErrorText { - get { - return ResourceManager.GetString("ValidationFileErrorText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The licence key must only contain upper case alpha characters or numerics.. - /// - internal static string ValidationRegExErrorText { - get { - return ResourceManager.GetString("ValidationRegExErrorText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A licence key must be entered.. - /// - internal static string ValidationRequiredErrorText { - get { - return ResourceManager.GetString("ValidationRequiredErrorText", resourceCulture); - } - } - } -} diff --git a/Foundation/UI/Resources.resx b/Foundation/UI/Resources.resx deleted file mode 100644 index 62dc47b..0000000 --- a/Foundation/UI/Resources.resx +++ /dev/null @@ -1,541 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Activate - - - <div class="{0}">{1} Data is active. Thank you.</div> - - - UserAgent Test Results - - - <p>Paste your data licence key into the textbox below. Select "Activate" to use the licence key with this web site.</p> - - - <div class="{0}"><p>The fiftyOne/detection element of the config file '{1}' could not be inserted. Please ensure the following text is present between the fiftyOne tags and try activating the licence key again.</p> -<br/> -<span style="margin-left: 0px !important;"> -<code style="color: #000000;">&lt;</code> -<code><span style="color: #006699;"><strong>detection</strong></span></code>&nbsp; -<code style="color: #808080;">binaryFilePath</code> -<code style="color: #000000;">=</code> -<code style="color: blue;">"~/App_Data/51Degrees-Premium.dat"</code> -<code><span style="color: #000000;">/&gt;</span></code> -</div> - - - <div class="{0}"> -<p>The device data file '{1}' could not be saved. Check the user '{2}' has write access to the folder, or change the folder location to one with write access.</p> -</div> - - - <div class="{0}"><p>The licence file '{1}' could not be written to this web sites bin folder '{2}'. Create a text file with the extension .lic and paste the licence key into the file. Save the text file in the bin folder.</p></div> - - - <div class="{0}"><p>Whoops. There was a problem activating the licence key or uploading premium data. We're unsure why this happened. Please <a href="http://51degrees.mobi/AboutUs/ContactUs.aspx">Contact Us</a> providing details of your web site implementation, relevent entries from your log file, and we'll try and help you.</p></div> - - - <div class="{0}"><p>We were unable to reach the 51Degrees.mobi licence validation web site at the host '{1}'. This could be for one of the following reasons.</p> -<ul> -<li> -This web site is running in medium trust mode and the -<a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.trustsection.originurl(v=VS.80).aspx">originUrl</a> -attribute in the web.config does not allow access the host '{1}'. Change the originUrl to include '{1}'. Multiple host names can -be seperated by | signs.</li> -<li> -The web servers firewall or another firewall is blocking access to the host or the SSL port 443. Check the firewall configuration. -</li> -</ul> -<p>When you've completed these checks try activating the licence key again.</p></div> - - - <div class="{0}"><p>The licence key provided failed validation. Please check the license key is validate with your reseller.</p></div> - - - <div class="{0}"><p>Success. Select the "Refresh" button to reload the web page and and start using Device Data. Note: There may be a short delay as the application restarts.</p></div> - - - Other {0} Devices - - - Other Vendors - - - http://51degrees.mobi/Products/DeviceData - - - function toggle(e, id, style) { - var profile = document.getElementById(id); - if (profile.style.display == 'block') { - profile.style.display = 'none'; - e.innerHTML = '+'; - } else { - profile.style.display = style; - e.innerHTML = '-'; - } -} - Script for the toggle functionality - - - <h1 class="{heading}">Legend</h1> -<p><strong>Property Fonts &amp; Colours</strong></p> -<p class="{property} {lite}" style="width:auto;float:none;">Property is included in <strong>both</strong> Lite and Premium data sets.</p> -<p class="{property} {cms}" style="width:auto;float:none;">Property is included in both CMS and the Premium data sets, but not the Lite data set.</p> -<p class="{property} {premium}" style="width:auto;float:none;">Property is included <strong>only</strong> in the Premium data sets.</p> -<p><strong>Symbols</strong></p> -<p class="{property}" style="width:auto;float:none;">[L] = the property can return multiple values as a list.</p> -<p class="{property}" style="width:auto;float:none;">(?) = More information.</p> - - - Related Browser & Software Combinations - - - Show or hide available values - - - <p>Thank you for using Lite device data from 51Degrees.mobi. You can now upgrade to Premium data whenever you want, giving you a range of benefits that include:</p> -<p>- Automatically redirecting users to optimised web pages, enabling you to create separate sites for tablets, feature phones and smartphones.</p> -<p>- Enhancing the IsMobile and Screen Size properties in Lite data with over 50 device properties including IsTablet, screen size in millimetres, vendor, model, platform details, input methods and levels of javascript support.</p> -<p>- Regular weekly updates of device data</p> -<p>- An option to automatically install new updates</p> -<p><a href="{1}" target="_blank" title="Buy a Licence Key for 51Degrees.mobi Premium Data Now">{2}</a>&nbsp;|&nbsp;<a href="{0}" target="_blank" title="Learn More">Learn More</a></p> - - - Find Device - - - <p>Enter the User Agent String to test and press the Find Device button.</p> - - - The licence key must only contain upper case alpha characters or numerics. - - - A licence key must be entered. - - - {0} Devices - - - Refresh - - - <p>Use the (?) icons to find out more information about the property or value.</p> - - - <p>Select a model to view its capabilities along with the different browser and software combinations.</p> - - - <p>Select a hardware vendor to view the device models they produce.</p> - - - <p>The list of properties and descriptions explain how to use the available device data. Use the [+] icon to display possible values associated with the property. Use the (?) icons to find out more information about the property or value.</p> - - - <div class="{0}"><p>The data source provided does not contain valid data.</p></div> - - - <div class="{0}"><p>The data source provided could not be read from.</p></div> - - - <div class="{0}"><span>Data Version: <b>{1}</b></span> <span>Published: <b>{2:d}</b></span><span>Properties: <b>{3}</b></span></div> - - - Upload - - - <p>Alternatively upload a Premium data file using the "Browse" and "Upload" buttons below.</p> - - - Use the Browse button to select a Premium data file to upload. - - - Enter key word to search - - - Enter the key word in the pattern "Nokia N95". Single word pattern will check against both Vendor and Model. - - - Select Model - - - Select Device Model from the selected Vendor ex: N95 - - - Select Vendor - - - Select Device Vendor to search ex: Nokia - - - Refresh Data - - - A file used to store the details of devices that have previously accessed the web site to determine if they're making a subsequent request. Needed to ensure multiple worker processes have a consistent view of previous activity. (Optional – random behaviour will be experienced if not specified on web sites with more than one worker processes). In Windows Azure this value becomes the name of devices cloud table that will be used instead of a file. - - - If unchecked redirection will be disabled. - - - If set to true only the first request received by the web site is redirected to the mobileUrl when the site is accessed from a mobile device. (Optional – defaults to true) - - - A regular expression used to evaluate the value of the property. (Mandatory) - - - The property of HttpRequest, HttpRequest.Browser or 51Degrees.mobi property to use when evaluating the matchExpression attribute. (Mandatory) - - - The location element contains a collection of criteria or filters that all need to match for the location to be used. - - - Can be used to provide a regular expression which will take the requesting URL as input match segments to be used in place of numeric parameters contained within {} in the url attribute. (Optional) - - - A unique identifier for the location. Used for debugging in the log file.(Mandatory) - - - URL of the redirect location to use if all the properties in the collection match. (Mandatory) - - - A regular expression that when applied to the current request Path (context.Request.AppRelativeCurrentExecutionFilePath) or the requesting Urlwill return true if it should be considered a mobile page. Use this attribute to tell redirection about mobile pages derived from base - classes such as System.Web.UI.Page. Redirection needs to be aware of mobile pages so that requests to these pages can be ignored. Any page that derives from System.Web.UI.MobileControls.MobilePage will automatically be treated as a mobile page irrespective of this attribute. (Optional) - - - A URL to direct mobile devices to instead of the normal web sites landing page. Will be used after all the locations have been evaluated if one did not match and a mobile device is present. (Optional) - - - If set to true the redirected URL will have the original requesting Url encoded and included as the origUrl query string parameter in the redirected Url. This will enable the mobile home page to determine the original requested resource providing the option to display a mobile friendly version. (Optional [but highly recommended] – defaults to false) - - - The number of minutes of inactivity that should occur before the requesting device should be treated as making a new request to the web site for the purposes of redirection. If the session is available the session timeout will be used and override this value. (Optional -defaults to 20 minutes) - - - <h3>General</h3> - - - Hide - - - New - - - Remove - - - Reset - - - Show - - - Update - - - Devices file must contain a valid file. - - - Duplicate unique destination location names '{0}' are not allowed. - - - Match expression must evaluate to a valid regular expression. - - - Mobile home page regex must evaluate to a valid regular expression. - - - Mobile home page URL must contain a valid absolute or relative URL. - - - Name field must be provided. - - - Timeout must be a numeric value greater than or equal to zero. - - - The URL is not in a valid format. - - - Devices File - - - Enabled - - - Filters - - - First Request Only - - - Match Expression - - - Mobile Home Page Url - - - Mobile Pages Regex - - - Original Url - - - Property - - - Redirect Url - - - Timeout - - - Unique Name - - - Value - - - <h3>Redirect Locations</h3> - - - <p>{0}</p><p>{1}</p> - - - <p>Exception updating configuration '{0}'.</p><p>Check the web sites application pool identity can modify the configuration files. If operating in a Medium trust environment switch to Full trust to complete the configuration changes.</p><p>Alternatively cut and paste the following XML into your configuration file.</p><p><code>{1}</code></p> - - - <p>Configuration updated successfully.</p><p>The application may need to be restarted for the redirection rules to become active.</p> - - - New Location - - - Share usage data with 51Degrees.mobi. - - - <div class="{0}">There was a problem recording your share usage data preference. If the web site is operating in a medium trust environment or modify permission to the configuration file(s) is not granted to the application pool identity you will have to change this value in the configuration file manually. Find the fiftyOne/detection element in the config file and set the shareUsage attribute.</div> - - - <div class="{0}">We're sorry you've decided not to share usage data. We hope you'll reconsider as usage data helps us provide you a better product. Find out more <a href="http://51degrees.mobi/Support/FAQs/UsageData" target="_blank">here</a>.<br/>You may need to restart the web site for the change to become effective.</div> - - - Learn More - - - <div class="{0}">Thank you for sharing usage data and helping improve this product.<br/>You may need to restart the web site for the change to become effective.</div> - - - http://51degrees.mobi/Support/FAQs/UsageData - - - // constants to control animations -var tickTime = 50; // time in milliseconds a 'tick' lasts for -var transitionTime = 500; // time in milliseconds a fade should last for -var imageDelay = 2000; // time in milliseconds a image will show for without fading - -// used to store image data between ticks -var hoveredImageData = null; - -// fired from img onmouseover event. begins transitions. -function ImageHovered(element, urls) { - hoveredImageData = new Object(); - hoveredImageData.Element = element; // the html img element to change - hoveredImageData.Urls = urls; // a string array of image urls in priority order - hoveredImageData.Cycle = 1; // the image displayed, ie index of Urls - hoveredImageData.Ticks = 0; // current tick used for animation - hoveredImageData.Phase = 'FadeOut'; // the next image will immediately begin loading - hoveredImageData.NextImage = new Image(); // used to preload image - hoveredImageData.NextImage.src = hoveredImageData.Urls[1]; - hoveredImageData.IntervalId = setInterval(tick, tickTime); // start ticker and store interval id -} - -// fired from img onmouseoff event. resets image to one with highest priority when unhovered -function ImageUnHovered(element, url) { - element.src = url; - UpdateFade(100); - clearInterval(hoveredImageData.IntervalId); -} - -function tick() { - // switch statement controls which part of the element's animation is in progress and updates it. - // phase is updated when the tick count reaches to relevant constant defined above. - switch (hoveredImageData.Phase) { - - - case 'FadeOut': - if (hoveredImageData.NextImage.complete == false) - return; // return to prevent ticks incrementing - // convert ticks to fade - UpdateFade(100 - (transitionTime / tickTime) * hoveredImageData.Ticks); - if (hoveredImageData.Ticks * tickTime == transitionTime) - ChangePhase('NewImage'); - break; - - case 'NewImage': - hoveredImageData.Element.src = hoveredImageData.NextImage.src; - hoveredImageData.Cycle++; - // checks if another image is available, going back to beginning if there isn't - if (hoveredImageData.Cycle == hoveredImageData.Urls.length) - hoveredImageData.Cycle = 0; - hoveredImageData.NextImage.src = hoveredImageData.Urls[hoveredImageData.Cycle]; - ChangePhase('FadeIn'); - break; - - case 'FadeIn': - // convert ticks to fade - UpdateFade((transitionTime / tickTime) * hoveredImageData.Ticks); - if (hoveredImageData.Ticks * tickTime == transitionTime) - ChangePhase('Delay'); - break; - - - case 'Delay': - // nothing to do except wait for time delay to expire - if (hoveredImageData.Ticks * tickTime == imageDelay) - ChangePhase('FadeOut'); - break; - - } - hoveredImageData.Ticks++; -} - -function ChangePhase(phase) { - hoveredImageData.Phase = phase; - // ticks are reset when a phase is changed - hoveredImageData.Ticks = 0; -} - -// updates img element's opacity. opacity is a percentage - 100 is fully opaque, 0 is completely transparent -function UpdateFade(opacity) { - // converts opacity to decimal - hoveredImageData.Element.style.opacity = opacity / 100; -} - Script for the image hover and switch functionality. - - - Search - - - Device Search: - - - <p>Displaying the top {0} latest devices.</p> - - \ No newline at end of file diff --git a/Foundation/UI/Web/Activate.cs b/Foundation/UI/Web/Activate.cs deleted file mode 100644 index 0056d96..0000000 --- a/Foundation/UI/Web/Activate.cs +++ /dev/null @@ -1,31 +0,0 @@ -/* ********************************************************************* - * 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 System; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Display a user interface to enable the user to enter a Premium license key and upgrade Foundation - /// to the premium product. If the fiftyOne/detection element does not exist in the configuration - /// this element is added and the binaryFilePath set to "51Degrees-Premium.dat". The licence key will - /// be written to a file called 51Degrees.mobi.lic in the bin folder. - /// If the site is running in medium trust mode the operation will fail and a message will be displayed - /// to the user. - /// The control also contains a check box to enable / disable the sharing of usage information with - /// 51Degrees.mobi. - /// - [Obsolete("Use the Detection user control. " + - "This control now includes functionality not entirely related to activating premium data.")] - public class Activate : Detection - { - } -} diff --git a/Foundation/UI/Web/ActivityResult.cs b/Foundation/UI/Web/ActivityResult.cs deleted file mode 100644 index b3f3f8d..0000000 --- a/Foundation/UI/Web/ActivityResult.cs +++ /dev/null @@ -1,72 +0,0 @@ -/* ********************************************************************* - * 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. - * ********************************************************************* */ - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Used to communicate to the users of the control the - /// result of an upload or activate process. - /// - public class ActivityResult - { - #region Fields - - private readonly string _html = null; - private readonly bool _success = false; - - #endregion - - #region Properties - - /// - /// Html to be displayed as the result of the upload. - /// - public string Html - { - get { return _html; } - } - - /// - /// True if the upload was successfull, otherwise false. - /// - public bool Success - { - get { return _success; } - } - - #endregion - - #region Constructor - - /// - /// Creates a new instance of ActivityResult. - /// - /// Html to be displayed as the result of the upload. - /// True is the upload was successfull, otherwise false. - internal ActivityResult(string html, bool success) - { - _html = html; - _success = success; - } - - /// - /// Creates a new instance of ActivityResult. - /// - /// Html to be displayed as the result of the upload. - internal ActivityResult(string html) - { - _html = html; - _success = false; - } - - #endregion - } -} diff --git a/Foundation/UI/Web/BaseDataControl.cs b/Foundation/UI/Web/BaseDataControl.cs deleted file mode 100644 index d8d5778..0000000 --- a/Foundation/UI/Web/BaseDataControl.cs +++ /dev/null @@ -1,319 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.IO; -using System.Security.Principal; -using System.Web.Hosting; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Base control used to include common methods shared between activation - /// with a licence key and uploading a data file. - /// - public class BaseDataControl : BaseUserControl - { - #region Fields - - #region Css - - private string _buttonCssClass = "button"; - private string _successCssClass = "success"; - private string _errorCssClass = "error"; - - #endregion - - #region Messages - - private string _activationDataInvalidHtml = Resources.ActivationDataInvalidHtml; - private string _activationFailureCouldNotUpdateConfigHtml = Resources.ActivationFailureCouldNotUpdateConfigHtml; - private string _activationFailureCouldNotWriteDataFileHtml = Resources.ActivationFailureCouldNotWriteDataFileHtml; - private string _activationFailureCouldNotWriteLicenceFileHtml = Resources.ActivationFailureCouldNotWriteLicenceFileHtml; - private string _activationFailureGenericHtml = Resources.ActivationFailureGenericHtml; - private string _activationFailureHttpHtml = Resources.ActivationFailureHttpHtml; - private string _activationFailureInvalidHtml = Resources.ActivationFailureInvalidHtml; - private string _activationStreamFailureHtml = Resources.ActivationStreamFailureHtml; - private string _activationSuccessHtml = Resources.ActivationSuccessHtml; - private bool _instructionsEnabled = true; - - #endregion - - #endregion - - #region Properties - - #region Messages - - /// - /// Error HTML displayed if the premium data is invalid. - /// - public virtual string ActivationDataInvalidHtml - { - get - { - return _activationDataInvalidHtml; - } - set - { - _activationDataInvalidHtml = value; - } - } - - /// - /// Error HTML dispalyed in the configuration files can't be changed. - /// - public virtual string ActivationFailureCouldNotUpdateConfigHtml - { - get - { - return _activationFailureCouldNotUpdateConfigHtml; - } - set - { - _activationFailureCouldNotUpdateConfigHtml = value; - } - } - - /// - /// Error HTML displayed if the premium data file downloaded can't be written. - /// - public virtual string ActivationFailureCouldNotWriteDataFileHtml - { - get - { - return _activationFailureCouldNotWriteDataFileHtml; - } - set - { - _activationFailureCouldNotWriteDataFileHtml = value; - } - } - - /// - /// Error HTML displayed if the premium data licence file can't be written. - /// - public virtual string ActivationFailureCouldNotWriteLicenceFileHtml - { - get - { - return _activationFailureCouldNotWriteLicenceFileHtml; - } - set - { - _activationFailureCouldNotWriteLicenceFileHtml = value; - } - } - - /// - /// Error HTML displayed if there is a unknown problem with activation. - /// - public virtual string ActivationFailureGenericHtml - { - get - { - return _activationFailureGenericHtml; - } - set - { - _activationFailureGenericHtml = value; - } - } - - /// - /// Error HTML displayed if the HTTP connection to get premium data can not be established. - /// - public virtual string ActivationFailureHttpHtml - { - get - { - return _activationFailureHttpHtml; - } - set - { - _activationFailureHttpHtml = value; - } - } - - /// - /// Error HTML displayed if the licence key is invalid. - /// - public virtual string ActivationFailureInvalidHtml - { - get - { - return _activationFailureInvalidHtml; - } - set - { - _activationFailureInvalidHtml = value; - } - } - - /// - /// Error HTML displayed if the returned stream is not valid during activation. - /// - public virtual string ActivationStreamFailureHtml - { - get - { - return _activationStreamFailureHtml; - } - set - { - _activationStreamFailureHtml = value; - } - } - - /// - /// Error HTML displayed on successful activation. - /// - public virtual string ActivationSuccessHtml - { - get - { - return _activationSuccessHtml; - } - set - { - _activationSuccessHtml = value; - } - } - - /// - /// Controls if instruction messages are displayed. - /// - public virtual bool InstructionsEnabled - { - get { return _instructionsEnabled; } - set { _instructionsEnabled = value; } - } - - #endregion - - #region Css - - /// - /// Gets or sets the success css class for messages. - /// - public virtual string SuccessCssClass - { - get { return _successCssClass; } - set { _successCssClass = value; } - } - - /// - /// Gets or sets the error css class for messages. - /// - public virtual string ErrorCssClass - { - get { return _errorCssClass; } - set { _errorCssClass = value; } - } - - /// - /// Gets or sets the button css class for activation and refresh. - /// - public virtual string ButtonCssClass - { - get { return _buttonCssClass; } - set { _buttonCssClass = value; } - } - - #endregion - - #endregion - - #region Methods - - /// - /// Activates the data stream. - /// - /// Stream being uploaded. - /// - protected ActivityResult Execute(Stream stream) - { - return ProcessResult(FiftyOne.Foundation.Mobile.Detection.LicenceKey.Activate(stream)); - } - - /// - /// Activates the licence key and updates the user interface - /// with the results. - /// - /// The licence key to try activating. - /// - protected ActivityResult Execute(string licenceKey) - { - return ProcessResult(FiftyOne.Foundation.Mobile.Detection.LicenceKey.Activate(licenceKey)); - } - - /// - /// Creates the activity results object with the correct information - /// for use by a UI. - /// - /// - /// - private ActivityResult ProcessResult(LicenceKeyResults result) - { - switch (result) - { - case Mobile.Detection.LicenceKeyResults.Success: - return new ActivityResult( - String.Format( - ActivationSuccessHtml, - SuccessCssClass), - true); - case Mobile.Detection.LicenceKeyResults.Config: - return new ActivityResult(String.Format( - ActivationFailureCouldNotUpdateConfigHtml, - ErrorCssClass, - String.Join(", ", FiftyOne.Foundation.Mobile.Constants.ConfigFileNames))); - case Mobile.Detection.LicenceKeyResults.Https: - return new ActivityResult(String.Format( - ActivationFailureHttpHtml, - ErrorCssClass, - FiftyOne.Foundation.Mobile.Detection.LicenceKey.HostName)); - case Mobile.Detection.LicenceKeyResults.Invalid: - return new ActivityResult(String.Format( - ActivationFailureInvalidHtml, - ErrorCssClass)); - case Mobile.Detection.LicenceKeyResults.StreamFailure: - return new ActivityResult(String.Format( - ActivationStreamFailureHtml, - ErrorCssClass)); - case Mobile.Detection.LicenceKeyResults.DataInvalid: - return new ActivityResult(String.Format( - ActivationDataInvalidHtml, - ErrorCssClass)); - case Mobile.Detection.LicenceKeyResults.WriteLicenceFile: - return new ActivityResult(String.Format( - ActivationFailureCouldNotWriteLicenceFileHtml, - ErrorCssClass, - FiftyOne.Foundation.Mobile.Detection.LicenceKey.LicenceKeyFileName, - Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "bin"))); - case Mobile.Detection.LicenceKeyResults.WriteDataFile: - return new ActivityResult(String.Format( - ErrorCssClass, - ActivationFailureCouldNotWriteDataFileHtml, - AutoUpdate.BinaryFile.FullName, - WindowsIdentity.GetCurrent().Name)); - case Mobile.Detection.LicenceKeyResults.GenericFailure: - default: - return new ActivityResult(String.Format( - ActivationFailureGenericHtml, - ErrorCssClass)); - } - } - - #endregion - } -} diff --git a/Foundation/UI/Web/BaseUserControl.cs b/Foundation/UI/Web/BaseUserControl.cs deleted file mode 100644 index e5c66bb..0000000 --- a/Foundation/UI/Web/BaseUserControl.cs +++ /dev/null @@ -1,583 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Text; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// The base user control containing common methods shared across - /// controls. - /// - public abstract class BaseUserControl : UserControl - { - #region Fields - - /// - /// Footer control used to display stats about the provider. - /// - protected Stats _footer = null; - - /// - /// The container for the all controls in the user control. - /// - protected Panel _container; - - /// - /// Used to control if the logo is displayed, or not. - /// - private bool _logoEnabled = true; - - /// - /// Controls if the footer appears showing the date published - /// and if Lite or Premium data is being used. - /// - private bool _footerEnabled = true; - - // CSS class fields. - - private string _propertyCssClass = "property"; - private string _valueCssClass = "value"; - private string _descriptionCssClass = "description"; - private string _premiumCssClass = "premium"; - private string _liteCssClass = "lite"; - private string _cmsCssClass = "premium"; - private string _vendorCssClass = "vendor"; - private string _modelCssClass = "model"; - private string _nameCssClass = "name"; - private string _vendorsCssClass = "deviceExplorerVendors"; - private string _devicesCssClass = "deviceExplorerDevices"; - private string _deviceCssClass = "deviceExplorerDevice"; - private string _itemCssClass = "item"; - private string _imagesCssClass = "image"; - private string _wideValueCssClass = "wide"; - private string _cssClass = null; - private string _footerCssClass = "footer"; - - #endregion - - #region Properties - - /// - /// Event handler used to create a label control for the item provided. - /// - /// The container the control will be placed into. - /// The text that will appear in the label. - /// The tooltip that will be displayed next to the label. - /// A url for more information. - /// - public delegate void CreateLabelEventHandler(WebControl container, string text, string tooltip, Uri url); - - /// - /// Event handler used to enable the client to persist the parameters of a request - /// into a URL format of its choosing. - /// - /// - /// - public delegate string CreateUrlEventHandler(List parameters); - - /// - /// Event handler that if present will be used by GetNewUrl to find the url. - /// - public event CreateUrlEventHandler CreateUrl; - - /// - /// Event handler that if present will be used by GetNewLabel when creating a label. - /// - public event CreateLabelEventHandler CreateLabel; - - /// - /// Controls whether the footer is displayed. - /// - public bool FooterEnabled - { - get { return _footerEnabled; } - set { _footerEnabled = value; } - } - - /// - /// Used to determine if a 51Degrees.mobi logo is displayed in the top - /// right hand corner of the control. - /// - public bool LogoEnabled - { - get { return _logoEnabled; } - set { _logoEnabled = value; } - } - - /// - /// The css class used by each item in the control. - /// - public string ItemCssClass - { - get { return _itemCssClass; } - set { _itemCssClass = value; } - } - - /// - /// The css class used by a device image. - /// - public string ImagesCssClass - { - get { return _imagesCssClass; } - set { _imagesCssClass = value; } - } - - /// - /// The css class used to display long lists of values. - /// - public string WideCssClass - { - get { return _wideValueCssClass; } - set { _wideValueCssClass = value; } - } - - /// - /// The css class used by the default container. - /// - public string CssClass - { - get { return _cssClass; } - set { _cssClass = value; } - } - - /// - /// The css class used by the devices container. - /// - public string DevicesCssClass - { - get { return _devicesCssClass; } - set { _devicesCssClass = value; } - } - - /// - /// The css class used by the device container. - /// - public string DeviceCssClass - { - get { return _deviceCssClass; } - set { _deviceCssClass = value; } - } - - /// - /// The css class used by the vendors container. - /// - public string VendorsCssClass - { - get { return _vendorsCssClass; } - set { _vendorsCssClass = value; } - } - - /// - /// The css class to use when displaying hardware vendor. - /// - public string VendorCssClass - { - get { return _vendorCssClass; } - set { _vendorCssClass = value; } - } - - /// - /// The css class to use when displaying hardware model. - /// - public string ModelCssClass - { - get { return _modelCssClass; } - set { _modelCssClass = value; } - } - - /// - /// The css class to use when displaying hardware name. - /// - public string NameCssClass - { - get { return _nameCssClass; } - set { _nameCssClass = value; } - } - - /// - /// The css class to use when displaying lite properties. - /// - public string LiteCssClass - { - get { return _liteCssClass; } - set { _liteCssClass = value; } - } - - /// - /// The css class to use when displaying CMS properties. - /// - public string CmsCssClass - { - get { return _cmsCssClass; } - set { _cmsCssClass = value; } - } - - /// - /// The css class to use when displaying premium properties. - /// - public string PremiumCssClass - { - get { return _premiumCssClass; } - set { _premiumCssClass = value; } - } - - /// - /// The css class to use when displaying properties. - /// - public string PropertyCssClass - { - get { return _propertyCssClass; } - set { _propertyCssClass = value; } - } - - /// - /// The css class to use when displaying values. - /// - public string ValueCssClass - { - get { return _valueCssClass; } - set { _valueCssClass = value; } - } - - /// - /// The css class to use when displaying descriptions. - /// - public string DescriptionCssClass - { - get { return _descriptionCssClass; } - set { _descriptionCssClass = value; } - } - - /// - /// The css class used to display the footer statistics. - /// - public string FooterCssClass - { - get { return _footerCssClass; } - set { _footerCssClass = value; } - } - - #endregion - - #region Events - - /// - /// Adds the legend to the list of controls. - /// - /// - protected override void OnInit(EventArgs e) - { - EnableViewState = false; - _container = new Panel(); - _footer = new Stats(); - Controls.Add(_container); - Page.PreRenderComplete += new EventHandler(Page_PreRenderComplete); - base.OnInit(e); - Controls.Add(_footer); - } - - /// - /// Sets the CSS class of the control. - /// - /// - protected override void OnPreRender(EventArgs e) - { - _container.CssClass = _cssClass; - _footer.CssClass = FooterCssClass; - base.OnPreRender(e); - } - - /// - /// Displays the logo if requested and the footer. - /// - /// - /// - protected void Page_PreRenderComplete(object sender, EventArgs e) - { - if (_logoEnabled) - { - System.Web.UI.WebControls.Image image = new System.Web.UI.WebControls.Image(); - image.Style.Add("border", "none"); - image.Style.Add("margin", "5px"); - image.Style.Add("float", "right"); - image.ImageUrl = Constants.Logo; - _container.Controls.AddAt(0, image); - } - - _footer.Visible = _footerEnabled; - } - - #endregion - - #region Methods - - /// - /// Replaces all the standard tags in the source text with the values defined - /// for the user control. - /// - /// - /// - protected virtual string ReplaceTags(string source) - { - List> list = new List>(); - AddTag(list, "property", _propertyCssClass); - AddTag(list, "premium", _premiumCssClass); - AddTag(list, "lite", _liteCssClass); - AddTag(list, "cms", _cmsCssClass); - AddTag(list, "description", _descriptionCssClass); - AddTag(list, "value", _valueCssClass); - return ReplaceTags(source, list); - } - - #endregion - - #region Static Methods - - /// - /// Replaces the tag with the value in the text provided. - /// - /// The source string builder. - /// Collection of tags and their new values. - /// A string containing the altered text. - protected static string ReplaceTags(string source, List> tags) - { - StringBuilder builder = new StringBuilder(source); - foreach(KeyValuePair pair in tags) - builder = builder.Replace(String.Format("{{{0}}}", pair.Key), pair.Value); - return builder.ToString(); - } - - /// - /// Adds the tag and replacement value to the list. - /// - /// - /// - /// - protected static void AddTag(List> list, string key, string value) - { - list.Add(new KeyValuePair(key, value)); - } - - /// - /// Adds a
to the controls. - ///
- protected void AddBreak() - { - Literal literalBreak = new Literal(); - literalBreak.Text = "
"; - _container.Controls.Add(literalBreak); - } - - /// - /// Adds a label control to the panel provided, setting the label controls - /// text to the value provided. - /// - /// Control the label will be added to. - /// The text that will appear in the label. - /// The tooltip that will be displayed next to the label. - /// A url for more information. - /// The name of the anchor. - protected virtual void AddLabel(WebControl panel, string text, string tooltip, Uri url, string anchor) - { - // Open the anchor. - if (String.IsNullOrEmpty(anchor) == false) - { - Literal literalAnchorOpen = new Literal(); - literalAnchorOpen.Text = String.Format("", anchor); - panel.Controls.Add(literalAnchorOpen); - } - - // Add the label. - if (CreateLabel != null && - (String.IsNullOrEmpty(tooltip) == false || - url != null)) - { - CreateLabel(panel, text, tooltip, url); - } - else - { - Label labelContent = new Label(); - labelContent.Text = HttpUtility.HtmlEncode(text); - labelContent.ToolTip = tooltip; - panel.Controls.Add(labelContent); - AddLink(panel, tooltip, url); - } - - // Close the anchor. - if (String.IsNullOrEmpty(anchor) == false) - { - Literal literalAnchorClose = new Literal(); - literalAnchorClose.Text = ""; - panel.Controls.Add(literalAnchorClose); - } - } - - /// - /// Adds a link control to the output for the value provided. - /// - /// Panel the link should be added to. - /// The tooltip that will be displayed next to the label. - /// A url for more information. - private static void AddLink(WebControl panel, string tooltip, Uri url) - { - if (url != null || String.IsNullOrEmpty(tooltip) == false) - { - Label labelOpen = new Label(); - Label labelClose = new Label(); - - labelOpen.Text = " ("; - panel.Controls.Add(labelOpen); - - if (url != null) - { - HyperLink link = new HyperLink(); - link.NavigateUrl = url.ToString(); - link.Text = "?"; - link.ToolTip = tooltip; - link.Target = "_blank"; - panel.Controls.Add(link); - } - else - { - Label label = new Label(); - label.Text = "?"; - label.ToolTip = tooltip; - panel.Controls.Add(label); - } - - labelClose.Text = ")"; - panel.Controls.Add(labelClose); - } - } - - /// - /// Adds a plus toggle to the control, and then returns the control added. - /// - /// The parent control. - /// The CSS display style to apply when expanding. - /// The control added. - protected virtual Panel AddPlus(WebControl control, string style) - { - if (Page.ClientScript.IsClientScriptBlockRegistered(GetType(), "toggle") == false) - Page.ClientScript.RegisterClientScriptBlock(GetType(), "toggle", Resources.JavaScriptToggle, true); - - Panel target = new Panel(); - Label labelOpen = new Label(); - Label labelClose = new Label(); - LinkButton button = new LinkButton(); - - control.Controls.Add(labelOpen); - control.Controls.Add(button); - control.Controls.Add(labelClose); - control.Controls.Add(target); - - target.Style.Add(HtmlTextWriterStyle.Display, "none"); - - labelOpen.Text = "["; - button.OnClientClick = String.Format( - "javascript:toggle(this, '{0}', '{1}'); return false;", - target.ClientID, - style); - button.ToolTip = Resources.ToggleToolTip; - button.Text = "+"; - labelClose.Text = "]"; - - return target; - } - - /// - /// Creates a new GET url containing the key and value parameters. - /// - /// The parameter key. - /// The parameter value. - /// A new url containing the additional key and value parameters. - protected virtual string GetNewUrl(string key, string value) - { - return GetNewUrl(new NameValueCollection(Request.QueryString), key, value); - } - - /// - /// Returns a new url that will replace, or add a parameter - /// to the one that is currently being used. - /// - /// Existing list of parameters to be altered. - /// The parameter key. - /// The parameter value. - /// A new url containing the parameters provided and the new key and value. - protected virtual string GetNewUrl(NameValueCollection parameters, string key, string value) - { - return GetNewUrl(Request.Url.AbsolutePath, parameters, key, value); - } - - /// - /// Returns a new url that will replace, or add a parameter - /// to the one that is currently being used. - /// - /// The root url to add parameters too. - /// Existing list of parameters to be altered. - /// A new url containing the parameters provided and the new key and value. - protected virtual string GetNewUrl(string absoluteUrl, NameValueCollection parameters) - { - return GetNewUrl(absoluteUrl, parameters, String.Empty); - } - - /// - /// Returns a new url that will replace, or add a parameter - /// to the one that is currently being used. - /// - /// The root url to add parameters too. - /// Existing list of parameters to be altered. - /// A parameter key not to be removed from the list of parameters. - /// A new url containing the parameters provided and the new key and value. - protected virtual string GetNewUrl(string absoluteUrl, NameValueCollection parameters, string key) - { - List list = new List(); - - // keys beginning with an _ will not be added to links, unless it was in the parameter - foreach (string index in parameters.Keys) - if (index.StartsWith("_") == false || index == key) - list.Add(String.Format("{0}={1}", index, HttpUtility.UrlEncode(parameters[index]))); - - if (CreateUrl != null) - return CreateUrl(list); - - return String.Format("{0}?{1}", - absoluteUrl, - String.Join("&", list.ToArray())); - } - - /// - /// Returns a new url that will replace, or add a parameter - /// to the one that was supplied. - /// - /// The root url to add parameters too. - /// Existing list of parameters to be altered. - /// The parameter key. - /// The parameter value. - /// A new url containing the parameters provided and the new key and value. - protected virtual string GetNewUrl(string absoluteUrl, NameValueCollection parameters, string key, string value) - { - parameters.Remove(key); - if (value != null) - parameters.Add(key, value); - return GetNewUrl(absoluteUrl, parameters); - } - - #endregion - } -} diff --git a/Foundation/UI/Web/Detection.cs b/Foundation/UI/Web/Detection.cs deleted file mode 100644 index 6b98458..0000000 --- a/Foundation/UI/Web/Detection.cs +++ /dev/null @@ -1,688 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Web.UI.WebControls; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Display a user interface to enable the user to enter a Premium license key and upgrade Foundation - /// to the premium product. If the fiftyOne/detection element does not exist in the configuration - /// this element is added and the binaryFilePath set to "51Degrees-Premium.dat". The licence key will - /// be written to a file called 51Degrees.mobi.lic in the bin folder. - /// If the site is running in medium trust mode the operation will fail and a message will be displayed - /// to the user. - /// The control also contains a check box to enable / disable the sharing of usage information with - /// 51Degrees.mobi. - /// - public class Detection : BaseDataControl - { - #region Constants - - private const string VALIDATION_LICENCE = "ValidateLicence"; - - #endregion - - #region Fields - - #region Controls - - private Literal _literalInstructions = null; - private TextBox _textBoxLicenceKey = null; - private Button _buttonActivate = null; - private Button _buttonRefresh = null; - private RequiredFieldValidator _validatorRequired = null; - private RegularExpressionValidator _validatorRegEx = null; - private ValidationSummary _validationLicenceSummary = null; - private Literal _literalResult = null; - private Upload _upload = new Upload(); - private Literal _literalUpload = null; - private ShareUsage _shareUsage = new ShareUsage(); - - #endregion - - #region Css - - private string _textBoxCssClass = "textbox"; - - #endregion - - #region Messages - - private string _activateButtonText = Resources.ActivateButtonText; - private string _activatedMessageHtml = Resources.ActivatedMessageHtml; - private string _activateInstructionsHtml = Resources.ActivateInstructionsHtml; - private string _uploadInstructionsHtml = Resources.UploadInstructionsHtml; - private string _validationRequiredErrorText = Resources.ValidationRequiredErrorText; - private string _refreshButtonText = Resources.RefreshButtonText; - private string _validationRegExErrorText = Resources.ValidationRegExErrorText; - - #endregion - - #endregion - - #region Properties - - #region Messages - - /// - /// The url of the page that should be used to find out more about - /// sharing usage information. - /// - public string ShareUsageUrl - { - get { return _shareUsage.ShareUsageUrl; } - set { _shareUsage.ShareUsageUrl = value; } - } - - /// - /// The text that should appear on the hyper link next to the - /// share usage check box text. - /// - public string ShareUsageLinkText - { - get { return _shareUsage.ShareUsageLinkText; } - set { _shareUsage.ShareUsageLinkText = value; } - } - - /// - /// Html used when the share usage value is set to true. - /// - public string ShareUsageTrueHtml - { - get { return _shareUsage.ShareUsageTrueHtml; } - set { _shareUsage.ShareUsageTrueHtml = value; } - } - - /// - /// Html used when the share usage value is set to false. - /// - public string ShareUsageFalseHtml - { - get { return _shareUsage.ShareUsageFalseHtml; } - set { _shareUsage.ShareUsageFalseHtml = value; } - } - - /// - /// Html used when an error is generated changing the share usage value. - /// - public string ShareUsageErrorHtml - { - get { return _shareUsage.ShareUsageErrorHtml; } - set { _shareUsage.ShareUsageErrorHtml = value; } - } - - /// - /// Text used to inform user about sharing usage information. - /// - public string ShareUsageText - { - get { return _shareUsage.ShareUsageText; } - set { _shareUsage.ShareUsageText = value; } - } - - /// - /// Error HTML displayed if the premium data is invalid. - /// - public override string ActivationDataInvalidHtml - { - get - { - return base.ActivationDataInvalidHtml; - } - set - { - base.ActivationDataInvalidHtml = value; - _upload.ActivationDataInvalidHtml = value; - } - } - - /// - /// Error HTML dispalyed in the configuration files can't be changed. - /// - public override string ActivationFailureCouldNotUpdateConfigHtml - { - get - { - return base.ActivationFailureCouldNotUpdateConfigHtml; - } - set - { - base.ActivationFailureCouldNotUpdateConfigHtml = value; - _upload.ActivationFailureCouldNotUpdateConfigHtml = value; - } - } - - /// - /// Error HTML displayed if the premium data file downloaded can't be written. - /// - public override string ActivationFailureCouldNotWriteDataFileHtml - { - get - { - return base.ActivationFailureCouldNotWriteDataFileHtml; - } - set - { - base.ActivationFailureCouldNotWriteDataFileHtml = value; - _upload.ActivationFailureCouldNotWriteDataFileHtml = value; - } - } - - /// - /// Error HTML displayed if the premium data licence file can't be written. - /// - public override string ActivationFailureCouldNotWriteLicenceFileHtml - { - get - { - return base.ActivationFailureCouldNotWriteLicenceFileHtml; - } - set - { - base.ActivationFailureCouldNotWriteLicenceFileHtml = value; - _upload.ActivationFailureCouldNotWriteLicenceFileHtml = value; - } - } - - /// - /// Error HTML displayed if there is a unknown problem with activation. - /// - public override string ActivationFailureGenericHtml - { - get - { - return base.ActivationFailureGenericHtml; - } - set - { - base.ActivationFailureGenericHtml = value; - _upload.ActivationFailureGenericHtml = value; - } - } - - /// - /// Error HTML displayed if the HTTP connection to get premium data can not be established. - /// - public override string ActivationFailureHttpHtml - { - get - { - return base.ActivationFailureHttpHtml; - } - set - { - base.ActivationFailureHttpHtml = value; - _upload.ActivationFailureHttpHtml = value; - } - } - - /// - /// Error HTML displayed if the licence key is invalid. - /// - public override string ActivationFailureInvalidHtml - { - get - { - return base.ActivationFailureInvalidHtml; - } - set - { - base.ActivationFailureInvalidHtml = value; - _upload.ActivationFailureInvalidHtml = value; - } - } - - /// - /// Error HTML displayed if the returned stream is not valid during activation. - /// - public override string ActivationStreamFailureHtml - { - get - { - return base.ActivationStreamFailureHtml; - } - set - { - base.ActivationStreamFailureHtml = value; - _upload.ActivationStreamFailureHtml = value; - } - } - - /// - /// Error HTML displayed on successful activation. - /// - public override string ActivationSuccessHtml - { - get - { - return base.ActivationSuccessHtml; - } - set - { - base.ActivationSuccessHtml = value; - _upload.ActivationSuccessHtml = value; - } - } - - /// - /// Validation regex error message. - /// - public string ValidationRegExErrorText - { - get { return _validationRegExErrorText; } - set { _validationRegExErrorText = value; } - } - - /// - /// Activate button text. - /// - public string ActivateButtonText - { - get - { - return _activateButtonText; - } - set - { - _activateButtonText = value; - } - } - - /// - /// HTML displayed when the premium data is activated. - /// - public string ActivatedMessageHtml - { - get - { - return _activatedMessageHtml; - } - set - { - _activatedMessageHtml = value; - } - } - - /// - /// Instruction HTML to activate premium data. Appears at the top of the control. - /// Suppressed if InstructionsEnabled is set to false. - /// - public string ActivateInstructionsHtml - { - get - { - return _activateInstructionsHtml; - } - set - { - _activateInstructionsHtml = value; - } - } - - /// - /// Errror message displayed if the licence key is not provided. - /// - public string ValidationRequiredErrorText - { - get - { - return _validationRequiredErrorText; - } - set - { - _validationRequiredErrorText = value; - } - } - - /// - /// Error message displayed if the file provided is invalid. - /// - public string ValidationFileErrorText - { - get - { - return _upload.ValidationFileErrorText; - } - set - { - _upload.ValidationFileErrorText = value; - } - } - - /// - /// Text used on the refresh button displayed after activation. - /// - public string RefreshButtonText - { - get - { - return _refreshButtonText; - } - set - { - _refreshButtonText = value; - } - } - - /// - /// Text used on the upload file button. - /// - public string UploadButtonText - { - get - { - return _upload.UploadButtonText; - } - set - { - _upload.UploadButtonText = value; - } - } - - /// - /// Instruction HTML used in the middle of the control to explain how to upload data. - /// - public string UploadInstructionsHtml - { - get - { - return _uploadInstructionsHtml; - } - set - { - _uploadInstructionsHtml = value; - } - } - - #endregion - - #region Css - - /// - /// Gets or sets the hyper link css class for share usage. - /// - public string HyperLinkCssClass - { - get { return _shareUsage.HyperLinkCssClass; } - set { _shareUsage.HyperLinkCssClass = value; } - } - - /// - /// Gets or sets the check box css class for share usaged check box. - /// - public string CheckBoxCssClass - { - get { return _shareUsage.CheckBoxCssClass; } - set { _shareUsage.CheckBoxCssClass = value; } - } - - /// - /// Gets or sets the text box css class for licence key entry. - /// - public string TextBoxCssClass - { - get { return _textBoxCssClass; } - set { _textBoxCssClass = value; } - } - - /// - /// Gets or sets the button css class for activation and refresh. - /// - public override string ButtonCssClass - { - get { return base.ButtonCssClass; } - set { base.ButtonCssClass = value; _upload.ButtonCssClass = value; } - } - - /// - /// Gets or sets the success css class for messages. - /// - public override string SuccessCssClass - { - get { return base.SuccessCssClass; } - set { base.SuccessCssClass = value; _upload.SuccessCssClass = value; _shareUsage.SuccessCssClass = value; } - } - - /// - /// Gets or sets the error css class for messages. - /// - public override string ErrorCssClass - { - get { return base.ErrorCssClass; } - set { base.ErrorCssClass = value; _upload.ErrorCssClass = value; _shareUsage.ErrorCssClass = value; } - } - - #endregion - - #region Controls - - /// - /// The textbox used to capture the licence key. - /// - public TextBox LicenceKeyTextBox - { - get { return _textBoxLicenceKey; } - } - - /// - /// The button used to activate the licence key. - /// - public Button ActivateButton - { - get { return _buttonActivate; } - } - - /// - /// The upload control used to upload data. - /// - public Upload ActivateFileUploadData - { - get { return _upload; } - } - - #endregion - - #region Other - - /// - /// Controls whether the share usage information is displayed. - /// Defaults to true. - /// - public bool ShowShareUsage - { - get { return _shareUsage.ShowShareUsage; } - set { _shareUsage.ShowShareUsage = value; } - } - - /// - /// Controls if instruction messages are displayed. - /// - public override bool InstructionsEnabled - { - get { return base.InstructionsEnabled; } - set - { - base.InstructionsEnabled = value; - _upload.InstructionsEnabled = value; - } - } - - #endregion - - #endregion - - #region Events - - /// - /// Load the controls which will form the user interface. - /// - /// - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - // Set the literal control. - _literalUpload = new Literal(); - _literalInstructions = new Literal(); - - // Create the required controls. - _textBoxLicenceKey = new TextBox(); - _buttonActivate = new Button(); - _buttonRefresh = new Button(); - _validatorRequired = new RequiredFieldValidator(); - _validatorRegEx = new RegularExpressionValidator(); - _validationLicenceSummary = new ValidationSummary(); - _literalResult = new Literal(); - - // Set the new controls properties. - _buttonActivate.ID = "ButtonActivate"; - _buttonActivate.Click += new EventHandler(_buttonActivate_Click); - _buttonActivate.ValidationGroup = VALIDATION_LICENCE; - _buttonRefresh.ID = "ButtonRefresh"; - _buttonRefresh.Click += new EventHandler(_buttonActivate_Click); - _buttonRefresh.Visible = false; - _textBoxLicenceKey.ID = "TextBoxLicenceKey"; - _textBoxLicenceKey.ValidationGroup = VALIDATION_LICENCE; - - // Set the validators. - _validatorRequired.ID = "ValidatorRequired"; - _validatorRegEx.ID = "ValidatorRegEx"; - _validationLicenceSummary.ID = "ValidationLicenceSummary"; - _validatorRequired.ControlToValidate = _validatorRegEx.ControlToValidate = _textBoxLicenceKey.ID; - _validatorRegEx.ValidationGroup = _validatorRequired.ValidationGroup = VALIDATION_LICENCE; - _validatorRegEx.ValidationExpression = FiftyOne.Foundation.Mobile.Detection.Constants.LicenceKeyValidationRegex; - _validationLicenceSummary.DisplayMode = ValidationSummaryDisplayMode.SingleParagraph; - _validationLicenceSummary.Style.Clear(); - _validationLicenceSummary.ValidationGroup = VALIDATION_LICENCE; - _validatorRequired.Display = _validatorRegEx.Display = ValidatorDisplay.None; - _validatorRegEx.EnableClientScript = _validatorRequired.EnableClientScript = - _validationLicenceSummary.EnableClientScript = true; - - // Set the child controls. - _upload.FooterEnabled = false; - _upload.LogoEnabled = false; - _upload.UploadComplete += new UploadEventHandler(_upload_UploadComplete); - _shareUsage.LogoEnabled = false; - _shareUsage.FooterEnabled = false; - _shareUsage.ShareUsageChanged += new ShareUsageChangedEventHandler(_shareUsage_ShareUsageChanged); - - // Add the controls to the user control. - if (DataProvider.IsPremium == false) - { - _container.Controls.Add(_literalResult); - _container.Controls.Add(_validationLicenceSummary); - } - _container.Controls.Add(_literalInstructions); - if (DataProvider.IsPremium == false && DataProvider.IsCms == false) - { - _container.Controls.Add(_validatorRequired); - _container.Controls.Add(_validatorRegEx); - _container.Controls.Add(_textBoxLicenceKey); - _container.Controls.Add(_buttonActivate); - _container.Controls.Add(_buttonRefresh); - _container.Controls.Add(_literalUpload); - _container.Controls.Add(_upload); - } - - _container.Controls.Add(_shareUsage); - } - - /// - /// Sets the visible status of the instruction messages. - /// - /// - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - _literalInstructions.Visible = _literalInstructions.Visible & InstructionsEnabled; - _literalUpload.Visible = _literalUpload.Visible & InstructionsEnabled; - if (String.IsNullOrEmpty(_literalInstructions.Text)) - _literalInstructions.Text = (DataProvider.IsPremium || DataProvider.IsCms) ? - String.Format(ActivatedMessageHtml, SuccessCssClass, DataProvider.Provider.DataSetName) : - ActivateInstructionsHtml; - _literalUpload.Text = UploadInstructionsHtml; - _buttonActivate.Text = ActivateButtonText; - _buttonRefresh.Text = RefreshButtonText; - _validatorRequired.ErrorMessage = ValidationRequiredErrorText; - _buttonActivate.CssClass = ButtonCssClass; - _buttonRefresh.CssClass = ButtonCssClass; - _textBoxLicenceKey.CssClass = TextBoxCssClass; - _validationLicenceSummary.CssClass = ErrorCssClass; - _validatorRegEx.ErrorMessage = ValidationRegExErrorText; - } - - /// - /// Fired when the user presses the Activate button. - /// - /// - /// - private void _buttonActivate_Click(object sender, EventArgs e) - { - if (Page.IsValid) - { - ActivityResult result = Execute(_textBoxLicenceKey.Text); - DisplayResults(result); - } - } - - /// - /// Displays the results to the user. - /// - /// - /// - private void _upload_UploadComplete(object sender, ActivityResult e) - { - DisplayResults(e); - } - - /// - /// Displays the result of the share usage change. - /// - /// - /// - private void _shareUsage_ShareUsageChanged(object sender, string html) - { - _literalInstructions.Text = html; - } - - /// - /// Displays the results returned from an activation or an - /// upload activity. - /// - /// - private void DisplayResults(ActivityResult result) - { - _literalResult.Text = result.Html; - if (result.Success) - { - _buttonActivate.Visible = _textBoxLicenceKey.Visible = _literalInstructions.Visible = - _validationLicenceSummary.Visible = _validatorRegEx.Visible = _validatorRequired.Visible = - _literalUpload.Visible = _upload.Visible = false; - _buttonRefresh.Visible = true; - base._footer.ButtonVisible = false; - } - } - - /// - /// Used to refresh the page after the activation has been successful. - /// - /// - /// - private void _buttonRefresh_Click(object sender, EventArgs e) - { - // Do nothing. - } - - #endregion - } -} diff --git a/Foundation/UI/Web/DeviceExplorer.cs b/Foundation/UI/Web/DeviceExplorer.cs deleted file mode 100644 index daea383..0000000 --- a/Foundation/UI/Web/DeviceExplorer.cs +++ /dev/null @@ -1,1038 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.IO; -using System.Reflection; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Xml; -using FiftyOne.Foundation.Mobile.Detection; -using FiftyOne.Foundation.Mobile.Detection.Matchers; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Used to explore the devices contained in the database. Won't work with Lite data. - /// - public class DeviceExplorer : BaseUserControl - { - #region Fields - - private Repeater _vendors; - private DataList _models; - private DataList _related; - private Panel _device; - private Panel _match; - private Panel _search; - - private string _vendor; - private string _model; - private string _deviceID; - private string _searchText; - private string _userAgent; - - private string _backButtonCssClass = "back"; - private string _pagerCssClass = "pager"; - private string _searchCssClass = "search"; - private string _searchTextCssClass = "searchText"; - private string _searchBoxCssClass = "searchBox"; - private string _searchButtonCssClass = "searchButton"; - private string _matchCssClass = "match"; - - private bool _navigation = true; - - private Literal _literalInstruction; - - private TextBox _searchBox; - private Button _searchButton; - - private string _deviceExplorerDeviceHtml = Resources.DeviceExplorerDeviceInstructionsHtml; - private string _deviceExplorerVendorsHtml = Resources.DeviceExplorerVendorsHtml; - private string _deviceExplorerModelsHtml = Resources.DeviceExplorerModelsInstructionsHtml; - private string _backButtonDevicesText = Resources.BackButtonDevicesText; - private string _backButtonDeviceText = Resources.BackButtonDeviceText; - private string _devicesVendorHeading = Resources.DevicesVendorHeading; - private string _relatedDevicesHeading = Resources.RelatedDevicesHeading; - private string _searchInstructionsText = Resources.SearchBoxInstructionText; - private string _searchButtonText = Resources.SearchBoxButtonText; - private string _matchCaption = Resources.MatchCaption; - - private HyperLink _linkBackTop; - private HyperLink _linkBackBottom; - private Panel _panelBackTop; - private Panel _panelBackBottom; - private Panel _searchPanel; - private Panel _instructions; - private Literal _instructionText; - - private bool _imagesEnabled = false; - private int _devicesLimit = 30; - - #endregion - - #region Properties - - /// - /// The user agent of the device to be displayed. - /// - public string UserAgent - { - get - { - if (_userAgent == null) - { - _userAgent = Request.QueryString["UserAgent"]; - } - return _userAgent; - } - set { _userAgent = value; } - } - - /// - /// The caption of the results section if displayed. - /// - public string MatchCaption - { - get { return _matchCaption; } - set { _matchCaption = value; } - } - - /// - /// The heading used to indicate a list of related devices. - /// - public string RelatedDevicesHeading - { - get { return _relatedDevicesHeading; } - set { _relatedDevicesHeading = value; } - } - - /// - /// The heading showing the list of devices for the vendor. The {0} - /// tag is replaced with the vendor name. - /// - public string DevicesVendorHeading - { - get { return _devicesVendorHeading; } - set { _devicesVendorHeading = value; } - } - - /// - /// The message shown on the back button when displayed on the screen showing - /// the properties of a specific device. The {0} tag of the string is - /// replaced with the vendor name. - /// - public string BackButtonDeviceText - { - get { return _backButtonDeviceText; } - set { _backButtonDeviceText = value; } - } - - /// - /// The message shown on the back button when displayed on the screen showing - /// models enabling the user to return to the list of vendors. - /// - public string BackButtonDevicesText - { - get { return _backButtonDevicesText; } - set { _backButtonDevicesText = value; } - } - - /// - /// The message shown at the top of the control when models are displayed. - /// - public string DeviceExplorerModelsHtml - { - get { return _deviceExplorerModelsHtml; } - set { _deviceExplorerModelsHtml = value; } - } - - /// - /// The message shown at the top of the control when vendors are displayed. - /// - public string DeviceExplorerVendorsHtml - { - get { return _deviceExplorerVendorsHtml; } - set { _deviceExplorerVendorsHtml = value; } - } - - /// - /// The message shown at the top of the control when device details are displayed. - /// - public string DeviceExplorerDeviceHtml - { - get { return _deviceExplorerDeviceHtml; } - set { _deviceExplorerDeviceHtml = value; } - } - - /// - /// Controls if navigating away from the set page is enabled. - /// - public bool Navigation - { - get { return _navigation; } - set { _navigation = value; } - } - - /// - /// The CssClass used to display the caption indicating the - /// results of the user agent test. - /// - public string MatchCssClass - { - get { return _matchCssClass; } - set { _matchCssClass = value; } - } - - /// - /// The CssClass to be used by the back button. - /// - public string BackButtonCssClass - { - get { return _backButtonCssClass; } - set { _backButtonCssClass = value; } - } - - /// - /// The CssClass used by the search box. - /// - public string SearchBoxCssClass - { - get { return _searchBoxCssClass; } - set { _searchBoxCssClass = value; } - } - - /// - /// The CssClass used by the search button. - /// - public string SearchButtonCssClass - { - get { return _searchButtonCssClass; } - set { _searchButtonCssClass = value; } - } - - /// - /// The CssClass used by the search div. - /// - public string SearchCssClass - { - get { return _searchCssClass; } - set { _searchCssClass = value; } - } - - /// - /// The CssClass used by the search text. - /// - public string SearchTextCssClass - { - get{return _searchTextCssClass;} - set{_searchTextCssClass = value;} - } - - /// - /// Returns the XML resource with the headings for each property. - /// - private static Stream Headings - { - get - { - return Assembly.GetExecutingAssembly() - .GetManifestResourceStream("FiftyOne.Foundation.UI.Headings.xml"); - } - } - - /// - /// The vendor the user has selected. - /// - public string Vendor - { - get - { - if (_vendor == null) - { - _vendor = Request.QueryString["Vendor"]; - } - return _vendor; - } - set - { - _vendor = value; - } - } - - /// - /// The search term the user has created. - /// - public string SearchText - { - get - { - if (_searchText == null) - { - _searchText = Request.QueryString["Search"]; - } - return _searchText; - } - set - { - _searchText = value; - } - } - - /// - /// The device id to be displayed. - /// - public string DeviceID - { - get - { - if (_deviceID == null) - { - _deviceID = Request.QueryString["DeviceID"]; - } - return _deviceID; - } - set - { - _deviceID = value; - } - } - - /// - /// Model the user has selected. - /// - public string Model - { - get - { - if (_model == null) - { - _model = Request.QueryString["Model"]; - } - return _model; - } - set - { - _model = value; - } - } - - /// - /// Controls if the control will display device images. - /// - public bool ImagesEnabled - { - get { return _imagesEnabled; } - set { _imagesEnabled = value; } - } - - /// - /// Gets or sets how many devices should be displayed at once. - /// - public int DevicesLimit - { - get { return _devicesLimit; } - set { _devicesLimit = value; } - } - - /// - /// Gets or sets the instructions text to use with the device search. - /// - public string SearchInstructionsText - { - get { return _searchInstructionsText; } - set { _searchInstructionsText = value; } - } - - /// - /// Gets or sets the text to use on the device search button. - /// - public string SearchButtonText - { - get { return _searchButtonText; } - set { _searchButtonText = value; } - } - - #endregion - - #region Events - - /// - /// Set the visibility of the data lists. - /// - /// - protected override void OnInit(EventArgs e) - { - - base.OnInit(e); Literal clearTop = new Literal(); - Literal clearBottom = new Literal(); - clearTop.Text = clearBottom.Text = "
"; - _literalInstruction = new Literal(); - _linkBackTop = new HyperLink(); - _panelBackTop = new Panel(); - _vendors = CreateVendorRepeater(); - _models = CreateDeviceDataList(); - _related = CreateRelatedDeviceDataList(); - _search = CreateSearch(); - _device = new Panel(); - _match = new Panel(); - _panelBackBottom = new Panel(); - _linkBackBottom = new HyperLink(); - - _panelBackTop.Visible = _panelBackBottom.Visible = false; - _container.Controls.Add(_search); - _panelBackTop.Controls.Add(_linkBackTop); - _container.Controls.Add(_panelBackTop); - _container.Controls.Add(_literalInstruction); - _container.Controls.Add(clearTop); - _container.Controls.Add(_vendors); - _container.Controls.Add(_models); - _container.Controls.Add(_match); - _container.Controls.Add(_device); - _container.Controls.Add(_related); - _container.Controls.Add(clearBottom); - _panelBackBottom.Controls.Add(_linkBackBottom); - _container.Controls.Add(_panelBackBottom); - _container.Controls.Add(DeviceImages.GetImageRotationScript()); - } - - /// - /// PreRenders one of the three available controls. - /// - /// - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - - - _searchPanel.CssClass = SearchCssClass; - - _instructions.CssClass = SearchTextCssClass; - _instructionText.Text = SearchInstructionsText; - - _searchButton.Text = SearchButtonText; - _searchButton.CssClass = SearchButtonCssClass; - - _searchBox.Text = SearchText; - _searchBox.CssClass = SearchBoxCssClass; - - _models.HeaderTemplate = new HeaderTemplate(String.Format(DevicesVendorHeading, Vendor), 1); - _related.HeaderTemplate = new HeaderTemplate(RelatedDevicesHeading, 1); - - _match.Visible = String.IsNullOrEmpty(UserAgent) == false; - - _device.Visible = - _match.Visible || - (String.IsNullOrEmpty(Vendor) == false && String.IsNullOrEmpty(Model) == false) || - String.IsNullOrEmpty(DeviceID) == false; - - _models.Visible = _device.Visible == false && - (String.IsNullOrEmpty(Vendor) == false || String.IsNullOrEmpty(SearchText) == false); - - _vendors.Visible = _device.Visible == false && _models.Visible == false; - - _search.Visible = DataProvider.IsPremium && (_vendors.Visible || _models.Visible); - - if (_vendors.Visible && DataProvider.IsPremium) - { - _literalInstruction.Text = DeviceExplorerVendorsHtml; - _vendors.DataSource = DataProvider.Vendors.Keys; - _vendors.DataBind(); - _container.CssClass = VendorsCssClass; - } - - if (_models.Visible && DataProvider.IsPremium) - { - List models = GetModels(); - _literalInstruction.Text = DeviceExplorerModelsHtml; - - int currentPage = 1; - if (Request.QueryString["_Page"] != null) - { - Int32.TryParse(Request.QueryString["_Page"], out currentPage); - } - - int adjustedPage = currentPage - 1; - int firstDevice = adjustedPage * _devicesLimit; - int lastDevice = firstDevice + _devicesLimit; - int offset = lastDevice < models.Count ? _devicesLimit : models.Count - firstDevice; - int totalPages = (int)Math.Ceiling((double)(models.Count + 1) / (double)_devicesLimit); - - try - { - _models.DataSource = models.GetRange(firstDevice, offset); - _models.DataBind(); - } - catch { } - - // only add pager if there is more than one page - if (totalPages > 1) - _container.Controls.Add(GetPagerFooter(currentPage, totalPages)); - - _container.CssClass = DevicesCssClass; - - NameValueCollection parameters = new NameValueCollection(Request.QueryString); - parameters.Remove("Vendor"); - _panelBackBottom.Visible = _panelBackTop.Visible = _navigation; - _linkBackBottom.Text = _linkBackTop.Text = String.Format(BackButtonDevicesText); - _linkBackBottom.NavigateUrl = _linkBackTop.NavigateUrl = GetNewUrl(parameters, null, null); - } - - if (_device.Visible) - { - Device device = null; - - // Try the device id if present to get the device. - if (DeviceID != null) - device = DataProvider.GetDeviceFromDeviceID(DeviceID); - - // The device id isn't provided, or didn't return a device - // so try the vendor and model if present. - if (device == null && - String.IsNullOrEmpty(Vendor) == false && - String.IsNullOrEmpty(Model) == false) - device = DataProvider.GetDeviceFromModel(Vendor, Model); - - // A device hasn't been found via the DeviceId, Vendor and Model - // if the user agent is provided then use this to get the device. - if (device == null && - String.IsNullOrEmpty(UserAgent) == false) - { -#pragma warning disable - Result result = DataProvider.Provider.GetResult(UserAgent); -#warning warning restore - ConstructResultContent(result); - device = DataProvider.GetDeviceFromDeviceID(result.Device.DeviceId); - } - - if (device != null) - { - _literalInstruction.Text = DeviceExplorerDeviceHtml; - if (_imagesEnabled) - { - Panel imagesPanel = DeviceImages.GetImagesPanel(device); - if (imagesPanel != null) - _device.Controls.Add(imagesPanel); - } - ConstructDeviceContent(device); - - _container.CssClass = DeviceCssClass; - - List relatedDevices = DataProvider.GetRelatedInfo(device); - if (relatedDevices.Count > 0) - { - _related.DataSource = DataProvider.GetRelatedInfo(device); - _related.DataBind(); - } - - NameValueCollection parameters = new NameValueCollection(Request.QueryString); - parameters.Remove("Model"); - parameters.Remove("DeviceID"); - parameters.Remove("UserAgent"); - parameters.Remove("Search"); - _panelBackBottom.Visible = _panelBackTop.Visible = _navigation; - _linkBackBottom.Text = _linkBackTop.Text = String.Format(BackButtonDeviceText, device.HardwareVendor); - _linkBackBottom.NavigateUrl = _linkBackTop.NavigateUrl = GetNewUrl(parameters, "Vendor", device.HardwareVendor); - } - } - - _container.DefaultButton = _searchButton.ID; - - _panelBackTop.CssClass = _panelBackBottom.CssClass = BackButtonCssClass; - } - - private void ConstructResultContent(Result result) - { - Literal heading = CreateHeading(1, _matchCaption); - _match.Controls.Add(heading); - - Literal table = new Literal(); - table.Text = String.Format( - "" + - "" + - "" + - "" + - "" + - "" + - "
UserAgents
  Requested{1}
  Found{2}
Confidence{3}
Difference{4:0.###}
", - MatchCssClass, - UserAgent, - result.Device.UserAgent, - result.Confidence.ToString(), - result.Difference); - - _match.Controls.Add(table); - } - - /// - /// Gets models that safisfy search and vendor conditions. - /// - /// - protected virtual List GetModels() - { -#if VER4 || VER35 - IEnumerable modelsEnum = DataProvider.Devices.AsEnumerable(); - - // check if a vendor has been specified - if (!String.IsNullOrEmpty(Vendor)) - modelsEnum = modelsEnum.Where(d => d.HardwareVendor == Vendor); - - // check if a search has been specified - if (!String.IsNullOrEmpty(SearchText)) - { - // gets seperate search terms by split search at spaces. Also removes empty entries and converts to lower case. - string[] searchTerms = - SearchText.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries) - .Select(s => s.ToLowerInvariant()).ToArray(); - - modelsEnum = modelsEnum.Where(d => MatchesSearch(searchTerms, d)); - } - - List models = modelsEnum.ToList(); -#else - List models = DataProvider.Devices; - - if (!String.IsNullOrEmpty(Vendor)) - { - List vendorModels = new List(); - foreach (Device model in models) - { - if (model.HardwareVendor == Vendor) - vendorModels.Add(model); - } - models = vendorModels; - } - - if (!String.IsNullOrEmpty(SearchText)) - { - string[] searchTerms = SearchText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < searchTerms.Length; i++) - searchTerms[i] = searchTerms[i].ToLowerInvariant(); - - List searchModels = new List(); - foreach (Device model in models) - { - if (MatchesSearch(searchTerms, model)) - searchModels.Add(model); - } - models = searchModels; - } -#endif - return models; - } - - private string GetPageUrl(int page) - { - return GetNewUrl("_Page", page.ToString()); - } - - private Control GetPagerFooter(int currentPage, int maxPage) - { - Panel panel = new Panel(); - panel.CssClass = _pagerCssClass; - - if (currentPage == 1) - { - Label prev = new Label(); - prev.Text = "< Prev "; - panel.Controls.Add(prev); - } - else - { - HyperLink prev = new HyperLink(); - prev.Text = "< Prev "; - prev.NavigateUrl = GetPageUrl(currentPage - 1); - panel.Controls.Add(prev); - } - - { - Label spacer = new Label(); - spacer.Text = " | "; - panel.Controls.Add(spacer); - } - - for(int i = 1; i < maxPage; i++) - { - if (i != currentPage) - { - HyperLink link = new HyperLink(); - link.Text = i.ToString(); - link.NavigateUrl = GetPageUrl(i); - panel.Controls.Add(link); - } - else - { - Label label = new Label(); - label.Text = i.ToString(); - panel.Controls.Add(label); - } - Label spacer = new Label(); - spacer.Text = " | "; - panel.Controls.Add(spacer); - - } - - if (currentPage == maxPage) - { - Label prev = new Label(); - prev.Text = " Next >"; - panel.Controls.Add(prev); - } - else - { - HyperLink prev = new HyperLink(); - prev.Text = " Next >"; - prev.NavigateUrl = GetPageUrl(currentPage + 1); - panel.Controls.Add(prev); - } - - return panel; - } - - private void ConstructDeviceContent(Device device) - { - AddNodes(device, 1); - } - - /// - /// Populates the panels with the information about the device. - /// - /// - /// - /// - /// - protected void ItemDataBound(Panel namePanel, Panel valuePanel, Device device, Property property) - { - Literal nameLiteral = new Literal(); - namePanel.Controls.Add(nameLiteral); - - // Add the name. - nameLiteral.Text = property.Name; - - // Add the values. - int count = 0; - foreach (string value in device.Properties[property.Name]) - { - if (count > 0) - { - Literal comma = new Literal(); - comma.Text = ", "; - valuePanel.Controls.Add(comma); - } - foreach (Value i in property.Values) - { - if (value == i.Name) - { - AddLabel(valuePanel, i.Name, i.Description, i.Url, null); - } - } - count++; - } - } - - private void AddNodes(Device device, int headingLevel) - { - using (XmlReader reader = XmlReader.Create(Headings)) - { - while (reader.EOF == false) - { - AddNodes(_device, reader, device); - } - } - } - - /// - /// Adds new controls and returns the number of actual values added. - /// - /// - /// - /// - /// - private int AddNodes(WebControl parent, XmlReader reader, Device device) - { - int added = 0; - if (reader.NodeType == XmlNodeType.Element) - { - string key = reader.GetAttribute("name"); - if (String.IsNullOrEmpty(key) == false) - { - if (device.Properties.ContainsKey(key) == false) - { - int depth = reader.Depth; - string caption; - switch (key) - { - case "Hardware": caption = String.Format("Hardware: {0}", device.HardwareCaption); break; - case "Software": caption = String.Format("Software: {0}", device.SoftwareCaption); break; - case "Browser": caption = String.Format("Browser: {0}", device.BrowserCaption); break; - case "Content": caption = "Content & Streaming"; break; - default: caption = key; break; - } - - Literal heading = CreateHeading(depth, caption); - parent.Controls.Add(heading); - - reader.Read(); - while (reader.Depth > depth) - added += AddNodes(parent, reader, device); - - if (added == 0) - parent.Controls.Remove(heading); - } - - if (device.Properties.ContainsKey(key) && device.Properties[key].Count > 0) - { - Property property = DataProvider.GetProperty(key); - if (property != null) - { - Panel itemPanel = new Panel(); - Panel namePanel = new Panel(); - Panel valuePanel = new Panel(); - - parent.Controls.Add(itemPanel); - itemPanel.Controls.Add(namePanel); - itemPanel.Controls.Add(valuePanel); - - valuePanel.CssClass = ValueCssClass; - namePanel.CssClass = String.Join(" ", new string[] { - PropertyCssClass, - (property.IsCms ? CmsCssClass : (property.IsPremium ? PremiumCssClass : LiteCssClass)) }); - - string wide = reader.GetAttribute("wide"); - itemPanel.CssClass = String.IsNullOrEmpty(wide) ? ItemCssClass : WideCssClass; - - ItemDataBound(namePanel, valuePanel, device, property); - - added++; - } - } - } - } - reader.Read(); - return added; - } - - /// - /// Returns a literal with the heading. - /// - /// - /// - private Literal CreateHeading(int depth, string caption) - { - Literal heading = new Literal(); - heading.Text = String.Format("{1}", depth, caption); - return heading; - } - - private void VendorRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) - { - if (e.Item.DataItem != null && - e.Item.DataItem is Value) - { - Value vendor = (Value)e.Item.DataItem; - HyperLink linkVendor = e.Item.FindControl("Vendor") as HyperLink; - Label labelCount = e.Item.FindControl("Count") as Label; - Panel panelContainer = e.Item.FindControl("Panel") as Panel; - - linkVendor.Text = vendor.Name; - linkVendor.NavigateUrl = GetNewUrl("Vendor", vendor.Name); - - labelCount.Text = DataProvider.Vendors[vendor].Count.ToString(); - - panelContainer.CssClass = ItemCssClass; - } - } - - private void RelatedDeviceDataList_ItemDataBound(object sender, DataListItemEventArgs e) - { - if (e.Item.DataItem != null && - e.Item.DataItem is Device) - { - Device device = e.Item.DataItem as Device; - Panel container = e.Item.FindControl("Device") as Panel; - HyperLink link = e.Item.FindControl("Link") as HyperLink; - - link.NavigateUrl = GetNewUrl("DeviceID", device.DeviceID); - link.Text = device.SoftwareBrowserCaption; - - container.CssClass = ItemCssClass; - } - } - - private void DeviceDataList_ItemDataBound(object sender, DataListItemEventArgs e) - { - if (e.Item.DataItem != null && - e.Item.DataItem is Device) - { - Device device = e.Item.DataItem as Device; - - Panel panelContainer = e.Item.FindControl("Device") as Panel; - Panel panelModel = e.Item.FindControl("Model") as Panel; - Panel panelImage = e.Item.FindControl("Image") as Panel; - Panel panelName = e.Item.FindControl("Name") as Panel; - - HyperLink linkModel = new HyperLink(); - HyperLink linkName = new HyperLink(); - - linkModel.Text = device.HardwareModel; - - // if a device has been searched for the vendor query won't be there and has to be added now. - // search will also be removed - NameValueCollection queryStrings = new NameValueCollection(Request.QueryString); - if (Vendor == null) - queryStrings.Add("Vendor", device.HardwareVendor); - if (SearchText != null) - queryStrings.Remove("Search"); - linkModel.NavigateUrl = GetNewUrl(queryStrings, "Model", device.HardwareModel); - - if (String.IsNullOrEmpty(device.HardwareModel) == false) - { - linkName.Text = device.HardwareName; - linkName.NavigateUrl = linkModel.NavigateUrl; - } - - if (_imagesEnabled) - { - WebControl image = DeviceImages.GetDeviceImageRotater(device, linkModel.NavigateUrl); - if (image != null) - panelImage.Controls.Add(image); - } - - panelName.Controls.Add(linkName); - panelModel.Controls.Add(linkModel); - - - panelModel.CssClass = ModelCssClass; - panelName.CssClass = NameCssClass; - panelImage.CssClass = ImagesCssClass; - panelContainer.CssClass = ItemCssClass; - } - } - - /// - /// Handles search box postback. - /// - /// - /// - void SearchBox_TextChanged(object sender, EventArgs e) - { - Response.Redirect(GetNewUrl("Search", _searchBox.Text)); - } - - #endregion - - #region Private Methods - - /// - /// Creates a panel with search functionality, including text instructions, a text box and button - /// - /// - private Panel CreateSearch() - { - _searchPanel = new Panel(); - - // create instructions - _instructions = new Panel(); - _instructionText = new Literal(); - _instructions.Controls.Add(_instructionText); - _searchPanel.Controls.Add(_instructions); - - // create search box - _searchBox = new TextBox(); - // needed to preserve text during post back - _searchBox.ID = "search_box"; - _searchBox.TextChanged += new EventHandler(SearchBox_TextChanged); - - Page.RegisterRequiresPostBack(_searchBox); - _searchPanel.Controls.Add(_searchBox); - - // create search button - _searchButton = new Button(); - _searchPanel.Controls.Add(_searchButton); - - return _searchPanel; - } - - - - /// - /// True if the given device's hardware matches the search terms. - /// - /// An array of sub string populated from the initial search string. Every string - /// must have a match for the device to be matched. - /// The device being queried. - /// Returns true if the device is a match. - private static bool MatchesSearch(string[] searchTerms, Device d) - { - foreach (string sub in searchTerms) - { - if ((MatchesSearchTerm(sub, d.HardwareVendor) || - MatchesSearchTerm(sub, d.HardwareModel) || - MatchesSearchTerm(sub, d.HardwareName)) == false) - return false; - } - return true; - } - - /// - /// Matches a search term against a device value. - /// - /// A substring from the search. - /// A value to match against. - /// True if a match is found. - private static bool MatchesSearchTerm(string searchTerm, string value) - { - if (String.IsNullOrEmpty(value)) - return false; - - return value.ToLowerInvariant().Contains(searchTerm); - } - - private Repeater CreateVendorRepeater() - { - Repeater repeater = new Repeater(); - repeater.ItemDataBound += new RepeaterItemEventHandler(VendorRepeater_ItemDataBound); - repeater.ItemTemplate = new VendorTemplate(); - return repeater; - } - - private DataList CreateDeviceDataList() - { - DataList dataList = new DataList(); - dataList.ItemDataBound += new DataListItemEventHandler(DeviceDataList_ItemDataBound); - - dataList.ItemTemplate = new DeviceTemplate(); - dataList.RepeatLayout = RepeatLayout.Flow; - dataList.RepeatDirection = RepeatDirection.Horizontal; - return dataList; - } - - private DataList CreateRelatedDeviceDataList() - { - DataList dataList = new DataList(); - dataList.ItemDataBound += new DataListItemEventHandler(RelatedDeviceDataList_ItemDataBound); - dataList.ItemTemplate = new RelatedDeviceTemplate(); - dataList.RepeatLayout = RepeatLayout.Flow; - dataList.RepeatDirection = RepeatDirection.Horizontal; - return dataList; - } - - #endregion - } -} diff --git a/Foundation/UI/Web/DeviceFinder.cs b/Foundation/UI/Web/DeviceFinder.cs deleted file mode 100644 index bcdeaae..0000000 --- a/Foundation/UI/Web/DeviceFinder.cs +++ /dev/null @@ -1,292 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.Web.UI.WebControls; -using FiftyOne.Foundation.Mobile.Detection; - -#if VER4 - -using System.Linq; - -#endif - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// User control used to select a specific device. - /// - public class DeviceFinder : BaseUserControl - { - #region Fields - - private string _deviceId; - - #endregion - - #region Controls Declaration - - private Panel _pnlTitle; - private Panel _pnlResult; - private Table _tblCriteria; - private DropDownList _ddlVendors; - private DropDownList _ddlModels; - private TextBox _txtFreeText; - private Button _btnFind; - private GridView _gvResults; - private Label _lblDevice; - - #endregion - - #region Private Methods - - private void CreateResultsList() - { - _gvResults = new GridView(); - _gvResults.AutoGenerateColumns = false; - - BoundField captionColumn = new BoundField(); - captionColumn.HeaderText = "Device"; - captionColumn.DataField = "Caption"; - _gvResults.Columns.Add(captionColumn); - - _gvResults.AutoGenerateSelectButton = true; - _gvResults.AutoGenerateDeleteButton = false; - _gvResults.AutoGenerateEditButton = false; - _gvResults.AllowPaging = true; - _gvResults.ShowHeader = true; - _gvResults.ShowFooter = false; - _gvResults.PageSize = 25; - - _gvResults.PageIndexChanging += new GridViewPageEventHandler(_gvResults_PageIndexChanging); - _gvResults.RowCommand += new GridViewCommandEventHandler(_gvResults_RowCommand); - } - - void _gvResults_PageIndexChanging(object sender, GridViewPageEventArgs e) - { - - } - - void _gvResults_RowCommand(object sender, GridViewCommandEventArgs e) - { - if (e.CommandName == "Select") - { - int index = 0; - if (int.TryParse(e.CommandArgument as string, out index)) - _deviceId = ((List)_gvResults.DataSource)[index].DeviceID; - } - } - - private Table CreateCriteriaTable() - { - Table table = new Table(); - - TableRow row = new TableRow(); - CreateCell(_lblDevice, row, 2); - table.Rows.Add(row); - - row = new TableRow(); - CreateLabelCell(Resources.FinderVendorLabelText, Resources.FinderVendorLabelToolTip, row, 1); - CreateLabelCell(Resources.FinderModelLabelText, Resources.FinderVendorLabelToolTip, row, 1); - table.Rows.Add(row); - - row = new TableRow(); - CreateCell(_ddlVendors, row, 1); - CreateCell(_ddlModels, row, 1); - table.Rows.Add(row); - - row = new TableRow(); - CreateLabelCell("Or", string.Empty, row, 2); - table.Rows.Add(row); - - row = new TableRow(); - CreateLabelCell(Resources.FinderFreeTextLabelText, Resources.FinderFreeTextLabelToolTip, row, 2); - table.Rows.Add(row); - - row = new TableRow(); - CreateLabelCell(Resources.FinderFreeTextLabelText, Resources.FinderFreeTextLabelToolTip, row, 2); - - row = new TableRow(); - CreateCell(_txtFreeText, row, 1); - CreateCell(_btnFind, row, 1); - table.Rows.Add(row); - - row = new TableRow(); - CreateCell(_gvResults, row, 1); - table.Rows.Add(row); - - return table; - } - - private void CreateCell(WebControl withControl, TableRow addToRow, int colSpan) - { - TableCell cell = new TableCell(); - cell.ColumnSpan = colSpan; - cell.Controls.Add(withControl); - addToRow.Cells.Add(cell); - } - - private void CreateLabelCell(string text, string toolTip, TableRow addToRow, int colSpan) - { - TableCell cell = new TableCell(); - cell.ColumnSpan = colSpan; - AddLabel(cell, text, toolTip, null, ""); - addToRow.Cells.Add(cell); - } - - private void CreateVendorsList() - { - _ddlVendors = new DropDownList(); - _ddlVendors.AutoPostBack = true; - _ddlVendors.ID = "DropDownListVendors"; - _ddlVendors.DataSource = DataProvider.Vendors.Keys; - _ddlVendors.DataTextField = "Name"; - _ddlVendors.DataValueField = "Name"; - _ddlVendors.DataBind(); - } - - /// - /// Creates the models data list with all the possible models as the datasource. - /// - private void CreateModelsList() - { - _ddlModels = new DropDownList(); - _ddlModels.ID = "DropDownListModels"; - _ddlModels.DataSource = DataProvider.Devices; - _ddlModels.DataTextField = "HardwareModel"; - _ddlModels.DataValueField = "DeviceID"; - _ddlModels.DataBind(); - _ddlModels.AutoPostBack = true; - } - - /// - /// Binds to a new list and retains the selected value. - /// - private void SetVendor() - { - Value selectedVendor = GetSelectedVendor(); - if (selectedVendor != null) - { - _ddlModels.DataSource = DataProvider.Vendors[selectedVendor]; - _ddlModels.DataBind(); - _ddlModels.SelectedValue = _deviceId; - } - } - - #endregion - - #region Events - - /// - /// Creates the new controls used by the device finder. - /// - /// - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - _pnlTitle = new Panel(); - _pnlResult = new Panel(); - _lblDevice = new Label(); - CreateVendorsList(); - CreateModelsList(); - CreateResultsList(); - _txtFreeText = new TextBox(); - _txtFreeText.ID = "TextBoxFreeText"; - _btnFind = new Button(); - _btnFind.ID = "ButtonFind"; - _btnFind.Text = "Find"; - _btnFind.Click += Find_Click; - _tblCriteria = CreateCriteriaTable(); - - _container.Controls.Add(_pnlTitle); - _container.Controls.Add(_tblCriteria); - _container.Controls.Add(_pnlResult); - - Page.RegisterRequiresControlState(this); - } - - /// - /// Saves the currently selected device id. - /// - /// - protected override object SaveControlState() - { - return _deviceId; - } - - /// - /// Loads the currently selected device id. - /// - /// - protected override void LoadControlState(object savedState) - { - _deviceId = (string)savedState; - } - - /// - /// Sets the correct models list for the vendor. - /// - /// - protected override void OnLoad(EventArgs e) - { - SetVendor(); - - _gvResults.Visible = !String.IsNullOrEmpty(_txtFreeText.Text); - - if (_gvResults.Visible) - { - _gvResults.DataSource = DataProvider.FindDevices(_txtFreeText.Text); - _gvResults.DataBind(); - } - - base.OnLoad(e); - } - - /// - /// Renders the current device caption. - /// - /// - protected override void OnPreRender(EventArgs e) - { - if (String.IsNullOrEmpty(_deviceId) == false) - { - Device device = DataProvider.GetDeviceFromDeviceID(_deviceId); - _lblDevice.Text = device.Caption; - } - else - { - _lblDevice.Parent.Parent.Visible = false; - } - base.OnPreRender(e); - } - - private void Find_Click(object sender, EventArgs e) - { - // TODO - } - - /// - /// Returns the currently selected vendor if any. - /// - /// - private Value GetSelectedVendor() - { - foreach (Value vendor in DataProvider.Vendors.Keys) - if (vendor.Name == _ddlVendors.SelectedValue) - return vendor; - return null; - } - - #endregion - } -} diff --git a/Foundation/UI/Web/DeviceTemplate.cs b/Foundation/UI/Web/DeviceTemplate.cs deleted file mode 100644 index 02a4951..0000000 --- a/Foundation/UI/Web/DeviceTemplate.cs +++ /dev/null @@ -1,45 +0,0 @@ -/* ********************************************************************* - * 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 System.Web.UI; -using System.Web.UI.WebControls; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Template used to display device properties. - /// - public class DeviceTemplate : ITemplate - { - /// - /// Adds requirement controls to the container. - /// - /// Container the template is being displayed in. - public void InstantiateIn(Control container) - { - Panel device = new Panel(); - Panel model = new Panel(); - Panel image = new Panel(); - Panel name = new Panel(); - - device.ID = "Device"; - model.ID = "Model"; - image.ID = "Image"; - name.ID = "Name"; - - device.Controls.Add(model); - device.Controls.Add(image); - device.Controls.Add(name); - - container.Controls.Add(device); - } - } -} diff --git a/Foundation/UI/Web/HeaderTemplate.cs b/Foundation/UI/Web/HeaderTemplate.cs deleted file mode 100644 index 55afe25..0000000 --- a/Foundation/UI/Web/HeaderTemplate.cs +++ /dev/null @@ -1,57 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Web.UI; -using System.Web.UI.WebControls; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Template used to display a heading. - /// - public class HeaderTemplate : ITemplate - { - private int _level; - private string _text; - - /// - /// Constructs the template setting parameters that control the heading created. - /// - /// - /// - internal HeaderTemplate(string text, int level) - { - _text = text; - _level = level; - } - - /// - /// Adds requirement controls to the container. - /// - /// Container the template is being displayed in. - public void InstantiateIn(Control container) - { - Literal open = new Literal(); - Literal close = new Literal(); - Label label = new Label(); - - open.Text = String.Format("", _level); - label.ID = "Heading"; - label.Text = _text; - close.Text = String.Format("", _level); - - container.Controls.Add(open); - container.Controls.Add(label); - container.Controls.Add(close); - } - } -} diff --git a/Foundation/UI/Web/LiteMessage.cs b/Foundation/UI/Web/LiteMessage.cs deleted file mode 100644 index 5adc9c7..0000000 --- a/Foundation/UI/Web/LiteMessage.cs +++ /dev/null @@ -1,84 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Web.UI.WebControls; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// This class displays simple HTML explaining why any upgraded is needed. The text the control displays - /// can be altered in the resources file. Retailers and affiliates should provide this own values for the - /// RetailerUrl and RetailerName to direct users to their eCommerce web sites. Affiliates should ensure - /// their affiliate ID is included in the URL if using the 51Degrees.mobi eCommerce web site. - /// - public class LiteMessage : BaseUserControl - { - #region Fields - - private Uri _retailerUrl = new Uri(RetailerConstants.RetailerUrl); - private string _retailerName = RetailerConstants.RetailerName; - private Literal _html; - - #endregion - - #region Properties - - /// - /// The url of the retailers web site. - /// - public Uri RetailerUrl - { - get { return _retailerUrl; } - set { _retailerUrl = value; } - } - - /// - /// The name of the retailer. - /// - public string RetailerName - { - get { return _retailerName; } - set { _retailerName = value; } - } - - #endregion - - #region Events - - /// - /// Creates the new literal control and adds it to the user control. - /// - /// - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - _html = new Literal(); - _container.Controls.Add(_html); - } - - /// - /// Adds html to the control displaying the upgrade message. - /// - /// - protected override void OnPreRender(EventArgs e) - { - _html.Text = String.Format(Resources.UpgradeHtml, - Resources.FiftyOneDegreesUrl, - _retailerUrl, - _retailerName); - _html.Visible = DataProvider.IsPremium == false && DataProvider.IsCms == false; - base.OnPreRender(e); - } - - #endregion - } -} diff --git a/Foundation/UI/Web/PropertyDictionary.cs b/Foundation/UI/Web/PropertyDictionary.cs deleted file mode 100644 index bb85e10..0000000 --- a/Foundation/UI/Web/PropertyDictionary.cs +++ /dev/null @@ -1,161 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Web.UI.WebControls; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Displays a list of the available properties and values. - /// - public class PropertyDictionary : BaseUserControl - { - #region Fields - - private Literal _legend = new Literal(); - private Literal _instructions = new Literal(); - private DataList _hardware = null; - private DataList _software = null; - private DataList _browser = null; - private DataList _content = null; - - #endregion - - #region Properties - - /// - /// Determines the visible status of the legend text. - /// - public bool DisplayLegend - { - get { return _legend.Visible; } - set { _legend.Visible = value; } - } - - #endregion - - #region Events - - /// - /// Renders the property to the data list control. - /// - /// - /// - private void DataList_ItemDataBound(object sender, DataListItemEventArgs e) - { - if (e.Item.DataItem != null && - e.Item.DataItem is Property) - { - Property property = (Property)e.Item.DataItem; - - Panel propertyPanel = e.Item.FindControl("Property") as Panel; - Panel descriptionPanel = e.Item.FindControl("Description") as Panel; - - AddLabel(propertyPanel, property.Name, null, property.Url, property.Name); - if (property.IsList) - AddLabel(propertyPanel, " [L]", null, null, null); - AddLabel(descriptionPanel, property.Description, null, null, null); - - if (property.ShowValues) - { - Panel valuesPanel = AddPlus(descriptionPanel, "block"); - valuesPanel.CssClass = ValueCssClass; - - int count = 0; - foreach (Value value in property.Values) - { - if (count > 0) - { - Literal comma = new Literal(); - comma.Text = ", "; - valuesPanel.Controls.Add(comma); - } - AddLabel(valuesPanel, value.Name, value.Description, value.Url, null); - count++; - } - } - - propertyPanel.CssClass = String.Format("{0} {1}", - PropertyCssClass, - property.IsCms ? CmsCssClass : - property.IsPremium ? PremiumCssClass : - LiteCssClass); - descriptionPanel.CssClass = DescriptionCssClass; - } - } - - /// - /// Creates the new literal control and adds it to the user control. - /// - /// - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - _hardware = CreateDataList("Hardware"); - _software = CreateDataList("Software"); - _browser = CreateDataList("Browser"); - _content = CreateDataList("Content"); - - _container.Controls.Add(_legend); - _container.Controls.Add(_instructions); - _container.Controls.Add(_hardware); - _container.Controls.Add(_software); - _container.Controls.Add(_browser); - _container.Controls.Add(_content); - } - - /// - /// Adds html to the control displaying the upgrade message. - /// - /// - protected override void OnPreRender(EventArgs e) - { - _instructions.Text = Resources.PropertyDictionaryInstructions; - _legend.Text = ReplaceTags(Resources.PropertyDictionaryLegend); - - _hardware.DataSource = DataProvider.HardwareProperties; - _software.DataSource = DataProvider.SoftwareProperties; - _browser.DataSource = DataProvider.BrowserProperties; - _content.DataSource = DataProvider.ContentProperties; - - _hardware.DataBind(); - _software.DataBind(); - _browser.DataBind(); - _content.DataBind(); - - _hardware.CssClass = ItemCssClass; - _software.CssClass = ItemCssClass; - _browser.CssClass = ItemCssClass; - _content.CssClass = ItemCssClass; - - base.OnPreRender(e); - } - - #endregion - - #region Private Methods - - private DataList CreateDataList(string heading) - { - DataList dataList = new DataList(); - dataList.ShowHeader = true; - dataList.ItemDataBound += new DataListItemEventHandler(DataList_ItemDataBound); - dataList.HeaderTemplate = new HeaderTemplate(heading, 1); - dataList.ItemTemplate = new PropertyTemplate(); - return dataList; - } - - #endregion - } -} diff --git a/Foundation/UI/Web/PropertyTemplate.cs b/Foundation/UI/Web/PropertyTemplate.cs deleted file mode 100644 index 031112b..0000000 --- a/Foundation/UI/Web/PropertyTemplate.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* ********************************************************************* - * 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 System.Web.UI; -using System.Web.UI.WebControls; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Template used to display a property from the dictionary. - /// - public class PropertyTemplate : ITemplate - { - /// - /// Adds requirement controls to the container. - /// - /// Container the template is being displayed in. - public void InstantiateIn(Control container) - { - Panel property = new Panel(); - Panel description = new Panel(); - - property.ID = "Property"; - description.ID = "Description"; - - container.Controls.Add(property); - container.Controls.Add(description); - } - } -} diff --git a/Foundation/UI/Web/Redirect.cs b/Foundation/UI/Web/Redirect.cs deleted file mode 100644 index 2bd90a6..0000000 --- a/Foundation/UI/Web/Redirect.cs +++ /dev/null @@ -1,1463 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Collections.Generic; -using System.IO; -using System.Text.RegularExpressions; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; -using FiftyOne.Foundation.Mobile.Detection; -using FiftyOne.Foundation.Mobile.Configuration; - -#if VER4 || VER35 - -using System.Linq; - -#endif - -namespace FiftyOne.Foundation.UI.Web -{ - - /// - /// Manages the redirection element of the configuration. - /// - public class Redirect : BaseUserControl - { - #region Constants - - internal const string REGEX_NUMERIC = @"^\d{1,}$"; - internal const string REGEX_FILE = @"^$|^(~|\\|\w).+"; - internal const string REGEX_URL = @"^(\w+://|~)[/\w\d\.{}]+$"; - internal const string VALIDATION_GROUP = "Redirect"; - internal const string EXPRESSION_VALUE = "[Expression]"; - - #endregion - - #region Static Methods - - /// - /// Used to determine if the regex is a valid one. - /// - /// Regex to be tested. - /// True if the expression is valid, otherwise false. - internal static bool CheckIsRegExValid(string regex) - { - try - { - new Regex(regex, RegexOptions.Compiled); - return true; - } - catch - { - return false; - } - } - - /// - /// Sets the error CssClass if an error is present. - /// - /// - /// - /// - internal static void SetError(BaseValidator validator, WebControl control, string className) - { - if (validator.IsValid == false) - { - AddCssClass(control, className); - } - } - - /// - /// Adds a new CssClass to any existing ones already present. - /// - /// - /// - private static void AddCssClass(WebControl control, string className) - { - List list = new List(control.CssClass.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)); - list.Add(className); - control.CssClass = String.Join(" ", list.ToArray()); - } - - #endregion - - #region Child Classes - - /// - /// Control used to represent a filter assigned to a location. All filters need to - /// match for the location to be used. - /// - internal class FilterControl : TableRow - { - #region Fields - - private DropDownList _ddlProperties = null; - private DropDownList _ddlValues = null; - private TextBox _textBoxExpression = null; - private CheckBox _checkBoxEnabled = null; - private Button _buttonDelete = null; - private CustomValidator _customValidatorMatchExpression = null; - - private FilterData _data; - private Redirect _parent; - - #endregion - - #region Properties - - private int TableIndex - { - get { return ((Table)((TableRow)((TableCell)((Table)Parent).Parent).Parent).Parent).Controls.IndexOf(Parent.Parent.Parent); } - } - - private int RowIndex - { - get { return ((Table)Parent).Controls.IndexOf(this); } - } - - #endregion - - #region Constrcutor - - internal FilterControl(FilterData data, Redirect parent) - { - _data = data; - _parent = parent; - - _ddlProperties = new DropDownList(); - _ddlValues = new DropDownList(); - _textBoxExpression = new TextBox(); - _checkBoxEnabled = new CheckBox(); - _buttonDelete = new Button(); - _customValidatorMatchExpression = new CustomValidator(); - - List list = new List(); - foreach (Property property in DataProvider.Provider.Properties.Values) - list.Add(property.Name); - list.Sort(); - _ddlProperties.DataSource = list; - - _ddlProperties.AutoPostBack = true; - _ddlValues.AutoPostBack = true; - - _customValidatorMatchExpression.Display = ValidatorDisplay.None; - _customValidatorMatchExpression.ValidateEmptyText = true; - _customValidatorMatchExpression.ValidationGroup = VALIDATION_GROUP; - - // Bind the list of properties to the control. - _ddlProperties.DataBind(); - _ddlProperties.Items.Add(new ListItem( - FiftyOne.Foundation.Mobile.Redirection.Constants.OriginalUrlSpecialProperty, - FiftyOne.Foundation.Mobile.Redirection.Constants.OriginalUrlSpecialProperty)); - _ddlProperties.SelectedValue = - FiftyOne.Foundation.Mobile.Redirection.Constants.OriginalUrlSpecialProperty; - - SetValuesDataSource(); - - _textBoxExpression.Text = _data.MatchExpression; - _checkBoxEnabled.Checked = _data.Enabled; - } - - #endregion - - #region Methods - - private TableCell NewCell(Control control) - { - TableCell cell = new TableCell(); - cell.Controls.Add(control); - return cell; - } - - private void SetValuesDataSource() - { - // Get the currently selected property. -#if VER4 || VER35 - var property = DataProvider.Provider.Properties.Values.FirstOrDefault(i => - i.Name == _data.Property); -#else - FiftyOne.Foundation.Mobile.Detection.Property property = null; - foreach (Property item in DataProvider.Provider.Properties.Values) - { - if (item.Name == _data.Property) - { - property = item; - break; - } - } -#endif - - if (property != null && - property.Values != null && - property.Values.Count > 0) - { - // Select the correct value for the property. - _ddlProperties.SelectedValue = property.Name; - - // Bind the values list to the ones that are available - // for the property selected. - _ddlValues.Items.Clear(); - List list = new List(); - foreach (Value value in property.Values) - list.Add(value.Name); - list.Sort(); - foreach (string item in list) - _ddlValues.Items.Add(new ListItem(item, item)); - _ddlValues.Items.Add(new ListItem(EXPRESSION_VALUE, String.Empty)); - - // Selected the current item if available, otherwise select - // the 1st item in the list. - if (String.IsNullOrEmpty(_data.MatchExpression) == false) - { -#if VER4 || VER35 - var selectedValue = property.Values.FirstOrDefault(i => - i.Name == _data.MatchExpression); -#else - FiftyOne.Foundation.Mobile.Detection.Value selectedValue = null; - foreach (Value item in property.Values) - { - if (item.Name == _data.MatchExpression) - { - selectedValue = item; - break; - } - } -#endif - if (selectedValue != null) - _ddlValues.SelectedValue = selectedValue.Name; - } - - _data.MatchExpression = _ddlValues.SelectedValue ?? _ddlValues.Items[0].Value; - _textBoxExpression.Text = _data.MatchExpression; - - _ddlValues.Enabled = true; - } - else - { - _ddlValues.Enabled = false; - } - _textBoxExpression.Enabled = - _ddlValues.Enabled == false || - _ddlValues.SelectedValue == String.Empty; - } - - #endregion - - #region Events - - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - Cells.Add(NewCell(_ddlProperties)); - Cells.Add(NewCell(_ddlValues)); - Cells.Add(NewCell(_textBoxExpression)); - Cells.Add(NewCell(_checkBoxEnabled)); - - TableCell cellLast = new TableCell(); - cellLast.Controls.Add(_buttonDelete); - cellLast.Controls.Add(_customValidatorMatchExpression); - Cells.Add(cellLast); - - _textBoxExpression.ID = _customValidatorMatchExpression.ControlToValidate = String.Format("X{0}-{1}", TableIndex, RowIndex); - _ddlProperties.ID = String.Format("P{0}-{1}", TableIndex, RowIndex); - _ddlValues.ID = String.Format("V{0}-{1}", TableIndex, RowIndex); - _buttonDelete.ID = String.Format("D{0}-{1}", TableIndex, RowIndex); - _checkBoxEnabled.ID = String.Format("E{0}-{1}", TableIndex, RowIndex); - - _ddlProperties.SelectedIndexChanged += new EventHandler(_ddlProperties_SelectedIndexChanged); - _ddlValues.SelectedIndexChanged += new EventHandler(_ddlValues_SelectedIndexChanged); - _textBoxExpression.TextChanged += new EventHandler(_textBoxExpression_TextChanged); - _checkBoxEnabled.CheckedChanged += new EventHandler(_checkBoxEnabled_CheckedChanged); - _buttonDelete.Click += new EventHandler(_buttonDelete_Click); - _customValidatorMatchExpression.ServerValidate += new ServerValidateEventHandler(_customValidatorMatchExpression_ServerValidate); - } - - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - - _checkBoxEnabled.CssClass = _parent.CheckBoxCssClass; - _textBoxExpression.CssClass = _parent.TextBoxCssClass; - _ddlValues.CssClass = _parent.DropDownListCssClass; - _ddlProperties.CssClass = _parent.DropDownListCssClass; - _buttonDelete.CssClass = _parent.ButtonCssClass; - - _buttonDelete.Text = _parent.RedirectButtonRemoveText; - - _customValidatorMatchExpression.ErrorMessage = _parent.RedirectErrorMessageMatchExpressionText; - - SetError(_customValidatorMatchExpression, _textBoxExpression,_parent.ErrorCssClass); - } - - private void _checkBoxEnabled_CheckedChanged(object sender, EventArgs e) - { - _data.Enabled = ((CheckBox)sender).Checked; - } - - private void _customValidatorMatchExpression_ServerValidate(object source, ServerValidateEventArgs args) - { - args.IsValid = CheckIsRegExValid(args.Value); - } - - private void _buttonDelete_Click(object sender, EventArgs e) - { - _data.Parent.Remove(_data); - this.Visible = false; - } - - private void _textBoxExpression_TextChanged(object sender, EventArgs e) - { - _data.MatchExpression = ((TextBox)sender).Text; - _ddlValues.SelectedValue = - _ddlValues.Items.FindByValue(_data.MatchExpression) != null ? - _data.MatchExpression : String.Empty; - } - - private void _ddlValues_SelectedIndexChanged(object sender, EventArgs e) - { - if (String.IsNullOrEmpty(((DropDownList)sender).SelectedValue) == false) - { - _data.MatchExpression = ((DropDownList)sender).SelectedValue; - _textBoxExpression.Text = _data.MatchExpression; - _textBoxExpression.Enabled = false; - } - else - _textBoxExpression.Enabled = true; - } - - private void _ddlProperties_SelectedIndexChanged(object sender, EventArgs e) - { - _data.Property = ((DropDownList)sender).SelectedValue; - SetValuesDataSource(); - } - - #endregion - } - - /// - /// Class represents a location under the redirect control. - /// - internal class LocationControl : TableRow - { - #region Fields - - private Table _tableFilters = null; - private Panel _panelProperty = null; - private Panel _panelValue = null; - private Panel _panelMatchExpression = null; - private Panel _panelEnabled = null; - private TextBox _textBoxUrl = null; - private TextBox _textBoxMatchExpression = null; - private TextBox _textBoxName = null; - private Button _buttonAdd = null; - private Button _buttonRemove = null; - private Button _buttonToggle = null; - private RegularExpressionValidator _regularExpressionValidatorUrl; - private RequiredFieldValidator _requiredFieldValidatorName; - private CustomValidator _customValidatorMatchExpression; - - private LocationData _data = null; - private Redirect _parent; - - #endregion - - #region Properties - - internal TextBox TextBoxName - { - get { return _textBoxName; } - } - - internal Table TableFilters - { - get { return _tableFilters; } - } - - private int RowIndex - { - get { return ((Table)Parent).Controls.IndexOf(this); } - } - - #endregion - - #region Constructors - - internal LocationControl(LocationData data, Redirect parent) - { - _data = data; - _parent = parent; - - _tableFilters = new Table(); - _panelEnabled = new Panel(); - _panelMatchExpression = new Panel(); - _panelProperty = new Panel(); - _panelValue = new Panel(); - _textBoxName = new TextBox(); - _textBoxUrl = new TextBox(); - _textBoxMatchExpression = new TextBox(); - _buttonAdd = new Button(); - _buttonRemove = new Button(); - _buttonToggle = new Button(); - _customValidatorMatchExpression = new CustomValidator(); - _requiredFieldValidatorName = new RequiredFieldValidator(); - _regularExpressionValidatorUrl = new RegularExpressionValidator(); - - _textBoxName.Text = _data.Name; - _textBoxUrl.Text = _data.Url; - _textBoxMatchExpression.Text = _data.MatchExpression; - - _requiredFieldValidatorName.EnableClientScript = - _regularExpressionValidatorUrl.EnableClientScript = false; - - _requiredFieldValidatorName.ValidationGroup = - _customValidatorMatchExpression.ValidationGroup = - _regularExpressionValidatorUrl.ValidationGroup = VALIDATION_GROUP; - - _requiredFieldValidatorName.Display = - _customValidatorMatchExpression.Display = - _regularExpressionValidatorUrl.Display = ValidatorDisplay.None; - - _regularExpressionValidatorUrl.ValidationExpression = REGEX_URL; - - TableHeaderRow rowHeader = new TableHeaderRow(); - rowHeader.Cells.Add(NewCell(_panelProperty)); - rowHeader.Cells.Add(NewCell(_panelValue)); - rowHeader.Cells.Add(NewCell(_panelMatchExpression)); - rowHeader.Cells.Add(NewCell(_panelEnabled)); - _tableFilters.Rows.Add(rowHeader); - - foreach (FilterData filter in _data) - _tableFilters.Rows.Add(new FilterControl(filter, _parent)); - } - - #endregion - - #region Methods - - private TableCell NewCell(Control control) - { - TableCell cell = new TableCell(); - cell.Controls.Add(control); - return cell; - } - - #endregion - - #region Events - - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - Cells.Add(NewCell(_textBoxName)); - Cells.Add(NewCell(_textBoxUrl)); - Cells.Add(NewCell(_textBoxMatchExpression)); - Cells.Add(NewCell(_buttonAdd)); - Cells.Add(NewCell(_buttonToggle)); - - TableCell cellLast = new TableCell(); - cellLast.Controls.Add(_buttonRemove); - cellLast.Controls.Add(_customValidatorMatchExpression); - cellLast.Controls.Add(_regularExpressionValidatorUrl); - cellLast.Controls.Add(_requiredFieldValidatorName); - Cells.Add(cellLast); - - _textBoxName.ID = _requiredFieldValidatorName.ControlToValidate = String.Format("N{0}", RowIndex); - _textBoxUrl.ID = _regularExpressionValidatorUrl.ControlToValidate = String.Format("U{0}", RowIndex); - _textBoxMatchExpression.ID = _customValidatorMatchExpression.ControlToValidate = String.Format("M{0}", RowIndex); - _buttonAdd.ID = String.Format("A{0}", RowIndex); - _buttonRemove.ID = String.Format("R{0}", RowIndex); - - _textBoxName.TextChanged += new EventHandler(_textBoxName_TextChanged); - _textBoxUrl.TextChanged += new EventHandler(_textBoxUrl_TextChanged); - _textBoxMatchExpression.TextChanged += new EventHandler(_textBoxMatchExpression_TextChanged); - _buttonAdd.Click += new EventHandler(_buttonAdd_Click); - _buttonRemove.Click += new EventHandler(_buttonRemove_Click); - _buttonToggle.Click += new EventHandler(_buttonToggle_Click); - _customValidatorMatchExpression.ServerValidate += new ServerValidateEventHandler(_customValidatorMatchExpression_ServerValidate); - } - - void _buttonToggle_Click(object sender, EventArgs e) - { - _data.ShowFilters = !_data.ShowFilters; - } - - void _buttonRemove_Click(object sender, EventArgs e) - { - _data.Parent.Remove(_data); - if (_tableFilters.Parent.Parent != null) - Parent.Controls.Remove(_tableFilters.Parent.Parent); - Parent.Controls.Remove(this); - } - - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - - _buttonToggle.Visible = false; - if (_tableFilters.Parent != null && - _tableFilters.Parent.Parent != null) - { - _tableFilters.Parent.Parent.Visible = _data.ShowFilters; - } - - _buttonToggle.Visible = _tableFilters.Visible = _data.Count > 0; - - _parent.AddLabel(_panelProperty, - _parent.RedirectLabelPropertyText, - _parent.RedirectLocationFilterPropertyToolTip, - null, null); - _parent.AddLabel(_panelValue, - _parent.RedirectLabelValueText, - _parent.RedirectLocationFilterMatchExpressionToolTip, - null, null); - _parent.AddLabel(_panelMatchExpression, - _parent.RedirectLabelMatchExpressionText, - _parent.RedirectLocationFilterMatchExpressionToolTip, - null, null); - _parent.AddLabel(_panelEnabled, - _parent.RedirectLabelEnabledText, - null, - null, null); - - AddCssClass(_panelProperty, _parent.LabelCssClass); - AddCssClass(_panelValue, _parent.LabelCssClass); - AddCssClass(_panelMatchExpression, _parent.LabelCssClass); - AddCssClass(_panelEnabled, _parent.LabelCssClass); - AddCssClass(_buttonAdd, _parent.ButtonCssClass); - AddCssClass(_textBoxUrl, _parent.TextBoxCssClass); - AddCssClass(_textBoxMatchExpression, _parent.TextBoxCssClass); - AddCssClass(_textBoxName, _parent.TextBoxCssClass); - - _buttonAdd.Text = _parent.RedirectButtonNewText; - _buttonRemove.Text = _parent.RedirectButtonRemoveText; - _buttonToggle.Text = _data.ShowFilters ? _parent.RedirectButtonHideText : _parent.RedirectButtonShowText; - - _customValidatorMatchExpression.ErrorMessage = _parent.RedirectErrorMessageMatchExpressionText; - _requiredFieldValidatorName.ErrorMessage = _parent.RedirectErrorMessageNameFieldText; - _regularExpressionValidatorUrl.ErrorMessage = _parent.RedirectErrorMessageUrlFormatText; - - SetError(_customValidatorMatchExpression, _textBoxMatchExpression, _parent.ErrorCssClass); - SetError(_requiredFieldValidatorName, _textBoxName, _parent.ErrorCssClass); - SetError(_regularExpressionValidatorUrl, _textBoxUrl, _parent.ErrorCssClass); - } - - private void _customValidatorMatchExpression_ServerValidate(object source, ServerValidateEventArgs args) - { - args.IsValid = CheckIsRegExValid(args.Value); - } - - private void _buttonAdd_Click(object sender, EventArgs e) - { - FilterData newFilter = new FilterData(_data); - _data.Add(newFilter); - _tableFilters.Rows.Add(new FilterControl(newFilter, _parent)); - _data.ShowFilters = true; - } - - private void _textBoxMatchExpression_TextChanged(object sender, EventArgs e) - { - _data.MatchExpression = ((TextBox)sender).Text; - } - - private void _textBoxUrl_TextChanged(object sender, EventArgs e) - { - _data.Url = ((TextBox)sender).Text; - } - - private void _textBoxName_TextChanged(object sender, EventArgs e) - { - _data.Name = ((TextBox)sender).Text; - } - - #endregion - } - - /// - /// Represents a collection of locations in the control. - /// - internal class LocationsControl : Table - { - #region Fields - - private Panel _panelName; - private Panel _panelUrl; - private Panel _panelMatchExpression; - private Panel _panelFilters; - private CustomValidator _customValidatorUniqueName; - private RedirectData _data; - private Redirect _parent; - private List _listDuplicateNames = new List(); - - #endregion - - #region Constructor - - internal LocationsControl (RedirectData data, Redirect parent) - { - _data = data; - _parent = parent; - _panelName = new Panel(); - _panelUrl = new Panel(); - _panelMatchExpression = new Panel(); - _panelFilters = new Panel(); - _customValidatorUniqueName = new CustomValidator(); - } - - #endregion - - #region Methods - - private TableCell NewCell(Control control) - { - TableCell cell = new TableCell(); - cell.Controls.Add(control); - return cell; - } - - #endregion - - #region Events - - /// - /// Initialise the controls. - /// - /// - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - TableHeaderRow rowHeader = new TableHeaderRow(); - rowHeader.Cells.Add(NewCell(_panelName)); - rowHeader.Cells.Add(NewCell(_panelUrl)); - rowHeader.Cells.Add(NewCell(_panelMatchExpression)); - TableCell cellFiltersLabel = new TableCell(); - cellFiltersLabel.ColumnSpan = 2; - cellFiltersLabel.Controls.Add(_panelFilters); - cellFiltersLabel.Controls.Add(_customValidatorUniqueName); - rowHeader.Cells.Add(cellFiltersLabel); - Rows.Add(rowHeader); - - _customValidatorUniqueName.ControlToValidate = ID; - _customValidatorUniqueName.Display = ValidatorDisplay.None; - _customValidatorUniqueName.ValidationGroup = VALIDATION_GROUP; - - foreach (LocationData item in _data) - { - // Add the location row. - LocationControl locationRow = new LocationControl(item, _parent); - - // Add the filters associated with the location to the next row. - Rows.Add(locationRow); - TableRow rowFilters = new TableRow(); - TableCell cellFilters = new TableCell(); - rowFilters.Cells.Add(cellFilters); - cellFilters.ColumnSpan = 6; - Rows.Add(rowFilters); - cellFilters.Controls.Add(locationRow.TableFilters); - } - - _customValidatorUniqueName.ServerValidate += new ServerValidateEventHandler(_customValidatorUniqueName_ServerValidate); - } - - /// - /// Check for duplicate unique names for the location elements. If duplicates are found raise - /// an error and ensure the list of offending controls is updated to mark in the returned UI. - /// - /// - /// - private void _customValidatorUniqueName_ServerValidate(object source, ServerValidateEventArgs args) - { - SortedList counts = new SortedList(); - foreach (TableRow row in Rows) - { - if (row is LocationControl) - { - LocationControl locationRow = (LocationControl)row; - if (counts.ContainsKey(locationRow.TextBoxName.Text) == false) - counts.Add(locationRow.TextBoxName.Text, 1); - else - counts[locationRow.TextBoxName.Text]++; - } - } - - List list = new List(); - foreach (string key in counts.Keys) - if (counts[key] > 1) - list.Add(key); - - foreach (TableRow row in Rows) - { - if (row is LocationControl) - { - LocationControl locationRow = (LocationControl)row; - if (counts[locationRow.TextBoxName.Text] > 1) - _listDuplicateNames.Add(locationRow); - } - } - - _customValidatorUniqueName.ErrorMessage = String.Format( - _parent.RedirectErrorMessageDuplicatesText, - String.Join(", ", list.ToArray())); - - args.IsValid = list.Count == 0; - } - - /// - /// Add any UI information to the controls. - /// - /// - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - - _panelName.CssClass = _panelUrl.CssClass = _panelMatchExpression.CssClass = - _panelFilters.CssClass = _parent.LabelCssClass; - - _parent.AddLabel(_panelName, - _parent.RedirectLabelUniqueNameText, - _parent.RedirectLocationNameToolTip, - null, null); - _parent.AddLabel(_panelUrl, - _parent.RedirectLabelRedirectUrlText, - _parent.RedirectLocationUrlToolTip, - null, null); - _parent.AddLabel(_panelMatchExpression, - _parent.RedirectLabelMatchExpressionText, - _parent.RedirectLocationMatchExpressionToolTip, - null, null); - _parent.AddLabel(_panelFilters, - _parent.RedirectLabelFiltersText, - _parent.RedirectLocationFiltersToolTip, - null, null); - - foreach (LocationControl row in _listDuplicateNames) - row.TextBoxName.CssClass = _parent.ErrorCssClass; - - int count = 1; - foreach (TableRow row in Rows) - { - if (row is LocationControl) - { - row.CssClass = count % 2 == 0 ? _parent.AltLocationCssClass : _parent.LocationCssClass; - int filterRowIndex = Rows.GetRowIndex(row) + 1; - if (filterRowIndex < Rows.Count) - Rows[filterRowIndex].CssClass = row.CssClass; - count++; - } - } - } - - #endregion - } - - #endregion - - #region Fields - - #region Controls - - private Table _tableBasic = null; - private Panel _panelEnabled = null; - private Panel _panelDevicesFile = null; - private Panel _panelFirstRequestOnly = null; - private Panel _panelMobileHomePageUrl = null; - private Panel _panelMobilePagesRegex = null; - private Panel _panelOriginalUrlAsQueryString = null; - private Panel _panelTimeout = null; - private Literal _literalBasic = null; - private Literal _literalLocations = null; - private Literal _literalMessage = null; - - private CheckBox _checkBoxEnabled = null; - private TextBox _textBoxDevicesFile = null; - private CheckBox _checkBoxFirstRequestOnly = null; - private TextBox _textBoxMobileHomePageUrl = null; - private TextBox _textBoxMobilePagesRegex = null; - private CheckBox _checkBoxOriginalUrlAsQueryString = null; - private TextBox _textBoxTimeout = null; - private ValidationSummary _validationSummary = null; - private RegularExpressionValidator _regularExpressionValidatorTimeout = null; - private RegularExpressionValidator _regularExpressionValidatorUrl = null; - private RegularExpressionValidator _regularExpressionValidatorDevicesFile = null; - private CustomValidator _customValidatorRegex = null; - private LocationsControl _locationsControl = null; - private Button _buttonUpdate = null; - private Button _buttonReset = null; - private Button _buttonAdd = null; - private Panel _panelLocations = null; - private Panel _panelButtons = null; - private Panel _panelBasic = null; - private Panel _panelMessages = null; - private RedirectData _data = null; - - #endregion - - #region Css - - private string _labelCssClass = "label"; - private string _dropDownListCssClass = "ddl"; - private string _textBoxCssClass = "textbox"; - private string _checkBoxCssClass = "checkbox"; - private string _errorCssClass = "error"; - private string _successCssClass = "success"; - private string _buttonCssClass = "button"; - private string _locationCssClass = "location"; - private string _altLocationCssClass = "altlocation"; - private string _basicCssClass = "basic"; - private string _locationsCssClass = "locations"; - private string _buttonsCssClass = "buttons"; - - #endregion - - #region Messages - - private string _redirectBasicHeadingHtml = Resources.RedirectBasicHeadingHtml; - private string _redirectButtonHideText = Resources.RedirectButtonHideText; - private string _redirectButtonNewLocationText = Resources.RedirectButtonNewLocationText; - private string _redirectButtonNewText = Resources.RedirectButtonNewText; - private string _redirectButtonRemoveText = Resources.RedirectButtonRemoveText; - private string _redirectButtonResetText = Resources.RedirectButtonResetText; - private string _redirectButtonShowText = Resources.RedirectButtonShowText; - private string _redirectButtonUpdateText = Resources.RedirectButtonUpdateText; - private string _redirectDevicesFileToolTip = Resources.RedirectDevicesFileToolTip; - private string _redirectEnabledToolTip = Resources.RedirectEnabledToolTip; - private string _redirectErrorMessageDevicesFileText = Resources.RedirectErrorMessageDevicesFileText; - private string _redirectErrorMessageDuplicatesText = Resources.RedirectErrorMessageDuplicatesText; - private string _redirectErrorMessageMatchExpressionText = Resources.RedirectErrorMessageMatchExpressionText; - private string _redirectErrorMessageMobileHomePageRegexText = Resources.RedirectErrorMessageMobileHomePageRegexText; - private string _redirectErrorMessageMobileHomePageUrlText = Resources.RedirectErrorMessageMobileHomePageUrlText; - private string _redirectErrorMessageNameFieldText = Resources.RedirectErrorMessageNameFieldText; - private string _redirectErrorMessageTimeOutText = Resources.RedirectErrorMessageTimeOutText; - private string _redirectErrorMessageUrlFormatText = Resources.RedirectErrorMessageUrlFormatText; - private string _redirectFirstRequestOnlyToolTip = Resources.RedirectFirstRequestOnlyToolTip; - private string _redirectLabelDevicesFileText = Resources.RedirectLabelDevicesFileText; - private string _redirectLabelEnabledText = Resources.RedirectLabelEnabledText; - private string _redirectLabelFiltersText = Resources.RedirectLabelFiltersText; - private string _redirectLabelFirstRequestOnlyText = Resources.RedirectLabelFirstRequestOnlyText; - private string _redirectLabelMatchExpressionText = Resources.RedirectLabelMatchExpressionText; - private string _redirectLabelMobileHomePageUrlText = Resources.RedirectLabelMobileHomePageUrlText; - private string _redirectLabelMobilePagesRegexText = Resources.RedirectLabelMobilePagesRegexText; - private string _redirectLabelOriginalUrlAsQueryStringText = Resources.RedirectLabelOriginalUrlAsQueryStringText; - private string _redirectLabelPropertyText = Resources.RedirectLabelPropertyText; - private string _redirectLabel_redirectUrlText = Resources.RedirectLabelRedirectUrlText; - private string _redirectLabelTimeoutText = Resources.RedirectLabelTimeoutText; - private string _redirectLabelUniqueNameText = Resources.RedirectLabelUniqueNameText; - private string _redirectLabelValueText = Resources.RedirectLabelValueText; - private string _redirectLocationFilterMatchExpressionToolTip = Resources.RedirectLocationFilterMatchExpressionToolTip; - private string _redirectLocationFilterPropertyToolTip = Resources.RedirectLocationFilterPropertyToolTip; - private string _redirectLocationFiltersToolTip = Resources.RedirectLocationFiltersToolTip; - private string _redirectLocationMatchExpressionToolTip = Resources.RedirectLocationMatchExpressionToolTip; - private string _redirectLocationNameToolTip = Resources.RedirectLocationNameToolTip; - private string _redirectLocationsHeadingHtml = Resources.RedirectLocationsHeadingHtml; - private string _redirectLocationUrlToolTip = Resources.RedirectLocationUrlToolTip; - private string _redirectMobilePagesRegexToolTip = Resources.RedirectMobilePagesRegexToolTip; - private string _redirectMobile_redirectUrlToolTip = Resources.RedirectMobileRedirectUrlToolTip; - private string _redirectOriginalUrlAsQueryStringToolTip = Resources.RedirectOriginalUrlAsQueryStringToolTip; - private string _redirectTimeoutToolTip = Resources.RedirectTimeoutToolTip; - private string _redirectUpdateGeneralDetailedFailureHtml = Resources.RedirectUpdateGeneralDetailedFailureHtml; - private string _redirectUpdateGeneralFailureHtml = Resources.RedirectUpdateGeneralFailureHtml; - private string _redirectUpdateSuccessHtml = Resources.RedirectUpdateSuccessHtml; - - #endregion - - #endregion - - #region Properties - - #region Css - - /// - /// The CssClass used for the general buttons area of the control. - /// - public string CssClassButtons - { - get { return _buttonsCssClass; } - set { _buttonsCssClass = value; } - } - - /// - /// The CssClass used for the basic fields areas of the the control. - /// - public string CssClassBasic - { - get { return _basicCssClass; } - set { _basicCssClass = value; } - } - - /// - /// The CssClass used for the locations area of the control. - /// - public string CssClassLocations - { - get { return _locationsCssClass; } - set { _locationsCssClass = value; } - } - - /// - /// The CssClass used for every other location row in the table. - /// - public string LocationCssClass - { - get { return _locationCssClass; } - set { _locationCssClass = value; } - } - - /// - /// The CssClass used for every other location row in the table. - /// - public string AltLocationCssClass - { - get { return _altLocationCssClass; } - set { _altLocationCssClass = value; } - } - - /// - /// The general button class used by the control. - /// - public string ButtonCssClass - { - get { return _buttonCssClass; } - set { _buttonCssClass = value; } - } - - /// - /// The CssClass used when an error is displayed. - /// - public string ErrorCssClass - { - get { return _errorCssClass; } - set { _errorCssClass = value; } - } - - /// - /// The CssClass used when a success message is displayed. - /// - public string SuccessCssClass - { - get { return _successCssClass; } - set { _successCssClass = value; } - } - - /// - /// The CssClass used to display a label. - /// - public string LabelCssClass - { - get { return _labelCssClass; } - set { _labelCssClass = value; } - } - - /// - /// The CssClass used to display a drop down list. - /// - public string DropDownListCssClass - { - get { return _dropDownListCssClass; } - set { _dropDownListCssClass = value; } - } - - /// - /// The CssClass used to display a textbox. - /// - public string TextBoxCssClass - { - get { return _textBoxCssClass; } - set { _textBoxCssClass = value; } - } - - /// - /// The CssClass used to display a checkbox. - /// - public string CheckBoxCssClass - { - get { return _checkBoxCssClass; } - set { _checkBoxCssClass = value; } - } - - #endregion - - #region Messages - - // Properties used to localise text displayed by the control. - - #pragma warning disable 1591 - - public string RedirectBasicHeadingHtml { get { return _redirectBasicHeadingHtml; } set { _redirectBasicHeadingHtml = value; } } - public string RedirectButtonHideText { get { return _redirectButtonHideText; } set { _redirectButtonHideText = value; } } - public string RedirectButtonNewLocationText { get { return _redirectButtonNewLocationText; } set { _redirectButtonNewLocationText = value; } } - public string RedirectButtonNewText { get { return _redirectButtonNewText; } set { _redirectButtonNewText = value; } } - public string RedirectButtonRemoveText { get { return _redirectButtonRemoveText; } set { _redirectButtonRemoveText = value; } } - public string RedirectButtonResetText { get { return _redirectButtonResetText; } set { _redirectButtonResetText = value; } } - public string RedirectButtonShowText { get { return _redirectButtonShowText; } set { _redirectButtonShowText = value; } } - public string RedirectButtonUpdateText { get { return _redirectButtonUpdateText; } set { _redirectButtonUpdateText = value; } } - public string RedirectDevicesFileToolTip { get { return _redirectDevicesFileToolTip; } set { _redirectDevicesFileToolTip = value; } } - public string RedirectEnabledToolTip { get { return _redirectEnabledToolTip; } set { _redirectEnabledToolTip = value; } } - public string RedirectErrorMessageDevicesFileText { get { return _redirectErrorMessageDevicesFileText; } set { _redirectErrorMessageDevicesFileText = value; } } - public string RedirectErrorMessageDuplicatesText { get { return _redirectErrorMessageDuplicatesText; } set { _redirectErrorMessageDuplicatesText = value; } } - public string RedirectErrorMessageMatchExpressionText { get { return _redirectErrorMessageMatchExpressionText; } set { _redirectErrorMessageMatchExpressionText = value; } } - public string RedirectErrorMessageMobileHomePageRegexText { get { return _redirectErrorMessageMobileHomePageRegexText; } set { _redirectErrorMessageMobileHomePageRegexText = value; } } - public string RedirectErrorMessageMobileHomePageUrlText { get { return _redirectErrorMessageMobileHomePageUrlText; } set { _redirectErrorMessageMobileHomePageUrlText = value; } } - public string RedirectErrorMessageNameFieldText { get { return _redirectErrorMessageNameFieldText; } set { _redirectErrorMessageNameFieldText = value; } } - public string RedirectErrorMessageTimeOutText { get { return _redirectErrorMessageTimeOutText; } set { _redirectErrorMessageTimeOutText = value; } } - public string RedirectErrorMessageUrlFormatText { get { return _redirectErrorMessageUrlFormatText; } set { _redirectErrorMessageUrlFormatText = value; } } - public string RedirectFirstRequestOnlyToolTip { get { return _redirectFirstRequestOnlyToolTip; } set { _redirectFirstRequestOnlyToolTip = value; } } - public string RedirectLabelDevicesFileText { get { return _redirectLabelDevicesFileText; } set { _redirectLabelDevicesFileText = value; } } - public string RedirectLabelEnabledText { get { return _redirectLabelEnabledText; } set { _redirectLabelEnabledText = value; } } - public string RedirectLabelFiltersText { get { return _redirectLabelFiltersText; } set { _redirectLabelFiltersText = value; } } - public string RedirectLabelFirstRequestOnlyText { get { return _redirectLabelFirstRequestOnlyText; } set { _redirectLabelFirstRequestOnlyText = value; } } - public string RedirectLabelMatchExpressionText { get { return _redirectLabelMatchExpressionText; } set { _redirectLabelMatchExpressionText = value; } } - public string RedirectLabelMobileHomePageUrlText { get { return _redirectLabelMobileHomePageUrlText; } set { _redirectLabelMobileHomePageUrlText = value; } } - public string RedirectLabelMobilePagesRegexText { get { return _redirectLabelMobilePagesRegexText; } set { _redirectLabelMobilePagesRegexText = value; } } - public string RedirectLabelOriginalUrlAsQueryStringText { get { return _redirectLabelOriginalUrlAsQueryStringText; } set { _redirectLabelOriginalUrlAsQueryStringText = value; } } - public string RedirectLabelPropertyText { get { return _redirectLabelPropertyText; } set { _redirectLabelPropertyText = value; } } - public string RedirectLabelRedirectUrlText { get { return _redirectLabel_redirectUrlText; } set { _redirectLabel_redirectUrlText = value; } } - public string RedirectLabelTimeoutText { get { return _redirectLabelTimeoutText; } set { _redirectLabelTimeoutText = value; } } - public string RedirectLabelUniqueNameText { get { return _redirectLabelUniqueNameText; } set { _redirectLabelUniqueNameText = value; } } - public string RedirectLabelValueText { get { return _redirectLabelValueText; } set { _redirectLabelValueText = value; } } - public string RedirectLocationFilterMatchExpressionToolTip { get { return _redirectLocationFilterMatchExpressionToolTip; } set { _redirectLocationFilterMatchExpressionToolTip = value; } } - public string RedirectLocationFilterPropertyToolTip { get { return _redirectLocationFilterPropertyToolTip; } set { _redirectLocationFilterPropertyToolTip = value; } } - public string RedirectLocationFiltersToolTip { get { return _redirectLocationFiltersToolTip; } set { _redirectLocationFiltersToolTip = value; } } - public string RedirectLocationMatchExpressionToolTip { get { return _redirectLocationMatchExpressionToolTip; } set { _redirectLocationMatchExpressionToolTip = value; } } - public string RedirectLocationNameToolTip { get { return _redirectLocationNameToolTip; } set { _redirectLocationNameToolTip = value; } } - public string RedirectLocationsHeadingHtml { get { return _redirectLocationsHeadingHtml; } set { _redirectLocationsHeadingHtml = value; } } - public string RedirectLocationUrlToolTip { get { return _redirectLocationUrlToolTip; } set { _redirectLocationUrlToolTip = value; } } - public string RedirectMobilePagesRegexToolTip { get { return _redirectMobilePagesRegexToolTip; } set { _redirectMobilePagesRegexToolTip = value; } } - public string RedirectMobileRedirectUrlToolTip { get { return _redirectMobile_redirectUrlToolTip; } set { _redirectMobile_redirectUrlToolTip = value; } } - public string RedirectOriginalUrlAsQueryStringToolTip { get { return _redirectOriginalUrlAsQueryStringToolTip; } set { _redirectOriginalUrlAsQueryStringToolTip = value; } } - public string RedirectTimeoutToolTip { get { return _redirectTimeoutToolTip; } set { _redirectTimeoutToolTip = value; } } - public string RedirectUpdateGeneralDetailedFailureHtml { get { return _redirectUpdateGeneralDetailedFailureHtml; } set { _redirectUpdateGeneralDetailedFailureHtml = value; } } - public string RedirectUpdateGeneralFailureHtml { get { return _redirectUpdateGeneralFailureHtml; } set { _redirectUpdateGeneralFailureHtml = value; } } - public string RedirectUpdateSuccessHtml { get { return _redirectUpdateSuccessHtml; } set { _redirectUpdateSuccessHtml = value; } } - - #pragma warning restore 1591 - - #endregion - - #endregion - - #region Constructor - - /// - /// Constructs a new instance of the control. - /// - public Redirect() - { - CssClass = "redirect"; - - _tableBasic = new Table(); - _panelEnabled = new Panel(); - _panelDevicesFile = new Panel(); - _panelFirstRequestOnly = new Panel(); - _panelMobileHomePageUrl = new Panel(); - _panelMobilePagesRegex = new Panel(); - _panelOriginalUrlAsQueryString = new Panel(); - _panelTimeout = new Panel(); - _literalBasic = new Literal(); - _literalLocations = new Literal(); - _textBoxDevicesFile = new TextBox(); - _checkBoxEnabled = new CheckBox(); - _checkBoxFirstRequestOnly = new CheckBox(); - _textBoxMobileHomePageUrl = new TextBox(); - _textBoxMobilePagesRegex = new TextBox(); - _checkBoxOriginalUrlAsQueryString = new CheckBox(); - _textBoxTimeout = new TextBox(); - _buttonReset = new Button(); - _buttonUpdate = new Button(); - _buttonAdd = new Button(); - _validationSummary = new ValidationSummary(); - _customValidatorRegex = new CustomValidator(); - _regularExpressionValidatorDevicesFile = new RegularExpressionValidator(); - _regularExpressionValidatorTimeout = new RegularExpressionValidator(); - _regularExpressionValidatorUrl = new RegularExpressionValidator(); - _panelLocations = new Panel(); - _panelButtons = new Panel(); - _panelBasic = new Panel(); - _panelMessages = new Panel(); - _literalMessage = new Literal(); - - _textBoxDevicesFile.ID = - _regularExpressionValidatorDevicesFile.ControlToValidate = "DevicesFile"; - _textBoxMobileHomePageUrl.ID = - _regularExpressionValidatorUrl.ControlToValidate = "MobileHomePageUrl"; - _textBoxMobilePagesRegex.ID = - _customValidatorRegex.ControlToValidate = "MobilePagesRegex"; - - _checkBoxFirstRequestOnly.ID = "FirstRequestOnly"; - _checkBoxOriginalUrlAsQueryString.ID = "OriginalUrlAsQueryString"; - _textBoxTimeout.ID = - _regularExpressionValidatorTimeout.ControlToValidate = "Timeout"; - _checkBoxEnabled.ID = "Enabled"; - - _buttonReset.ID = "Reset"; - _buttonUpdate.ID = "Update"; - _buttonAdd.ID = "Add"; - - _buttonUpdate.CausesValidation = true; - _buttonReset.CausesValidation = _buttonAdd.CausesValidation = false; - - _validationSummary.DisplayMode = ValidationSummaryDisplayMode.List; - - _validationSummary.ValidationGroup = - _buttonUpdate.ValidationGroup = - _regularExpressionValidatorDevicesFile.ValidationGroup = - _regularExpressionValidatorTimeout.ValidationGroup = - _regularExpressionValidatorUrl.ValidationGroup = - _customValidatorRegex.ValidationGroup = VALIDATION_GROUP; - - _regularExpressionValidatorDevicesFile.Display = - _regularExpressionValidatorTimeout.Display = - _regularExpressionValidatorUrl.Display = - _customValidatorRegex.Display = ValidatorDisplay.None; - - _regularExpressionValidatorDevicesFile.EnableClientScript = - _regularExpressionValidatorTimeout.EnableClientScript = - _regularExpressionValidatorUrl.EnableClientScript = false; - - _regularExpressionValidatorTimeout.ValidationExpression = REGEX_NUMERIC; - _regularExpressionValidatorDevicesFile.ValidationExpression = REGEX_FILE; - _regularExpressionValidatorUrl.ValidationExpression = REGEX_URL; - - _buttonUpdate.CausesValidation = true; - } - - #endregion - - #region Methods - - /// - /// Saves the controls data between requests. - /// - /// The data object to be saved. - protected override object SaveControlState() - { - using (MemoryStream ms = new MemoryStream()) - { - using (BinaryWriter writer = new BinaryWriter(ms)) - { - _data.Serialize(writer); - } - return ms.GetBuffer(); - } - } - - /// - /// Loads the controls data from a previous request. - /// - /// The previous data object. - protected override void LoadControlState(object savedState) - { - using (BinaryReader reader = new BinaryReader(new MemoryStream((byte[])savedState))) - { - _data = new RedirectData(reader); - LoadData(); - } - } - - /// - /// Sets the fields based on the data strucuture loaded. - /// - protected void LoadData() - { - _textBoxDevicesFile.Text = _data.DevicesFile; - _checkBoxEnabled.Checked = _data.Enabled; - _checkBoxFirstRequestOnly.Checked = _data.FirstRequestOnly; - _textBoxMobileHomePageUrl.Text = _data.MobileHomePageUrl; - _textBoxMobilePagesRegex.Text = _data.MobilePagesRegex; - _checkBoxOriginalUrlAsQueryString.Checked = _data.OriginalUrlAsQueryString; - _textBoxTimeout.Text = _data.Timeout.ToString(); - - if (_locationsControl != null) - _panelLocations.Controls.Remove(_locationsControl); - _locationsControl = new LocationsControl(_data, this); - _panelLocations.Controls.Add(_locationsControl); - } - - private Panel AddPanel() - { - Panel panel = new Panel(); - Controls.Add(panel); - return panel; - } - - private TableRow AddTableRow(Panel label, Control ctrl) - { - TableRow row = new TableRow(); - _tableBasic.Controls.Add(row); - TableCell cell1 = new TableCell(); - TableCell cell2 = new TableCell(); - row.Controls.Add(cell1); - row.Controls.Add(cell2); - cell1.Controls.Add(label); - cell2.Controls.Add(ctrl); - return row; - } - - private TableRow AddTableRowSingle(Panel label, Control ctrl) - { - TableRow row1 = new TableRow(); - TableRow row2 = new TableRow(); - _tableBasic.Controls.Add(row1); - _tableBasic.Controls.Add(row2); - TableCell cell1 = new TableCell(); - TableCell cell2 = new TableCell(); - cell1.ColumnSpan = cell2.ColumnSpan = 2; - row1.Controls.Add(cell1); - row2.Controls.Add(cell2); - cell1.Controls.Add(label); - cell2.Controls.Add(ctrl); - return row1; - } - - #endregion - - #region Events - - /// - /// Initialise the controls. - /// - /// - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - Page.MaintainScrollPositionOnPostBack = true; - - _container.Controls.Add(_panelMessages); - _panelMessages.Controls.Add(_literalMessage); - _panelMessages.Controls.Add(_validationSummary); - _container.Controls.Add(_panelBasic); - _panelBasic.Controls.Add(_literalBasic); - _panelBasic.Controls.Add(_tableBasic); - AddTableRow(_panelEnabled, _checkBoxEnabled); - AddTableRow(_panelFirstRequestOnly, _checkBoxFirstRequestOnly); - AddTableRow(_panelOriginalUrlAsQueryString, _checkBoxOriginalUrlAsQueryString); - AddTableRow(_panelTimeout, _textBoxTimeout); - AddTableRowSingle(_panelMobileHomePageUrl, _textBoxMobileHomePageUrl); - AddTableRowSingle(_panelMobilePagesRegex, _textBoxMobilePagesRegex); - AddTableRowSingle(_panelDevicesFile, _textBoxDevicesFile); - _container.Controls.Add(_panelLocations); - _panelLocations.Controls.Add(_literalLocations); - _container.Controls.Add(_panelButtons); - _panelButtons.Controls.Add(_buttonUpdate); - _panelButtons.Controls.Add(_buttonReset); - _panelButtons.Controls.Add(_buttonAdd); - _container.Controls.Add(_regularExpressionValidatorDevicesFile); - _container.Controls.Add(_regularExpressionValidatorTimeout); - _container.Controls.Add(_regularExpressionValidatorUrl); - _container.Controls.Add(_customValidatorRegex); - - Page.RegisterRequiresControlState(this); - - if (!Page.IsPostBack) - { - _data = new RedirectData(FiftyOne.Foundation.Mobile.Configuration.Manager.Redirect); - LoadData(); - } - - _textBoxDevicesFile.TextChanged += new EventHandler(_textBoxDevicesFile_TextChanged); - _checkBoxEnabled.CheckedChanged += new EventHandler(_checkBoxEnabled_CheckedChanged); - _checkBoxFirstRequestOnly.CheckedChanged += new EventHandler(_checkBoxFirstRequestOnly_CheckedChanged); - _textBoxMobileHomePageUrl.TextChanged += new EventHandler(_textBoxMobileHomePageUrl_TextChanged); - _textBoxMobilePagesRegex.TextChanged += new EventHandler(_textBoxMobilePagesRegex_TextChanged); - _checkBoxOriginalUrlAsQueryString.CheckedChanged += new EventHandler(_checkBoxOriginalUrlAsQueryString_CheckedChanged); - _textBoxTimeout.TextChanged += new EventHandler(_textBoxTimeout_TextChanged); - _buttonAdd.Click += new EventHandler(_buttonAdd_Click); - _buttonReset.Click += new EventHandler(_buttonReset_Click); - _buttonUpdate.Click += new EventHandler(_buttonUpdate_Click); - _customValidatorRegex.ServerValidate += new ServerValidateEventHandler(_customValidatorRegex_ServerValidate); - } - - /// - /// Sets the final UI elements of the control. - /// - /// - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - - AddLabel(_panelDevicesFile, - this.RedirectLabelDevicesFileText, - this.RedirectDevicesFileToolTip, - null, null); - AddLabel(_panelEnabled, - this.RedirectLabelEnabledText, - this.RedirectEnabledToolTip, - null, null); - AddLabel(_panelFirstRequestOnly, - this.RedirectLabelFirstRequestOnlyText, - this.RedirectFirstRequestOnlyToolTip, - null, null); - AddLabel(_panelMobileHomePageUrl, - this.RedirectLabelMobileHomePageUrlText, - this.RedirectMobileRedirectUrlToolTip, - null, null); - AddLabel(_panelMobilePagesRegex, - this.RedirectLabelMobilePagesRegexText, - this.RedirectMobilePagesRegexToolTip, - null, null); - AddLabel(_panelOriginalUrlAsQueryString, - this.RedirectLabelOriginalUrlAsQueryStringText, - this.RedirectOriginalUrlAsQueryStringToolTip, - null, null); - AddLabel(_panelTimeout, - this.RedirectLabelTimeoutText, - this.RedirectTimeoutToolTip, - null, null); - - AddCssClass(_panelBasic, CssClassBasic); - AddCssClass(_panelLocations, CssClassLocations); - if (String.IsNullOrEmpty(_panelMessages.CssClass)) - AddCssClass(_panelMessages, ErrorCssClass); - AddCssClass(_panelDevicesFile, LabelCssClass); - AddCssClass(_panelEnabled, LabelCssClass); - AddCssClass(_panelFirstRequestOnly, LabelCssClass); - AddCssClass(_panelMobileHomePageUrl, LabelCssClass); - AddCssClass(_panelMobilePagesRegex, LabelCssClass); - AddCssClass(_panelOriginalUrlAsQueryString, LabelCssClass); - AddCssClass(_panelTimeout, LabelCssClass); - AddCssClass(_textBoxDevicesFile, TextBoxCssClass); - AddCssClass(_textBoxMobileHomePageUrl, TextBoxCssClass); - AddCssClass(_textBoxMobilePagesRegex, TextBoxCssClass); - AddCssClass(_textBoxTimeout, TextBoxCssClass); - AddCssClass(_checkBoxEnabled, CheckBoxCssClass); - AddCssClass(_checkBoxFirstRequestOnly, CheckBoxCssClass); - AddCssClass(_checkBoxOriginalUrlAsQueryString, CheckBoxCssClass); - AddCssClass(_buttonAdd, ButtonCssClass); - AddCssClass(_buttonUpdate, ButtonCssClass); - AddCssClass(_buttonReset, ButtonCssClass); - AddCssClass(_panelButtons, CssClassButtons); - - _literalBasic.Text = this.RedirectBasicHeadingHtml; - _literalLocations.Text = this.RedirectLocationsHeadingHtml; - - _buttonReset.Text = this.RedirectButtonResetText; - _buttonUpdate.Text = this.RedirectButtonUpdateText; - _buttonAdd.Text = this.RedirectButtonNewLocationText; - - _customValidatorRegex.ErrorMessage = this.RedirectErrorMessageMobileHomePageRegexText; - _regularExpressionValidatorDevicesFile.ErrorMessage = this.RedirectErrorMessageDevicesFileText; - _regularExpressionValidatorTimeout.ErrorMessage = this.RedirectErrorMessageTimeOutText; - _regularExpressionValidatorUrl.ErrorMessage = this.RedirectErrorMessageMobileHomePageUrlText; - - SetError(_regularExpressionValidatorDevicesFile, _textBoxDevicesFile, ErrorCssClass); - SetError(_regularExpressionValidatorTimeout, _textBoxTimeout, ErrorCssClass); - SetError(_regularExpressionValidatorUrl, _textBoxMobileHomePageUrl, ErrorCssClass); - SetError(_customValidatorRegex, _textBoxMobilePagesRegex, ErrorCssClass); - - bool invalid = false; - foreach (IValidator validator in Page.GetValidators(VALIDATION_GROUP)) - { - if (validator.IsValid == false) - { - invalid = true; - break; - } - } - _panelMessages.Visible = - String.IsNullOrEmpty(_literalMessage.Text) == false || invalid; - } - - private void _customValidatorRegex_ServerValidate(object source, ServerValidateEventArgs args) - { - args.IsValid = CheckIsRegExValid(args.Value); - } - - private void _buttonUpdate_Click(object sender, EventArgs e) - { - string xml = null; - try - { - if (Page.IsValid) - { - RedirectSection section = _data.GetElement(); - xml = section.GetXmlElement(); - if (section != null) - { - FiftyOne.Foundation.Mobile.Configuration.Support.SetWebApplicationSection(section); - FiftyOne.Foundation.Mobile.Configuration.Manager.Refresh(); - } - _literalMessage.Text = this.RedirectUpdateSuccessHtml; - _panelMessages.CssClass = SuccessCssClass; - } - } - catch (Exception ex) - { -#if DEBUG - _literalMessage.Text = String.Format( - this.RedirectUpdateGeneralDetailedFailureHtml, - ex.Message, - ex.StackTrace, - xml); -#else - _literalMessage.Text = String.Format( - this.RedirectUpdateGeneralFailureHtml, - ex.Message, - xml == null ? "Not Available" : HttpUtility.HtmlEncode(xml)); -#endif - EventLog.Fatal(ex); - } - } - - private void _buttonReset_Click(object sender, EventArgs e) - { - _data = new RedirectData(FiftyOne.Foundation.Mobile.Configuration.Manager.Redirect); - LoadData(); - } - - private void _buttonAdd_Click(object sender, EventArgs e) - { - LocationData newLocation = new LocationData(_data); - _data.Add(newLocation); - _locationsControl.Rows.Add(new LocationControl(newLocation, this)); - } - - private void _textBoxTimeout_TextChanged(object sender, EventArgs e) - { - _data.Timeout = int.Parse(((TextBox)sender).Text); - } - - private void _checkBoxOriginalUrlAsQueryString_CheckedChanged(object sender, EventArgs e) - { - _data.OriginalUrlAsQueryString = ((CheckBox)sender).Checked; ; - } - - private void _textBoxMobilePagesRegex_TextChanged(object sender, EventArgs e) - { - _data.MobilePagesRegex = ((TextBox)sender).Text; - } - - private void _textBoxMobileHomePageUrl_TextChanged(object sender, EventArgs e) - { - _data.MobileHomePageUrl = ((TextBox)sender).Text; - } - - private void _checkBoxFirstRequestOnly_CheckedChanged(object sender, EventArgs e) - { - _data.FirstRequestOnly = ((CheckBox)sender).Checked; - } - - private void _checkBoxEnabled_CheckedChanged(object sender, EventArgs e) - { - _data.Enabled = ((CheckBox)sender).Checked; - } - - private void _textBoxDevicesFile_TextChanged(object sender, EventArgs e) - { - _data.DevicesFile = ((TextBox)sender).Text; - } - - #endregion - } -} diff --git a/Foundation/UI/Web/RelatedDeviceTemplate.cs b/Foundation/UI/Web/RelatedDeviceTemplate.cs deleted file mode 100644 index 44f7778..0000000 --- a/Foundation/UI/Web/RelatedDeviceTemplate.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* ********************************************************************* - * 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 System.Web.UI; -using System.Web.UI.WebControls; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Template used to display a device related to another one by a shared hardware platform. - /// - public class RelatedDeviceTemplate : ITemplate - { - /// - /// Adds requirement controls to the container. - /// - /// Container the template is being displayed in. - public void InstantiateIn(Control container) - { - Panel panel = new Panel(); - HyperLink deviceLink = new HyperLink(); - - deviceLink.ID = "Link"; - panel.ID = "Device"; - - panel.Controls.Add(deviceLink); - - container.Controls.Add(panel); - } - } -} diff --git a/Foundation/UI/Web/ShareUsage.cs b/Foundation/UI/Web/ShareUsage.cs deleted file mode 100644 index 7c08ec2..0000000 --- a/Foundation/UI/Web/ShareUsage.cs +++ /dev/null @@ -1,263 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Web.UI.WebControls; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// EventHandler used to notify containers of a message to display - /// when the share usage value changes. - /// - /// The control instance generating the event. - /// The results of the change. - public delegate void ShareUsageChangedEventHandler(object sender, string html); - - /// - /// Control used to provide the UI for turning the share usage attribute - /// on and off. - /// - public class ShareUsage : BaseDataControl - { - #region Constants - - private const string VALIDATION_LICENCE = "ValidateLicence"; - - #endregion - - #region Fields - - #region Controls - - private Literal _literalShareUsageResult = null; - private CheckBox _checkBoxShareUsage = null; - private HyperLink _hyperLinkShareUsage = null; - - #endregion - - #region Css - - private string _checkBoxCssClass = "checkbox"; - private string _hyperLinkCssClass = "hyperlink"; - - #endregion - - #region Messages - - private string _shareUsageText = Resources.ShareUsageText; - private string _shareUsageTrueHtml = Resources.ShareUsageTrueHtml; - private string _shareUsageFalseHtml = Resources.ShareUsageFalseHtml; - private string _shareUsageErrorHtml = Resources.ShareUsageErrorHtml; - private string _shareUsageLinkText = Resources.ShareUsageLinkText; - private string _shareUsageUrl = Resources.ShareUsageUrl; - - #endregion - - #region Other - - private bool _showShareUsage = true; - - #endregion - - #endregion - - #region Properties - - #region Messages - - /// - /// The url of the page that should be used to find out more about - /// sharing usage information. - /// - public string ShareUsageUrl - { - get { return _shareUsageUrl; } - set { _shareUsageUrl = value; } - } - - /// - /// The text that should appear on the hyper link next to the - /// share usage check box text. - /// - public string ShareUsageLinkText - { - get { return _shareUsageLinkText; } - set { _shareUsageLinkText = value; } - } - - /// - /// Html used when the share usage value is set to true. - /// - public string ShareUsageTrueHtml - { - get { return _shareUsageTrueHtml; } - set { _shareUsageTrueHtml = value; } - } - - /// - /// Html used when the share usage value is set to false. - /// - public string ShareUsageFalseHtml - { - get { return _shareUsageFalseHtml; } - set { _shareUsageFalseHtml = value; } - } - - /// - /// Html used when an error is generated changing the share usage value. - /// - public string ShareUsageErrorHtml - { - get { return _shareUsageErrorHtml; } - set { _shareUsageErrorHtml = value; } - } - - /// - /// Text used to inform user about sharing usage information. - /// - public string ShareUsageText - { - get { return _shareUsageText; } - set { _shareUsageText = value; } - } - - #endregion - - #region Css - - /// - /// Gets or sets the hyper link css class for share usage. - /// - public string HyperLinkCssClass - { - get { return _hyperLinkCssClass; } - set { _hyperLinkCssClass = value; } - } - - /// - /// Gets or sets the check box css class for share usaged check box. - /// - public string CheckBoxCssClass - { - get { return _checkBoxCssClass; } - set { _checkBoxCssClass = value; } - } - - #endregion - - #region Other - - /// - /// Controls whether the share usage information is displayed. - /// Defaults to true. - /// - public bool ShowShareUsage - { - get { return _showShareUsage; } - set { _showShareUsage = value; } - } - - #endregion - - #endregion - - #region Event Handlers - - /// - /// Fired when the upload has completed. Used to inform other - /// controls the result of the upload. - /// - public event ShareUsageChangedEventHandler ShareUsageChanged; - - #endregion - - #region Events - - /// - /// Load the controls which will form the user interface. - /// - /// - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - // Create the required controls. - _checkBoxShareUsage = new CheckBox(); - _hyperLinkShareUsage = new HyperLink(); - _literalShareUsageResult = new Literal(); - - // Set the new controls properties. - _checkBoxShareUsage.ID = "CheckBoxShareUsage"; - _checkBoxShareUsage.CausesValidation = false; - _checkBoxShareUsage.AutoPostBack = true; - _checkBoxShareUsage.Checked = FiftyOne.Foundation.Mobile.Detection.Configuration.Manager.ShareUsage; - _checkBoxShareUsage.CheckedChanged += new EventHandler(_checkBoxShareUsage_CheckedChanged); - _hyperLinkShareUsage.ID = "HyperLinkShareUsage"; - - // Add the controls to the user control. - _container.Controls.Add(_literalShareUsageResult); - _container.Controls.Add(_checkBoxShareUsage); - _container.Controls.Add(_hyperLinkShareUsage); - } - - /// - /// Sets the visible status of the instruction messages. - /// - /// - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - - _literalShareUsageResult.Visible = !String.IsNullOrEmpty(_literalShareUsageResult.Text); - _checkBoxShareUsage.CssClass = CheckBoxCssClass; - _checkBoxShareUsage.Text = ShareUsageText; - _hyperLinkShareUsage.CssClass = HyperLinkCssClass; - _hyperLinkShareUsage.Text = ShareUsageLinkText; - _hyperLinkShareUsage.NavigateUrl = ShareUsageUrl; - _hyperLinkShareUsage.Target = "_blank"; - - _hyperLinkShareUsage.Visible = _checkBoxShareUsage.Visible = - _literalShareUsageResult.Visible = ShowShareUsage; - } - - /// - /// Fired when the user changes the share usage preference. - /// - /// - /// - private void _checkBoxShareUsage_CheckedChanged(object sender, EventArgs e) - { - string message; - - try - { - FiftyOne.Foundation.Mobile.Detection.Configuration.Manager.ShareUsage = _checkBoxShareUsage.Checked; - - message = String.Format( - _checkBoxShareUsage.Checked ? - ShareUsageTrueHtml : ShareUsageFalseHtml, SuccessCssClass); - } - catch - { - message = String.Format( - ShareUsageErrorHtml, ErrorCssClass); - } - - if (ShareUsageChanged == null) - _literalShareUsageResult.Text = message; - else - ShareUsageChanged(this, message); - } - - #endregion - } -} diff --git a/Foundation/UI/Web/Stats.cs b/Foundation/UI/Web/Stats.cs deleted file mode 100644 index dbf2478..0000000 --- a/Foundation/UI/Web/Stats.cs +++ /dev/null @@ -1,160 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Web.UI; -using System.Web.UI.WebControls; -using FiftyOne.Foundation.Mobile; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Displays key stats about the active data provider. - /// - public class Stats : UserControl - { - #region Fields - - private string _cssClass = "footer"; - private Literal _literal = null; - private bool _buttonVisible = true; - private string _buttonText = Resources.StatsRefreshButtonText; - private string _buttonCssClass = "button"; - private string _html = Resources.StatsHtml; - private Button _buttonRefresh = null; - - #endregion - - #region Properties - - /// - /// Returns true if the refresh button should be visible. - /// - public bool ButtonVisible - { - get { return _buttonVisible; } - set { _buttonVisible = value; } - } - - /// - /// Sets the Html for the control with the following replacable sections. - /// {0} = CssClass - /// {1} = Data type Lite / Premium - /// {2} = Published data - /// {3} = Count of available properties - /// - public string Html - { - get { return _html; } - set { _html = value; } - } - - /// - /// The text that appears on the CSS button. - /// - public string RefreshButtonText - { - get { return _buttonText; } - set { _buttonText = value; } - } - - /// - /// The css class used for the refresh button. - /// - public string ButtonCssClass - { - get { return _buttonCssClass; } - set { _buttonCssClass = value; } - } - - /// - /// The css class used for the statistics literal control. - /// - public string CssClass - { - get { return _cssClass; } - set { _cssClass = value; } - } - - #endregion - - #region Events - - /// - /// Initialise the control. - /// - /// - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - _buttonRefresh = new Button(); - _literal = new Literal(); - _buttonRefresh.ID = "ButtonRefresh"; - Controls.Add(_literal); - Controls.Add(_buttonRefresh); - _buttonRefresh.Click += new EventHandler(_buttonRefresh_Click); - Page.PreRenderComplete += new EventHandler(Page_PreRenderComplete); - } - - /// - /// The refresh button has been clicked, refresh the data. - /// - /// - /// - private void _buttonRefresh_Click(object sender, EventArgs e) - { - try - { - AutoUpdate.Download(); - } - catch (Exception ex) - { - EventLog.Warn(new MobileException("Exception refreshing data.", ex)); - } - } - - /// - /// Set the properties of the controls. - /// - /// - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - _buttonRefresh.Text = RefreshButtonText; - - // Only enable the refresh button if premium keys are available. - _buttonRefresh.Visible = ButtonVisible && LicenceKey.Keys != null && LicenceKey.Keys.Length > 0; - - // Enable the button if there's a chance new data could be available. - _buttonRefresh.Enabled = DataProvider.Provider.PublishedDate.Add( - FiftyOne.Foundation.Mobile.Detection.Constants.AutoUpdateWait) < DateTime.UtcNow; - } - - /// - /// Displays the statistics about the provider. - /// - /// - /// - protected void Page_PreRenderComplete(object sender, EventArgs e) - { - _literal.Text = String.Format( - Html, - CssClass, - DataProvider.Provider.DataSetName, - DataProvider.Provider.PublishedDate, - DataProvider.Provider.Properties.Count, - Request.Browser[FiftyOne.Foundation.Mobile.Detection.Constants.DetectionTimeProperty]); - } - - #endregion - } -} diff --git a/Foundation/UI/Web/Upload.cs b/Foundation/UI/Web/Upload.cs deleted file mode 100644 index 0bcf4d9..0000000 --- a/Foundation/UI/Web/Upload.cs +++ /dev/null @@ -1,184 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Web.UI.WebControls; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// EventHandler used to notify containers that the upload has completed. - /// - /// The control instance generating the event. - /// The results of the upload. - public delegate void UploadEventHandler(object sender, ActivityResult e); - - /// - /// User Control to enable the uploading of a data file manually. - /// - public class Upload : BaseDataControl - { - #region Constants - - private const string VALIDATION_UPLOAD = "ValidateUpload"; - - #endregion - - #region Fields - - #region Controls - - private FileUpload _fileUploadData = null; - private Button _buttonUpload = null; - private CustomValidator _validatorFile = null; - private ValidationSummary _validationFileSummary = null; - - #endregion - - #region Messages - - private string _uploadButtonText = Resources.UploadButtonText; - private string _validationFileErrorText = Resources.ValidationFileErrorText; - - #endregion - - #endregion - - #region Properties - - #region Messages - - /// - /// Error message displayed if the file provided is invalid. - /// - public string ValidationFileErrorText - { - get - { - return _validationFileErrorText; - } - set - { - _validationFileErrorText = value; - } - } - - /// - /// Text used on the upload file button. - /// - public string UploadButtonText - { - get - { - return _uploadButtonText; - } - set - { - _uploadButtonText = value; - } - } - - #endregion - - #endregion - - #region Event Handlers - - /// - /// Fired when the upload has completed. Used to inform other - /// controls the result of the upload. - /// - public event UploadEventHandler UploadComplete; - - #endregion - - #region Events - - /// - /// Initialises the child controls in the upload control. - /// - /// - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - // Create the controls. - _validatorFile = new CustomValidator(); - _buttonUpload = new Button(); - _fileUploadData = new FileUpload(); - _validationFileSummary = new ValidationSummary(); - - // Set the new controls properties. - _buttonUpload.ID = "ButtonUpload"; - _buttonUpload.Click += new EventHandler(_buttonUpload_Click); - _buttonUpload.ValidationGroup = VALIDATION_UPLOAD; - _fileUploadData.ID = "FileUpload"; - - // Set the validators. - _validatorFile.ID = "ValidatorFile"; - _validationFileSummary.Style.Clear(); - _validationFileSummary.ValidationGroup = VALIDATION_UPLOAD; - _validatorFile.ValidationGroup = VALIDATION_UPLOAD; - _validatorFile.ControlToValidate = _fileUploadData.ID; - _validatorFile.ValidateEmptyText = true; - _validatorFile.ServerValidate += new ServerValidateEventHandler(_validationFile_ServerValidate); - _validationFileSummary.ID = "ValidationFileSummary"; - _validationFileSummary.DisplayMode = ValidationSummaryDisplayMode.SingleParagraph; - _validatorFile.Display = ValidatorDisplay.None; - _validationFileSummary.EnableClientScript = true; - - // Add the controls to the user control. - _container.Controls.Add(_validationFileSummary); - _container.Controls.Add(_fileUploadData); - _container.Controls.Add(_buttonUpload); - } - - /// - /// Sets the visible status of the instruction messages. - /// - /// - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - _buttonUpload.Text = UploadButtonText; - _buttonUpload.CssClass = ButtonCssClass; - _validationFileSummary.CssClass = ErrorCssClass; - _validatorFile.ErrorMessage = ValidationFileErrorText; - } - - /// - /// Fired when the upload is completed. - /// - /// - /// - private void _buttonUpload_Click(object sender, EventArgs e) - { - if (Page.IsValid) - { - ActivityResult result = Execute(_fileUploadData.PostedFile.InputStream); - if (UploadComplete != null) - UploadComplete(this, result); - } - } - - /// - /// Validates a file has been selected. - /// - /// - /// - private void _validationFile_ServerValidate(object source, ServerValidateEventArgs args) - { - args.IsValid = _fileUploadData.HasFile; - } - - #endregion - } -} diff --git a/Foundation/UI/Web/UserAgentTester.cs b/Foundation/UI/Web/UserAgentTester.cs deleted file mode 100644 index f74804b..0000000 --- a/Foundation/UI/Web/UserAgentTester.cs +++ /dev/null @@ -1,126 +0,0 @@ -/* ********************************************************************* - * 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 System; -using System.Web.UI.WebControls; -using FiftyOne.Foundation.Mobile.Detection; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Class to test a user agent and display the resulting device. - /// - public class UserAgentTester : BaseUserControl - { - #region Fields - - private Literal _instructions; - private TextBox _textBoxUserAgent; - private Button _buttonTest; - private DeviceExplorer _deviceExplorer; - - private string _textBoxCssClass = "textbox"; - private string _buttonCssClass = "button"; - private string _userAgentTesterButton = Resources.UserAgentTesterButtonText; - private string _userAgentTesterInstructions = Resources.UserAgentTesterInstructions; - - #endregion - - #region Properties - - /// - /// Gets or sets the text box css class for licence key entry. - /// - public string TextBoxCssClass - { - get { return _textBoxCssClass; } - set { _textBoxCssClass = value; } - } - - /// - /// Gets or sets the button css class for activation and refresh. - /// - public string ButtonCssClass - { - get { return _buttonCssClass; } - set { _buttonCssClass = value; } - } - - /// - /// Instruction text to use with the control. - /// - public string UserAgentTesterInstructions - { - get { return _userAgentTesterInstructions; } - set { _userAgentTesterInstructions = value; } - } - - /// - /// Button text to use with the control. - /// - public string UserAgentTesterButton - { - get { return _userAgentTesterButton; } - set { _userAgentTesterButton = value; } - } - - #endregion - - #region Events - - /// - /// Creates the new controls used by the user agent tester. - /// - /// - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - _instructions = new Literal(); - _textBoxUserAgent = new TextBox(); - _buttonTest = new Button(); - _deviceExplorer = new DeviceExplorer(); - _textBoxUserAgent.MaxLength = 800; - _buttonTest.Click += new EventHandler(ButtonTest_Click); - _deviceExplorer.Navigation = false; - _deviceExplorer.FooterEnabled = false; - _deviceExplorer.LogoEnabled = false; - _container.Controls.Add(_deviceExplorer); - _container.Controls.Add(_instructions); - _container.Controls.Add(_textBoxUserAgent); - _container.Controls.Add(_buttonTest); - _textBoxUserAgent.Text = Request.UserAgent; - } - - /// - /// Controls if the device explorer is visible. - /// - /// - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - _deviceExplorer.Visible = - _deviceExplorer.DeviceID != null || - String.IsNullOrEmpty(_deviceExplorer.UserAgent) == false; - _textBoxUserAgent.CssClass = TextBoxCssClass; - _buttonTest.CssClass = ButtonCssClass; - _instructions.Text = UserAgentTesterInstructions; - _buttonTest.Text = UserAgentTesterButton; - _container.DefaultButton = _buttonTest.UniqueID; - } - - private void ButtonTest_Click(object sender, EventArgs e) - { - _deviceExplorer.UserAgent = _textBoxUserAgent.Text; - } - - #endregion - } -} diff --git a/Foundation/UI/Web/VendorTemplate.cs b/Foundation/UI/Web/VendorTemplate.cs deleted file mode 100644 index 1da4bf6..0000000 --- a/Foundation/UI/Web/VendorTemplate.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Web.UI; -using System.Web.UI.WebControls; - -namespace FiftyOne.Foundation.UI.Web -{ - /// - /// Template used to display a vendor from the data set. - /// - public class VendorTemplate : ITemplate - { - /// - /// Adds requirement controls to the container. - /// - /// Container the template is being displayed in. - public void InstantiateIn(Control container) - { - Panel panel = new Panel(); - Literal open = new Literal(); - Literal close = new Literal(); - HyperLink vendorLink = new HyperLink(); - Label countLabel = new Label(); - - vendorLink.ID = "Vendor"; - countLabel.ID = "Count"; - panel.ID = "Panel"; - - open.Text = " ("; - close.Text = ")"; - - panel.Controls.Add(vendorLink); - panel.Controls.Add(open); - panel.Controls.Add(countLabel); - panel.Controls.Add(close); - - container.Controls.Add(panel); - } - } -} diff --git a/Foundation/app.config b/Foundation/app.config deleted file mode 100644 index 89dc7d4..0000000 --- a/Foundation/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - -