コード例 #1
0
        // Token: 0x06001332 RID: 4914 RVA: 0x000771CC File Offset: 0x000753CC
        internal static void LookupExperiencesForRequest(OwaContext owaContext, bool isOptimizedForAccessibility, bool isRichClientFeatureEnabled, out BrowserType browserType, out UserAgentParser.UserAgentVersion browserVersion, out Experience[] experiences)
        {
            string application = string.Empty;
            string empty       = string.Empty;

            browserType    = BrowserType.Other;
            browserVersion = default(UserAgentParser.UserAgentVersion);
            if (isOptimizedForAccessibility || RequestDispatcherUtilities.ShouldDoBasicRegistryLookup(owaContext))
            {
                UserAgentParser.Parse(string.Empty, out application, out browserVersion, out empty);
            }
            else
            {
                UserAgentParser.Parse(owaContext.HttpContext.Request.UserAgent, out application, out browserVersion, out empty);
            }
            browserType = Utilities.GetBrowserType(owaContext.HttpContext.Request.UserAgent);
            if (browserType == BrowserType.Other)
            {
                application    = "Safari";
                browserVersion = new UserAgentParser.UserAgentVersion(3, 0, 0);
                empty          = string.Empty;
                browserType    = BrowserType.Safari;
            }
            experiences = FormsRegistryManager.LookupExperiences(application, browserVersion, empty, ClientControl.None, isRichClientFeatureEnabled);
        }
コード例 #2
0
 // Token: 0x060007DE RID: 2014 RVA: 0x0003B0A8 File Offset: 0x000392A8
 internal ClientMapping(string application, UserAgentParser.UserAgentVersion minimumVersion, string platform, ClientControl control, Experience experience)
 {
     this.application    = application;
     this.minimumVersion = minimumVersion;
     this.platform       = platform;
     this.control        = control;
     this.experience     = experience;
 }
コード例 #3
0
        public static Experience[] LookupExperiences(string application, UserAgentParser.UserAgentVersion version, string platform, ClientControl control, bool isRichClientFeatureOn)
        {
            ExTraceGlobals.FormsRegistryCallTracer.TraceDebug(0L, "FormsRegistryManager.LookupExperiences application = {0}, version = {1}, platform = {2}, control = {3}", new object[]
            {
                application,
                version,
                platform,
                control
            });
            int num;
            int num2;

            if (!FormsRegistryManager.baseExperienceClientMappingList.FindMatchingRange(application, platform, control, version, out num, out num2))
            {
                return(null);
            }
            FormsRegistry formsRegistry = null;

            if (isRichClientFeatureOn)
            {
                formsRegistry = FormsRegistryManager.baseExperienceClientMappingList[num2].Experience.FormsRegistry;
            }
            else
            {
                for (int i = num2; i >= num; i--)
                {
                    formsRegistry = FormsRegistryManager.baseExperienceClientMappingList[i].Experience.FormsRegistry;
                    if (!formsRegistry.IsRichClient)
                    {
                        break;
                    }
                    formsRegistry = null;
                }
                if (formsRegistry == null)
                {
                    return(null);
                }
            }
            ExTraceGlobals.FormsRegistryDataTracer.TraceDebug <string>(0L, "Matched registry = {0}", formsRegistry.Name);
            return(formsRegistry.LookupExperiences(application, version, platform, control));
        }
