html ConfigurationSection app.config web.config

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html ConfigurationSection app.config web.config相关的知识,希望对你有一定的参考价值。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  
    <section name="CustomAssemblySection" type="System.Configuration.NameValueSectionHandler"/>
    
  </configSections>
  
  <CustomAssemblySection>
    <add key="C:\Assemblies\DemoAssembly.dll" value="DemoAssembly" />
  </CustomAssemblySection>
  
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  
  <connectionStrings>
    <add name="dbDynamic" connectionString="data source=.\sqlexpress;initial catalog=dbDynamic;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

//Code:

 //var configSection = ConfigurationManager.GetSection("CustomAssemblySection") as NameValueCollection;
        //foreach (var customAssemblyKey in configSection.AllKeys)
        //{
        //    //Assembly assembly = Assembly.Load(customAssemblyKey);
        //    Assembly assembly = Assembly.LoadFrom(@"C:\Assemblies\DemoAssembly.dll");
        //    foreach (Type type in assembly.ExportedTypes)
        //    {
        //        if (type.IsClass)
        //        {
        //            MethodInfo method = modelBuilder.GetType().GetMethod("Entity");
        //            method = method.MakeGenericMethod(new Type[] { type });
        //            method.Invoke(modelBuilder, null);
        //        }
        //    }
        //}




以上是关于html ConfigurationSection app.config web.config的主要内容,如果未能解决你的问题,请参考以下文章

对比使用IConfigurationSectionHandler和ConfigurationSection自定义节点和自定义处理程序

如何在 ConfigurationSection 中包含简单集合

ConfigurationSection类使用心得

如何确定“ConfigurationElement”在“ConfigurationSection”自定义配置设置中可用

获取 ConfigurationSection 的初始 JSON 表示

如何获取 NameValueSectionHandler 类型的 ConfigurationSection 的值