惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
D
Docker
云风的 BLOG
云风的 BLOG
F
Fortinet All Blogs
F
Full Disclosure
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
L
LangChain Blog
H
Help Net Security
B
Blog
T
Tailwind CSS Blog
V
V2EX
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
美团技术团队
A
About on SuperTechFans
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
I
InfoQ
Project Zero
Project Zero
I
Intezer
Google DeepMind News
Google DeepMind News
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Threat Research - Cisco Blogs
Last Week in AI
Last Week in AI
C
Cyber Attacks, Cyber Crime and Cyber Security
G
GRAHAM CLULEY
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AWS News Blog
AWS News Blog
Spread Privacy
Spread Privacy
S
Securelist
Recorded Future
Recorded Future
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 叶小钗
S
Security Affairs
Blog — PlanetScale
Blog — PlanetScale
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
The Hacker News
The Hacker News

博客园 - jayu

Windows 资源管理中 创建无文件名只有扩展名文件 CoreOS Hyper-V 安装 RancherOS Hyper-V 安装 MSSQL 2005 分页分析及优化 泛型类型的返回 招 .Net 网站程序员, Flash 程序员 上海盛大网络浩方在线招聘网站程序 ACS 20070412 TODO JSmarty ACS 20070108 更新 Alienwave.CommunityServer 20070103 更新 基于逻辑运算的简单权限系统(实现) JS 版 基于逻辑运算的简单权限系统(原理,设计,实现) VBS 版 ACS 社区系统演示地址 Python 2.5 发布 Visual Studio 2005 SDK version 3.0 道德沦丧 还是意识淡薄 Microsoft Expression Web Beta 1 《星际之剑》(Sword of the Stars)CLONE版
代码片段
jayu · 2011-02-24 · via 博客园 - jayu

经常会写一些测试用的片段 丢了又可惜 决定记下来

值类型检查

                 var list = new List<Type>()
                 {
                     typeof(Object),
                     typeof(DBNull),
                     typeof(Boolean),
                     typeof(Char),
                     typeof(SByte),
                     typeof(Byte),
                     typeof(Int16),
                     typeof(UInt16),
                     typeof(Int32),
                     typeof(UInt32),
                     typeof(Int64),
                     typeof(UInt64),
                     typeof(Single),
                     typeof(Double),
                     typeof(Decimal),
                     typeof(DateTime),
                     typeof(String),
                 };
                 foreach(var item in list)
                 {
                     WL("Type: {0}, IsValueType: {1}", item.Name, item.IsValueType);
                 }

 IIS 管理  C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll

创建 删除 修改 虚拟目录

        static void UpdateIIS(string[] args)
        {
            using (var serverManager = new ServerManager())
            {
#if !DEBUG
                if (args.Length != 3)
                {
                    Console.Write("参数不正确!");
                    return;
                }
#endif

                Configuration config = serverManager.GetApplicationHostConfiguration();
                ConfigurationSection sitesSection = config.GetSection("system.applicationHost/sites");
                ConfigurationElementCollection sitesCollection = sitesSection.GetCollection();
#if !DEBUG
                ConfigurationElement siteElement = FindElement(sitesCollection, "site", "name", args[0]);
#else
                ConfigurationElement siteElement = FindElement(sitesCollection, "site", "name", "LXT");
#endif
                if (siteElement == null)
                {
                    Console.WriteLine("IIS 未找到名为 {0} 的站点", args[0]);
                    return;
                }


                ConfigurationElementCollection siteCollection = siteElement.GetCollection();

#if !DEBUG
                Delete(siteCollection, args[1]);
                Create(siteCollection, args[1], args[2]);
#else
                Delete(siteCollection, "/HeadImages");
                Create(siteCollection, "/HeadImages", @"D:\Dev\IIS7");
#endif

                serverManager.CommitChanges();

            }
            Console.WriteLine("IIS 更新完成");
        }


        static ConfigurationElement FindElement(ConfigurationElementCollection collection, string elementTagName, params string[] keyValues)
        {
            foreach (ConfigurationElement element in collection)
            {
                if (String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase))
                {
                    bool matches = true;
                    for (int i = 0; i < keyValues.Length; i += 2)
                    {
                        object o = element.GetAttributeValue(keyValues[i]);
                        string value = null;
                        if (o != null)
                        {
                            value = o.ToString();
                        }
                        if (!String.Equals(value, keyValues[i + 1], StringComparison.OrdinalIgnoreCase))
                        {
                            matches = false;
                            break;
                        }
                    }
                    if (matches)
                    {
                        return element;
                    }
                }
            }
            return null;
        }

        static void Delete(ConfigurationElementCollection collection, string virtualDirectoryPath)
        {
            var oldApplication = collection.SingleOrDefault(e => e.Attributes["path"].Value.ToString() == "/");
            if (oldApplication == null) return;
            var virtualDirectorys = oldApplication.GetCollection();
            if (virtualDirectorys.Count == 1) return;
            var virtualDirectory = virtualDirectorys.SingleOrDefault(e => e.Attributes["path"].Value.ToString() == virtualDirectoryPath);
            if (virtualDirectory == null) return;
            virtualDirectorys.Remove(virtualDirectory);
            Console.WriteLine("IIS 删除 虚拟目录");
        }

        static void Create(ConfigurationElementCollection collection, string virtualDirectoryPath, string physicalPath)
        {

            var application = collection.SingleOrDefault(e => e.Attributes["path"].Value.ToString() == virtualDirectoryPath);
            if (application == null)
            {
                application = collection.CreateElement("application");
                application["path"] = virtualDirectoryPath;
                collection.Add(application);
            }
            application["applicationPool"] = "LXT";

            ConfigurationElementCollection virtualDirectorys = application.GetCollection();
            var virtualDirectory = virtualDirectorys.SingleOrDefault(e => e.Attributes["path"].Value.ToString() == "/");
            if (virtualDirectory == null)
            {
                virtualDirectory = virtualDirectorys.CreateElement("virtualDirectory");
                virtualDirectory["path"] = @"/";
                virtualDirectorys.Add(virtualDirectory);
                Console.WriteLine("IIS 创建 应用程序");
            }
            else
                Console.WriteLine("IIS 修改 应用程序");
            virtualDirectory["physicalPath"] = physicalPath;
        }