コード例 #1
0
        private static void AddHookLayer()
        {
            var providerHelper = new ConfigurationProviderHelper();

            var layeredConfiguration = new LayeredConfigurationFiles();

            var configurationLayerProvider = layeredConfiguration.ConfigurationLayerProviders.FirstOrDefault();

            if (configurationLayerProvider != null && configurationLayerProvider.GetLayers().Any(l => l.Name == HookName))
            {
                return;
            }

            if (!(configurationLayerProvider is DefaultConfigurationLayerProvider defaultConfigurationLayerProvider))
            {
                return;
            }

            var ddApplicationLayer = new DefaultConfigurationLayer(HookName, $"{HookName}/App_Config/Include/");

            AddLayer("Foundation", ddApplicationLayer);
            AddLayer("Feature", ddApplicationLayer);
            AddLayer("Project", ddApplicationLayer);

            defaultConfigurationLayerProvider.AddLayer(ddApplicationLayer);
            providerHelper.SaveConfigurationProvider(configurationLayerProvider);
        }
コード例 #2
0
        private static void AddLayer(string layerName, DefaultConfigurationLayer ddApplicationLayer)
        {
            var configEntryInfo = new DefaultConfigurationLayer.ConfigEntryInfo
            {
                Path    = layerName,
                Type    = DefaultConfigurationLayer.ConfigEntryType.Folder,
                Enabled = true
            };

            ddApplicationLayer.LoadOrder.Add(configEntryInfo);
        }