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);
            }
        }
Ejemplo n.º 2
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));
        }
        private bool IsParentRegistry(FormsRegistry registry, FormsRegistry parentCandidate)
        {
            FormsRegistry formsRegistry = (FormsRegistry)this.registries[registry.InheritsFrom];

            while (formsRegistry != null)
            {
                if (string.Equals(formsRegistry.Name, parentCandidate.Name, StringComparison.Ordinal))
                {
                    return(true);
                }
                if (formsRegistry.InheritsFrom.Length != 0)
                {
                    formsRegistry = (FormsRegistry)this.registries[formsRegistry.InheritsFrom];
                }
                else
                {
                    formsRegistry = null;
                }
            }
            return(false);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 5
0
 internal Experience(string name, FormsRegistry formsRegistry)
 {
     this.name          = name;
     this.formsRegistry = formsRegistry;
 }