int IComparer.Compare(object x, object y)
        {
            ClientMapping clientMapping  = x as ClientMapping;
            ClientMapping clientMapping2 = y as ClientMapping;

            ExTraceGlobals.FormsRegistryDataTracer.TraceDebug <ClientMapping, ClientMapping>((long)this.GetHashCode(), "ClientMappingComparer::Compare. a = {0}, b = {1}", clientMapping, clientMapping2);
            if (clientMapping == null && clientMapping2 == null)
            {
                return(0);
            }
            if (clientMapping == null)
            {
                return(-1);
            }
            if (clientMapping2 == null)
            {
                return(1);
            }
            int num = string.Compare(clientMapping.Application, clientMapping2.Application, StringComparison.Ordinal);

            if (num != 0)
            {
                return(num);
            }
            num = string.Compare(clientMapping.Platform, clientMapping2.Platform, StringComparison.Ordinal);
            if (num != 0)
            {
                return(num);
            }
            num = clientMapping.Control - clientMapping2.Control;
            if (num != 0)
            {
                return(num);
            }
            double num2 = (double)clientMapping.MinimumVersion.CompareTo(clientMapping2.MinimumVersion);

            if (num2 != 0.0)
            {
                if (num2 <= 0.0)
                {
                    return(-1);
                }
                return(1);
            }
            else
            {
                FormsRegistry formsRegistry  = clientMapping.Experience.FormsRegistry;
                FormsRegistry formsRegistry2 = clientMapping2.Experience.FormsRegistry;
                if (this.IsParentRegistry(formsRegistry, formsRegistry2))
                {
                    return(1);
                }
                if (this.IsParentRegistry(formsRegistry2, formsRegistry))
                {
                    return(-1);
                }
                return(0);
            }
        }
Пример #2
0
        private ArrayList ParseExperience()
        {
            ExTraceGlobals.FormsRegistryCallTracer.TraceDebug((long)this.GetHashCode(), "FormsRegistryParser.ParseExperience");
            ArrayList arrayList = new ArrayList();
            bool      flag      = false;
            string    text      = string.Empty;

            if (!this.reader.MoveToAttribute(FormsRegistryParser.nameTableValues[1]))
            {
                this.ThrowExpectedAttributeException(FormsRegistryParser.NameTableValues.Name);
            }
            text = this.reader.Value;
            ExTraceGlobals.FormsRegistryDataTracer.TraceDebug <string>((long)this.GetHashCode(), "experience = {0}", text);
            bool flag2 = this.registry.BaseExperience == text;

            while (!flag && this.reader.Read())
            {
                XmlNodeType nodeType = this.reader.NodeType;
                if (nodeType != XmlNodeType.Element)
                {
                    if (nodeType == XmlNodeType.EndElement)
                    {
                        if (this.reader.Name == FormsRegistryParser.nameTableValues[5])
                        {
                            flag = true;
                        }
                    }
                }
                else if (this.reader.Name == FormsRegistryParser.nameTableValues[6])
                {
                    ClientMapping clientMapping = this.ParseClientMapping();
                    clientMapping.Experience = new Experience(text, this.registry);
                    ExTraceGlobals.FormsRegistryDataTracer.TraceDebug <ClientMapping>((long)this.GetHashCode(), "Parsed ClientMapping - {0}", clientMapping);
                    arrayList.Add(clientMapping);
                    if (flag2)
                    {
                        this.baseClientMappings.Add(clientMapping);
                    }
                }
                else if (this.reader.Name == FormsRegistryParser.nameTableValues[11])
                {
                    this.ParseApplicationElement(text);
                }
                else
                {
                    this.ThrowParserException("Expected Client or ApplicationElement element", ClientsEventLogConstants.Tuple_FormsRegistryExpectedClientOrApplicationElement, new object[]
                    {
                        this.registryFile,
                        this.reader.LineNumber.ToString(CultureInfo.InvariantCulture),
                        this.reader.LinePosition.ToString(CultureInfo.InvariantCulture)
                    });
                }
            }
            return(arrayList);
        }
 // Token: 0x060007DF RID: 2015 RVA: 0x0003B0F8 File Offset: 0x000392F8
 internal static ClientMapping Copy(ClientMapping clientMapping)
 {
     return(new ClientMapping
     {
         application = string.Copy(clientMapping.Application),
         minimumVersion = clientMapping.MinimumVersion,
         platform = clientMapping.Platform,
         control = clientMapping.Control,
         experience = Experience.Copy(clientMapping.Experience)
     });
 }
