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); }
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); }