コード例 #1
0
            public static void Initialize(Resources resources)
            {
                resources.BuildinHandler = null;

                if (RuntimeInformation.IsUnittest &&
                    ConfigurationServices.ConfigurationSource?.GetSection(TypeManagerTypeHandlerSettings.SectionName) == null)
                {
                    resources.BuildinHandler = new BuildinTypeManagerTypeHandler();
                }
                else
                {
                    IConfigurationSource source = GetConfiguration();

                    TypeManagerTypeHandlerSettings settings = source.GetSection(TypeManagerTypeHandlerSettings.SectionName) as TypeManagerTypeHandlerSettings;

                    if (settings == null)
                    {
                        throw new ConfigurationErrorsException($"Failed to load the configuration section '{TypeManagerTypeHandlerSettings.SectionName}' from the configuration");
                    }

                    resources.ProviderNameList = new List <ProviderEntry>();

                    foreach (TypeManagerTypeHandlerData data in settings.TypeManagerTypeHandlerPlugins)
                    {
                        resources.ProviderNameList.Add(new ProviderEntry(data.Priority, data.Name));
                    }

                    resources.ProviderNameList.Sort((e1, e2) => e1.Priority - e2.Priority);
                }
            }
コード例 #2
0
ファイル: TypeManagerImpl.cs プロジェクト: wwl2013/C1-CMS
            public static void Initialize(Resources resources)
            {
                resources.BuildinHandler = null;

                if (RuntimeInformation.IsDebugBuild &&
                    (ConfigurationServices.ConfigurationSource == null ||
                     ConfigurationServices.ConfigurationSource.GetSection(TypeManagerTypeHandlerSettings.SectionName) == null))
                {
                    resources.BuildinHandler = new BuildinTypeManagerTypeHandler();
                }
                else
                {
                    IConfigurationSource source = GetConfiguration();

                    TypeManagerTypeHandlerSettings settings = source.GetSection(TypeManagerTypeHandlerSettings.SectionName) as TypeManagerTypeHandlerSettings;

                    if (settings == null)
                    {
                        throw new ConfigurationErrorsException(string.Format("Failed to load the configuration section '{0}' from the configuration", TypeManagerTypeHandlerSettings.SectionName));
                    }

                    resources.ProviderNameList = new List <ProviderEntry>();

                    foreach (TypeManagerTypeHandlerData data in settings.TypeManagerTypeHandlerPlugins)
                    {
                        resources.ProviderNameList.Add(new ProviderEntry(data.Priority, data.Name));
                    }

                    resources.ProviderNameList.Sort(delegate(ProviderEntry e1, ProviderEntry e2) { return(e1.Priority - e2.Priority); });
                }
            }