当前位置: 首页 > news >正文

w3c网站模板做网站每年包多少流量

w3c网站模板,做网站每年包多少流量,如何制作网站板块,网站如何做ssl认证最近在将原有代码迁移.NET Core, 代码的迁移基本很快#xff0c;当然也遇到了不少坑#xff0c;重构了不少#xff0c;后续逐步总结分享给大家。今天总结分享一下ConfigurationManager遇到的一个问题。先说一下场景#xff1a;迁移.NET Core后#xff0c;已有的配置文件当然也遇到了不少坑重构了不少后续逐步总结分享给大家。今天总结分享一下ConfigurationManager遇到的一个问题。先说一下场景   迁移.NET Core后已有的配置文件我们希望做到兼容比如说app.config和web.config,   这样配置文件尽可能地和.NET Framework是一套尽可能低保持一致。比如appSettings、自定义configSection等等。?xml version1.0 encodingutf-8 ?configuration  configSections    strongsection/strong nameCustomConfigs typeClassLibraryNetStandard.CustomConfigHandler, ClassLibraryNetStandard/  /configSections  strongCustomConfigs/strong    CustomConfig nameservice1 order0 reflectconfigClassLibraryNetStandard.TestService, ClassLibraryNetStandard/    CustomConfig nameservice2 order1 reflectconfigClassLibraryNetStandard.TestService2, ClassLibraryNetStandard/  /CustomConfigs   strongappSettings/strong    add keyservice valueservice1/  /appSettings/configuration 对于上面配置读取我们做了以下几个事情   1. 添加NugetSystem.Configuration.ConfigurationManager   2. 保证原有自定义Section配置相关的代码、读取配置的代码迁移到.NET Core后编译通过   3. 修改配置文件、单元测试 一、添加NugetSystem.Configuration.ConfigurationManager   搜索System.Configuration.ConfigurationManager找到Nuget包并添加引用   二、保证原有自定义Section配置相关的代码、读取配置的代码迁移到.NET Core后编译通过  示例代码中自定义配置类CustomConfigusing System;using System.Collections.Generic;using System.Text;namespace ClassLibraryNetStandard{    public class CustomConfig    {        public string Name { get; set; }        public string ReflectConfig { get; set; }        public int Order { get; set; }    }}  同时对应的Section配置节解析类CustomConfigHandler实现接口System.Configuration.IConfigurationSectionHandlerusing System;using System.Collections.Generic;using System.Text;using System.Xml;namespace ClassLibraryNetStandard{   public class CustomConfigHandler : System.Configuration.IConfigurationSectionHandler    {        public object Create(object parent, object configContext, XmlNode section)        {            var configs  new ListCustomConfig();            foreach (XmlNode childNode in section.ChildNodes)            {                string name  null;                var config  new CustomConfig();                if (childNode.Attributes[name] ! null)                {                    name childNode.Attributes[name].Value;                    config.Name name;                    if (childNode.Attributes[order] ! null)                    {                        config.Order Convert.ToInt32(childNode.Attributes[order].Value);                    }                    if (childNode.Attributes[reflectconfig] ! null)                    {                        config.ReflectConfig childNode.Attributes[reflectconfig].Value;                    }                                     configs.Add(config);                }            }            return configs;        }    }}    同时我们编写了一个简单的配置管理类CustomConfigManager其中有配置读取方法直接读取配置文件1public static ListCustomConfig GetCustomConfigs(){    var sectionConfig System.Configuration.ConfigurationManager.GetSection(CustomConfigs);    if (sectionConfig ! null)    {        return  sectionConfig as ListCustomConfig;    }    return null;}  这里我们使用了.NET Standard 2.0 library project代码编译通过1------ 已启动全部重新生成: 项目: ClassLibraryNetStandard, 配置: Debug Any CPU ------1C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: 你正在使用 .NET Core 的预览版。请查看 https://aka.ms/dotnet-core-preview1ClassLibraryNetStandard - C:\Users\***\source\repos\NETFrameworkTest\ClassLibraryNetStandard\bin\Debug\netstandard2.0\ClassLibraryNetStandard.dll 全部重新生成: 成功 1 个失败 0 个跳过 0 个    三、修改配置文件、单元测试  添加MSTest单元测试工程        增加App.config配置文件      在单元测试方法中测试配置的读取[TestMethod] public void ConfigTest() {     var configs ClassLibraryNetStandard.CustomConfigManager.GetCustomConfigs();     Assert.IsNotNull(configs); }  原本以为肯定可以获取到配置实际获取的configs是null。        换了个Console类的应用同样的配置文件读取一点没有问题            对比看了一下这两个工程发现除了实际编译生成的配置文件名称不同其他都一样。      问题肯定出在了单元测试工程上。Google了一下有以下发现       1MSTest is running as testhost.dll, which means that ConfigurationManager is reading settings from testhost.dll.config when executing under .NET core. brIt will look for testhost.dll.config where the testhost.dll is located as the accepted answer states. brWhat is not mentioned is that it will also look for testhost.dll.config in the location where you have your test dlls.  一句话MSTest以testhost.dll运行去取的配置文件是testhost.dll.config        这太尴尬了直接无语不过有两个解决方案        1. 直接在单元测试工程中将app.config文件改为testhost.dll.config        2. 修改单元测试工程文件配置编译后事件动态copy生成testhost.dll.config             试过之后果真可以了问题解决分享个大家。原文链接https://www.cnblogs.com/tianqing/p/11514840.html.NET社区新闻深度好文欢迎访问公众号文章汇总 http://www.csharpkit.com
http://wiki.neutronadmin.com/news/6911/

相关文章:

  • 西安网站开发定制制作专注昆明网站建设
  • 简述网站的设计流程是怎样的宣城网站seo诊断
  • 石家庄网站设计培训班网上开店电商平台有哪些
  • 建网站做点什么好百度云搜索引擎官方入口
  • 网站站点是什么科技资讯网站有哪些
  • 永春县住房和城乡规划建设局网站手机网站安全证书过期怎么处理
  • 海外域名注册网站重庆建网站流程
  • 兰州做网站泰兴公司做网站
  • 服装设计参考网站公司网站设计维护
  • wordpress最新主题百度整站优化
  • 房屋网站wordpress文档可以下载吗
  • 郑州网站建设用户广州住房保障城市建设局网站
  • 网站建设基础入门西安网站制作 西安彩铃400电话
  • 个人宽带备案网站wordpress考试系统
  • 非常好的网站建设公司网站建设的定位是什么意思
  • 网站建设为什么不清晰阿里云网站怎么备案域名
  • asp.net怎么生成网站龙华网站建设推广平台
  • 网站建设与制作教程下载做外贸网站服务器要选择哪里的
  • 门户网站如何帮企业做宣传曲靖网站微信建设
  • 唐山手机网站建设网站快备案
  • 域名之后怎么做网站网站手机采集
  • 分类网站上怎么做锚文本广东
  • 网站建设公司 信科便宜垂直购物网站建设
  • 成都网站搜索优化手游网页版
  • 网站建设企业排行培训机构专业
  • 邢台网站网页设计公司php网站模板怎么安装
  • 医生工作室网站建设建一个做笔记的网站
  • 北京市建设厅网站首页深圳网站建设app开发
  • 建设厅网站进不去中国机械加工网商城
  • 河南科技网站建设比亚迪新能源汽车报价大全一览表