是否有可能重新使用密钥在Web.Config中? [英] Is it possible to reuse Keys in Web.Config?
本文介绍了是否有可能重新使用密钥在Web.Config中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想分享两个Web应用程序之间的文件夹,所以我试图做到以下几点:
I want to share a folder between two web applications, so I tried to do the following:
<add key="SharedFolder" value="D:\tfs\PlacasV1\Aplicacion Placas DataCenter\Integracion.Reclamos\Web-PRbranch1\"/>
<add key="Claims.ControlGen.OutputDir" value="SharedFolder\restricted\controls\generated\"/>
<add key="Claims.ControlGen.CsTemplatePath" value="SharedFolder\restricted\templates\CustomFieldsControl.ascx.cs.temp"/>
<add key="Claims.ControlGen.AscxTemplatePath" value="SharedFolder\restricted\templates\CustomFieldsControl.ascx.temp.xhtml"/>
<add key="Claims.CodeGeneration.ExpressionValidatorTemplatePath" value="SharedFolder\restricted\templates\ClaimsExpressionValidator.cs.temp"/>
<add key="Claims.CodeGeneration.SrcOutputPath" value="SharedFolder\App_Code\"/>
<add key="Claims.CodeGeneration.DatatypeTemplatePath" value="SharedFolder\restricted\templates\CaseExtensionData.cs.temp"/>
<add key="Claims.CodeGeneration.LibDir" value="SharedFolder\bin"/>
<add key="Claims.Xsl.Dir" value="SharedFolder\restricted\xsl\"/>
任何想法?
谢谢!
推荐答案
您可以创建自定义配置部分,设计它做你要找的内容,以某种方式或其他。
You can create a custom configuration section, and design it to do what you're looking for, in some way or the other.
请参阅本文就如何创建自定义配置节的内容:
See this article for details on how to create custom configuration sections:
http://msdn.microsoft.com/en-us/library/ 2tw134k3.aspx
下面是我在我们的应用中的一个创建自定义配置部的一个例子。只是设计部分,以适应您的需求,它应该工作就像一个魅力:
Here is an example of a custom configuration section that I created in one of our applications. Just design the section to accomodate your needs, and it should work like a charm:
public class ImportConfiguration : ConfigurationSection
{
[ConfigurationProperty("importMap")]
public ImportMapElementCollection ImportMap
{
get
{
return this["importMap"] as ImportMapElementCollection;
}
}
}
public class ImportColumnMapElement : ConfigurationElement
{
[ConfigurationProperty("localName", IsRequired = true, IsKey = true)]
public string LocalName
{
get
{
return this["localName"] as string;
}
set
{
this["localName"] = value;
}
}
[ConfigurationProperty("sourceName", IsRequired = true)]
public string SourceName
{
get
{
return this["sourceName"] as string;
}
set
{
this["sourceName"] = value;
}
}
}
public class ImportMapElementCollection : ConfigurationElementCollection
{
public ImportColumnMapElement this[object key]
{
get
{
return base.BaseGet(key) as ImportColumnMapElement;
}
}
public override ConfigurationElementCollectionType CollectionType
{
get
{
return ConfigurationElementCollectionType.BasicMap;
}
}
protected override string ElementName
{
get
{
return "columnMap";
}
}
protected override bool IsElementName(string elementName)
{
bool isName = false;
if (!String.IsNullOrEmpty(elementName))
isName = elementName.Equals("columnMap");
return isName;
}
protected override ConfigurationElement CreateNewElement()
{
return new ImportColumnMapElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((ImportColumnMapElement)element).LocalName;
}
}
这篇关于是否有可能重新使用密钥在Web.Config中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文