Пример #4
0
        public void LoadRegistries(string directory)
        {
            ExTraceGlobals.FormsRegistryCallTracer.TraceDebug <string>((long)this.GetHashCode(), "FormsRegistryLoader.LoadRegistries directory = {0}", directory);
            Hashtable hashtable  = new Hashtable();
            Hashtable hashtable2 = new Hashtable();

            if (!Directory.Exists(directory))
            {
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_FormsFolderNotFound, string.Empty, new object[]
                {
                    directory
                });
                throw new OwaInvalidInputException("Forms directory not found", null, this);
            }
            foreach (string text in Directory.GetDirectories(directory))
            {
                string text2 = Path.Combine(text, "registry.xml").Replace('/', '\\');
                if (!File.Exists(text2))
                {
                    ExTraceGlobals.FormsRegistryDataTracer.TraceDebug <string>((long)this.GetHashCode(), "Registry file not found. file = {0}", text2);
                }
                else
                {
                    int num = text.LastIndexOf('\\');
                    if (num >= 0)
                    {
                        text = text.Substring(num + 1);
                    }
                    FormsRegistryParser formsRegistryParser = new FormsRegistryParser();
                    try
                    {
                        formsRegistryParser.Load(text2, text);
                    }
                    catch (Exception)
                    {
                        if (formsRegistryParser.Registry.IsCustomRegistry)
                        {
                            goto IL_251;
                        }
                        throw;
                    }
                    if (this.registries.ContainsKey(formsRegistryParser.Registry.Name))
                    {
                        OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_FormsRegistryReDefinition, string.Empty, new object[]
                        {
                            formsRegistryParser.Registry.Name
                        });
                        if (formsRegistryParser.Registry.IsCustomRegistry)
                        {
                            goto IL_251;
                        }
                        if (!((FormsRegistry)this.registries[formsRegistryParser.Registry.Name]).IsCustomRegistry)
                        {
                            throw new OwaInvalidInputException(string.Format("Duplicate registry found ('{0}')", formsRegistryParser.Registry.Name), null, this);
                        }
                        this.registries.Remove(formsRegistryParser.Registry.Name);
                        hashtable.Remove(formsRegistryParser.Registry.Name);
                        hashtable2.Remove(formsRegistryParser.Registry.Name);
                        this.loadedCustomRegistryFiles.Remove(formsRegistryParser.Registry.Name);
                    }
                    if (formsRegistryParser.Registry.HasCustomForm)
                    {
                        this.loadedCustomRegistryFiles.Add(formsRegistryParser.Registry.Name, text2);
                    }
                    this.registries.Add(formsRegistryParser.Registry.Name, formsRegistryParser.Registry);
                    hashtable.Add(formsRegistryParser.Registry.Name, formsRegistryParser.ClientMappings);
                    hashtable2.Add(formsRegistryParser.Registry.Name, formsRegistryParser.BaseClientMappings);
                }
                IL_251 :;
            }
            if (this.loadedCustomRegistryFiles.Count > 0)
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (object obj in this.loadedCustomRegistryFiles.Values)
                {
                    string value = (string)obj;
                    stringBuilder.AppendLine(value);
                }
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_CustomizationFormsRegistryLoadSuccessfully, string.Empty, new object[]
                {
                    stringBuilder.ToString()
                });
            }
            IDictionaryEnumerator enumerator2 = this.registries.GetEnumerator();

            while (enumerator2.MoveNext())
            {
                FormsRegistry formsRegistry = (FormsRegistry)enumerator2.Value;
                ArrayList     arrayList     = (ArrayList)hashtable[formsRegistry.Name];
                if (formsRegistry.InheritsFrom.Length > 0)
                {
                    FormsRegistry formsRegistry2 = formsRegistry;
                    while (formsRegistry2.InheritsFrom.Length > 0)
                    {
                        if (!this.registries.ContainsKey(formsRegistry.InheritsFrom))
                        {
                            OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_FormsRegistryNotFound, string.Empty, new object[]
                            {
                                formsRegistry.Name,
                                formsRegistry.InheritsFrom
                            });
                            throw new OwaInvalidInputException(string.Format("Forms registry {0} inherits forms registry {1} that could not be found", formsRegistry.Name, formsRegistry.InheritsFrom), null, this);
                        }
                        formsRegistry2 = (FormsRegistry)this.registries[formsRegistry2.InheritsFrom];
                        arrayList.AddRange((ArrayList)hashtable[formsRegistry2.Name]);
                    }
                    ArrayList arrayList2 = (ArrayList)hashtable2[formsRegistry2.Name];
                    for (int j = 0; j < arrayList2.Count; j++)
                    {
                        ClientMapping clientMapping = ClientMapping.Copy((ClientMapping)arrayList2[j]);
                        ExTraceGlobals.FormsRegistryDataTracer.TraceDebug <ClientMapping>((long)this.GetHashCode(), "Copied client mapping form inherited registry. ClientMapping = {0}", clientMapping);
                        clientMapping.Experience.FormsRegistry = formsRegistry;
                        this.baseExperienceClientMappings.Add(clientMapping);
                    }
                }
                else
                {
                    int k;
                    for (k = 0; k < arrayList.Count; k++)
                    {
                        ClientMapping clientMapping2 = (ClientMapping)arrayList[k];
                        if (formsRegistry.BaseExperience == clientMapping2.Experience.Name)
                        {
                            ExTraceGlobals.FormsRegistryTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Registry '{0}' Verified existence of base experience '{1}'", formsRegistry.Name, formsRegistry.BaseExperience);
                            break;
                        }
                    }
                    if (k == arrayList.Count)
                    {
                        OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_FormsRegistryMissingBaseExperience, string.Empty, new object[]
                        {
                            formsRegistry.Name,
                            formsRegistry.BaseExperience
                        });
                        throw new OwaInvalidInputException(string.Format("Registry {0} does not define the specified base experience named {1}", formsRegistry.Name, formsRegistry.BaseExperience), null, this);
                    }
                    ArrayList c = (ArrayList)hashtable2[formsRegistry.Name];
                    this.baseExperienceClientMappings.AddRange(c);
                }
                arrayList.Sort(new ClientMappingComparer(this.Registries));
                formsRegistry.ClientMappingList = new ClientMappingList((ClientMapping[])arrayList.ToArray(typeof(ClientMapping)));
            }
            ExTraceGlobals.FormsRegistryDataTracer.TraceDebug <int>((long)this.GetHashCode(), "Total client mappings for all base experiences: {0}", this.baseExperienceClientMappings.Count);
            this.baseExperienceClientMappings.Sort(new ClientMappingComparer(this.Registries));
        }
Пример #5
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);
        }
Пример #6
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)));
        }