コード例 #4
0
        private ClientMapping ParseClientMapping()
        {
            ExTraceGlobals.FormsRegistryCallTracer.TraceDebug((long)this.GetHashCode(), "FormsRegistryParser.ParseClientMapping");
            ClientMapping clientMapping = new ClientMapping();

            UserAgentParser.UserAgentVersion minimumVersion = default(UserAgentParser.UserAgentVersion);
            if (this.reader.MoveToAttribute(FormsRegistryParser.nameTableValues[7]))
            {
                clientMapping.Application = this.reader.Value;
            }
            if (this.reader.MoveToAttribute(FormsRegistryParser.nameTableValues[9]))
            {
                clientMapping.Platform = this.reader.Value;
            }
            if (this.reader.MoveToAttribute(FormsRegistryParser.nameTableValues[8]))
            {
                try
                {
                    minimumVersion = new UserAgentParser.UserAgentVersion(this.reader.Value);
                }
                catch (ArgumentException)
                {
                    this.ThrowParserException(string.Format(CultureInfo.InvariantCulture, "Unable to parse MinimumVersion attribute value = {0}", new object[]
                    {
                        this.reader.Value
                    }), ClientsEventLogConstants.Tuple_FormsRegistryInvalidMinimumVersion, new object[]
                    {
                        this.registryFile,
                        this.reader.LineNumber.ToString(CultureInfo.InvariantCulture),
                        this.reader.LinePosition.ToString(CultureInfo.InvariantCulture),
                        this.reader.Value
                    });
                }
            }
            clientMapping.MinimumVersion = minimumVersion;
            if (this.reader.MoveToAttribute(FormsRegistryParser.nameTableValues[10]))
            {
                object obj = FormsRegistry.ClientControlParser.Parse(this.reader.Value);
                if (obj == null)
                {
                    try
                    {
                        minimumVersion = new UserAgentParser.UserAgentVersion(this.reader.Value);
                    }
                    catch (ArgumentException)
                    {
                        this.ThrowParserException(string.Format(CultureInfo.InvariantCulture, "Invalid ClientControl: {0}", new object[]
                        {
                            this.reader.Value
                        }), ClientsEventLogConstants.Tuple_FormsRegistryInvalidClientControl, new object[]
                        {
                            this.registryFile,
                            this.reader.LineNumber.ToString(CultureInfo.InvariantCulture),
                            this.reader.LinePosition.ToString(CultureInfo.InvariantCulture),
                            this.reader.Value
                        });
                    }
                }
                clientMapping.Control = (ClientControl)obj;
            }
            return(clientMapping);
        }
コード例 #5
0
        // Token: 0x06000988 RID: 2440 RVA: 0x0004348C File Offset: 0x0004168C
        public Experience[] LookupExperiences(string application, UserAgentParser.UserAgentVersion version, string platform, ClientControl control)
        {
            ExTraceGlobals.FormsRegistryCallTracer.TraceDebug((long)this.GetHashCode(), "FormsRegistry.LookupExperiences application = {0}, version = {1}, platform = {2}, control = {3}", new object[]
            {
                application,
                version,
                platform,
                control
            });
            Hashtable hashtable = new Hashtable(1);
            ArrayList arrayList = new ArrayList(1);

            FormsRegistry.LookupExperienceState lookupExperienceState = FormsRegistry.LookupExperienceState.ExactMatch;
            while (FormsRegistry.LookupExperienceState.Done != lookupExperienceState)
            {
                switch (lookupExperienceState)
                {
                case FormsRegistry.LookupExperienceState.ExactMatch:
                    lookupExperienceState = FormsRegistry.LookupExperienceState.Control;
                    break;

                case FormsRegistry.LookupExperienceState.Control:
                    lookupExperienceState = FormsRegistry.LookupExperienceState.Platform;
                    if (control == ClientControl.None)
                    {
                        continue;
                    }
                    control = ClientControl.None;
                    break;

                case FormsRegistry.LookupExperienceState.Platform:
                    lookupExperienceState = FormsRegistry.LookupExperienceState.Application;
                    platform = string.Empty;
                    break;

                case FormsRegistry.LookupExperienceState.Application:
                    lookupExperienceState = FormsRegistry.LookupExperienceState.Done;
                    application           = string.Empty;
                    break;
                }
                int i;
                int num;
                if (this.clientMappingList.FindMatchingRange(application, platform, control, version, out i, out num))
                {
                    while (i <= num)
                    {
                        ClientMapping clientMapping = this.clientMappingList[num];
                        Experience    experience    = clientMapping.Experience;
                        if (!hashtable.ContainsKey(experience))
                        {
                            ExTraceGlobals.FormsRegistryDataTracer.TraceDebug <string, ClientMapping>((long)this.GetHashCode(), "Matched experience. name = {0}, client mapping = ({1})", experience.Name, clientMapping);
                            hashtable.Add(experience, string.Empty);
                            arrayList.Add(experience);
                        }
                        num--;
                    }
                }
            }
            ExTraceGlobals.FormsRegistryTracer.TraceDebug <int>((long)this.GetHashCode(), "FormsRegistry.LookupExperiences - Exit.  Matched {0} Experiences", arrayList.Count);
            return((Experience[])arrayList.ToArray(typeof(Experience)));
        }
