private static Dictionary <string, ExtensionData> ReadDefaultExtensionData(IExchangePrincipal exchangePrincipal)
        {
            Dictionary <string, ExtensionData> dictionary = new Dictionary <string, ExtensionData>();
            string text = ExchangeSetupContext.InstallPath + "ClientAccess\\owa\\" + string.Format("\\prem\\{0}\\ext\\def\\", DefaultExtensionTable.GetInstalledOwaVersion());

            string[] array = null;
            try
            {
                if (!Directory.Exists(text))
                {
                    DefaultExtensionTable.Tracer.TraceError <string>(0L, "Default extension path {0} does not exist", text);
                    ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_DefaultExtensionPathNotExist, null, new object[]
                    {
                        DefaultExtensionTable.scenario
                    });
                    return(dictionary);
                }
                array = Directory.GetDirectories(text);
            }
            catch (Exception ex)
            {
                DefaultExtensionTable.Tracer.TraceError <Exception>(0L, "Failed to access default extension folder. ", ex);
                ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_DefaultExtensionFolderAccessFailed, ex.GetType().ToString(), new object[]
                {
                    DefaultExtensionTable.scenario,
                    ExtensionDiagnostics.GetLoggedExceptionString(ex)
                });
                return(dictionary);
            }
            foreach (string text2 in array)
            {
                try
                {
                    string path = text2 + "\\" + "manifest.xml";
                    if (File.Exists(path))
                    {
                        using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
                        {
                            ExtensionData extensionData = ExtensionData.ParseOsfManifest(fileStream, null, null, ExtensionType.Default, ExtensionInstallScope.Default, true, DisableReasonType.NotDisabled, string.Empty, null);
                            extensionData.ProvidedTo         = ClientExtensionProvidedTo.Everyone;
                            extensionData.IsMandatory        = false;
                            extensionData.IsEnabledByDefault = true;
                            extensionData.InstalledByVersion = ExchangeSetupContext.InstalledVersion;
                            if (exchangePrincipal != null)
                            {
                                Exception arg = null;
                                if (!DefaultExtensionTable.TryUpdateDefaultExtensionPath(exchangePrincipal, "SourceLocation", extensionData, out arg))
                                {
                                    DefaultExtensionTable.Tracer.TraceError <Exception>(0L, "Skip one default extension because entry point path cannot be updated: {0}", arg);
                                    goto IL_22D;
                                }
                                if (!DefaultExtensionTable.TryUpdateDefaultExtensionPath(exchangePrincipal, "IconUrl", extensionData, out arg))
                                {
                                    DefaultExtensionTable.Tracer.TraceError <Exception>(0L, "Skip one default extension because icon path cannot be updated: {0}", arg);
                                    goto IL_22D;
                                }
                                if (!DefaultExtensionTable.TryUpdateDefaultExtensionPath(exchangePrincipal, "HighResolutionIconUrl", extensionData, out arg))
                                {
                                    DefaultExtensionTable.Tracer.TraceError <Exception>(0L, "Skip one default extension because hi-res icon path cannot be updated: {0}", arg);
                                    goto IL_22D;
                                }
                            }
                            dictionary[ExtensionDataHelper.FormatExtensionId(extensionData.ExtensionId)] = extensionData;
                        }
                    }
                }
                catch (Exception ex2)
                {
                    DefaultExtensionTable.Tracer.TraceError <Exception>(0L, "Skip one default extension because of error. {0}", ex2);
                    ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_DefaultExtensionRetrievalFailed, text2, new object[]
                    {
                        DefaultExtensionTable.scenario,
                        text2,
                        ExtensionDiagnostics.GetLoggedExceptionString(ex2)
                    });
                }
                IL_22D :;
            }
            return(dictionary);
        }