コード例 #6
0
        // Token: 0x0600005E RID: 94 RVA: 0x00003954 File Offset: 0x00001B54
        internal static void Parse(string userAgent, out string application, out UserAgentParser.UserAgentVersion version, out string platform)
        {
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "Globals.ParseUserAgent. user-agent = {0}", (userAgent != null) ? userAgent : "<null>");
            }
            application = string.Empty;
            version     = default(UserAgentParser.UserAgentVersion);
            platform    = string.Empty;
            if (userAgent == null || userAgent.Length == 0)
            {
                return;
            }
            int num = int.MinValue;
            int i;

            for (i = 0; i < UserAgentParser.clientApplication.Length; i++)
            {
                if (-1 != (num = userAgent.IndexOf(UserAgentParser.clientApplication[i], StringComparison.OrdinalIgnoreCase)))
                {
                    if (string.Equals(UserAgentParser.clientApplication[i], "Safari", StringComparison.OrdinalIgnoreCase))
                    {
                        if (-1 != userAgent.IndexOf("Chrome", StringComparison.OrdinalIgnoreCase))
                        {
                            goto IL_BC;
                        }
                    }
                    else if (string.Equals(UserAgentParser.clientApplication[i], UserAgentParser.ie11ApplicationName, StringComparison.OrdinalIgnoreCase) && -1 == userAgent.IndexOf(UserAgentParser.ie11ExtraCheck, StringComparison.OrdinalIgnoreCase))
                    {
                        goto IL_BC;
                    }
                    application = UserAgentParser.clientApplication[i];
                    break;
                }
                IL_BC :;
            }
            if (i == UserAgentParser.clientApplication.Length)
            {
                return;
            }
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "Parsed out application = {0}", application);
            }
            int num2 = -1;

            if (string.Equals(application, "MSIE", StringComparison.Ordinal) || string.Equals(application, "Firefox", StringComparison.Ordinal) || string.Equals(application, "Chrome", StringComparison.Ordinal))
            {
                num += application.Length + 1;
            }
            else if (string.Equals(application, "Safari", StringComparison.Ordinal))
            {
                string text = "Version/";
                num = userAgent.IndexOf(text) + text.Length;
            }
            else
            {
                if (!string.Equals(application, UserAgentParser.ie11ApplicationName, StringComparison.Ordinal))
                {
                    return;
                }
                num += application.Length;
            }
            int j;

            for (j = num; j < userAgent.Length; j++)
            {
                if (!char.IsDigit(userAgent, j) && userAgent[j] != '.')
                {
                    num2 = j;
                    break;
                }
            }
            if (num2 == -1)
            {
                num2 = userAgent.Length;
            }
            if (j == num)
            {
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug(0L, "Unable to parse browser version.  Could not find semicolon");
                }
                return;
            }
            string text2 = userAgent.Substring(num, num2 - num);

            try
            {
                version = new UserAgentParser.UserAgentVersion(text2);
            }
            catch (ArgumentException)
            {
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "TryParse failed, unable to parse browser version = {0}", text2);
                }
                return;
            }
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "Parsed out version = {0}", version.ToString());
            }
            for (i = 0; i < UserAgentParser.clientPlatform.Length; i++)
            {
                if (-1 != userAgent.IndexOf(UserAgentParser.clientPlatform[i], StringComparison.OrdinalIgnoreCase))
                {
                    platform = UserAgentParser.clientPlatform[i];
                    break;
                }
            }
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "Parsed out platform = {0}", platform);
            }
        }
コード例 #7
0
 internal bool FindMatchingRange(string application, string platform, ClientControl control, UserAgentParser.UserAgentVersion minVersion, out int firstMatch, out int lastMatch)
 {
     firstMatch = 0;
     lastMatch  = this.Count - 1;
     if (this.Count == 0)
     {
         return(false);
     }
     ClientMappingList.MatchingParameters parameters = new ClientMappingList.MatchingParameters(application, platform, control, minVersion);
     for (ClientMappingList.ClientAttribute clientAttribute = ClientMappingList.ClientAttribute.First; clientAttribute < ClientMappingList.ClientAttribute.Last; clientAttribute++)
     {
         if (!this.MatchClientAttribute(ref firstMatch, ref lastMatch, clientAttribute, parameters))
         {
             return(false);
         }
     }
     return(this.MatchClientMinimumVersion(firstMatch, ref lastMatch, parameters));
 }
コード例 #8
0
 public MatchingParameters(string application, string platform, ClientControl control, UserAgentParser.UserAgentVersion version)
 {
     this.Application = application;
     this.Platform    = platform;
     this.Control     = control;
     this.Version     = version;
 }