本文整理汇总了C#中System.Configuration.ConfigurationElement类的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationElement类的具体用法?C# ConfigurationElement怎么用?C# ConfigurationElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationElement类属于System.Configuration命名空间,在下文中一共展示了ConfigurationElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckBaseType
internal static void CheckBaseType(Type expectedBaseType, Type userBaseType, string propertyName, ConfigurationElement configElement)
{
if (!expectedBaseType.IsAssignableFrom(userBaseType))
{
throw new ConfigurationErrorsException(System.Web.SR.GetString("Invalid_type_to_inherit_from", new object[] { userBaseType.FullName, expectedBaseType.FullName }), configElement.ElementInformation.Properties[propertyName].Source, configElement.ElementInformation.Properties[propertyName].LineNumber);
}
}
示例2: Reset
protected override void Reset(ConfigurationElement parentElement)
{
WsdlHelpGeneratorElement element = (WsdlHelpGeneratorElement) parentElement;
WebContext hostingContext = base.EvaluationContext.HostingContext as WebContext;
if (hostingContext != null)
{
string path = hostingContext.Path;
bool flag = path == null;
this.actualPath = element.actualPath;
if (flag)
{
path = HostingEnvironment.ApplicationVirtualPath;
}
if ((path != null) && !path.EndsWith("/", StringComparison.Ordinal))
{
path = path + "/";
}
if ((path == null) && (parentElement != null))
{
this.virtualPath = element.virtualPath;
}
else if (path != null)
{
this.virtualPath = path;
}
}
base.Reset(parentElement);
}
示例3: Configure
public new void Configure(ConfigurationElement configuration)
{
//Store the .config configuration section for us to maybe created modified version later (if requested on the model).
//Note, we had to implement IConfigurable as well (despite it being implemented on our base class) or this would not be called.
_realConfiguration = configuration as OrderPipelinesProcessorConfiguration;
base.Configure(configuration);
}
示例4: BaseIndexOf
protected int BaseIndexOf (ConfigurationElement element)
{
Contract.Requires(element != null);
Contract.Ensures(Contract.Result<int>() >= -1);
return default(int);
}
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:System.Configuration.ConfigurationElementCollection.cs
示例5: GetElementKey
protected override object GetElementKey(ConfigurationElement element)
{
var ele = element as IgnorePostfixConfigurationElement;
if (ele == null)
throw new ArgumentNullException("element", "element不能转换成 IgnoreConfigurationElement");
return ele.Postfix;
}
示例6: GetElementKey
protected override object GetElementKey(ConfigurationElement element)
{
if (element == null)
throw new ArgumentNullException("element");
return ((RepositoryElement)element).Name;
}
示例7: GetElementKey
protected override object GetElementKey(ConfigurationElement element)
{
var ele = element as ServiceConfigurationElement;
if (ele == null)
throw new ArgumentNullException("element", "element不能转换成 ServiceConfigurationElement");
return ele.Key;
}
示例8: ConfigurationLockCollection
internal ConfigurationLockCollection(ConfigurationElement thisElement, ConfigurationLockCollectionType lockType,
string ignoreName, ConfigurationLockCollection parentCollection)
{
_thisElement = thisElement;
LockType = lockType;
_internalDictionary = new HybridDictionary();
_internalArraylist = new ArrayList();
IsModified = false;
ExceptionList = (LockType == ConfigurationLockCollectionType.LockedExceptionList) ||
(LockType == ConfigurationLockCollectionType.LockedElementsExceptionList);
_ignoreName = ignoreName;
if (parentCollection == null) return;
foreach (string key in parentCollection) // seed the new collection
{
Add(key, ConfigurationValueFlags.Inherited); // add the local copy
if (!ExceptionList) continue;
if (_seedList.Length != 0)
_seedList += ",";
_seedList += key;
}
}
示例9: SerializeSection
protected internal virtual string SerializeSection(ConfigurationElement parentElement, string name,
ConfigurationSaveMode saveMode)
{
if ((CurrentConfiguration != null) &&
(CurrentConfiguration.TargetFramework != null) &&
!ShouldSerializeSectionInTargetVersion(CurrentConfiguration.TargetFramework))
return string.Empty;
ValidateElement(this, null, true);
ConfigurationElement tempElement = CreateElement(GetType());
tempElement.Unmerge(this, parentElement, saveMode);
StringWriter strWriter = new StringWriter(CultureInfo.InvariantCulture);
XmlTextWriter writer = new XmlTextWriter(strWriter)
{
Formatting = Formatting.Indented,
Indentation = 4,
IndentChar = ' '
};
tempElement.DataToWriteInternal = saveMode != ConfigurationSaveMode.Minimal;
if ((CurrentConfiguration != null) && (CurrentConfiguration.TargetFramework != null))
_configRecord.SectionsStack.Push(this);
tempElement.SerializeToXmlElement(writer, name);
if ((CurrentConfiguration != null) && (CurrentConfiguration.TargetFramework != null))
_configRecord.SectionsStack.Pop();
writer.Flush();
return strWriter.ToString();
}
示例10: AutoConfigurationHelper
internal AutoConfigurationHelper(ConfigurationElement element, Action<ConfigurationProperty, object> valueSetter, Func<ConfigurationProperty, object> valueGetter)
{
_ConfigElement = element;
_ValueSetter = valueSetter;
_ValueGetter = valueGetter;
var type = element.GetType();
Dictionary<ConfigurationProperty, PropertyInfo> properties;
if (!_TypeProperties.TryGetValue(type, out properties))
{
properties = new Dictionary<ConfigurationProperty, PropertyInfo>();
foreach (var member in type.GetProperties())
{
var configField = member.GetCustomAttributes(typeof(ConfigurationPropertyAttribute), true).Cast<ConfigurationPropertyAttribute>().FirstOrDefault();
if (configField != null)
{
var property = new ConfigurationProperty(configField.Name, member.PropertyType, configField.DefaultValue, ConfigurationPropertyOptions.None);
properties[property] = member;
}
}
_TypeProperties.TryAdd(type, properties);
}
_Properties = properties;
// Pre-initialize properties of type ConfigurationElement, or things go boom
foreach (var property in _Properties)
{
if (typeof(ConfigurationElement).IsAssignableFrom(property.Value.PropertyType))
property.Value.SetValue(_ConfigElement, _ValueGetter(property.Key), null);
}
}
示例11: Reset
protected internal override void Reset(ConfigurationElement parentSection) {
_KeyValueCollection = null;
base.Reset(parentSection);
if (!String.IsNullOrEmpty((string)base[s_propFile])) { // don't inherit from the parent
SetPropertyValue(s_propFile,null,true); // ignore the lock to prevent inheritence
}
}
示例12: GetElementKey
protected override object GetElementKey(ConfigurationElement element)
{
if (element == null) throw new ArgumentNullException("element");
var le = element as LocaleElement;
if (le == null) throw new ArgumentException("Value must be LocaleElement.", "element");
return le.Prefix;
}
示例13: GetElementKey
/// <summary>
/// Gets the element key for autofac component configuration element composed from component name and type.
/// </summary>
/// <param name="element">Autofac component configuration element</param>
/// <returns>An <see cref="System.Object" /> that acts as the key for the specified <see cref="ConfigurationElement" />.</returns>
protected override object GetElementKey(ConfigurationElement element)
{
Guard.NotNull("element", element);
var component = (ComponentConfigurationElement)element;
return component.Name + component.TypeString;
}
开发者ID:kingkino,项目名称:azure-documentdb-datamigrationtool,代码行数:12,代码来源:ComponentConfigurationElementCollection.cs
示例14: GetType
internal static Type GetType(string typeName, string propertyName, ConfigurationElement configElement, XmlNode node, bool checkAptcaBit, bool ignoreCase)
{
Type type;
try
{
type = BuildManager.GetType(typeName, true, ignoreCase);
}
catch (Exception exception)
{
if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException))
{
throw;
}
if (node != null)
{
throw new ConfigurationErrorsException(exception.Message, exception, node);
}
if (configElement != null)
{
throw new ConfigurationErrorsException(exception.Message, exception, configElement.ElementInformation.Properties[propertyName].Source, configElement.ElementInformation.Properties[propertyName].LineNumber);
}
throw new ConfigurationErrorsException(exception.Message, exception);
}
if (checkAptcaBit)
{
if (node != null)
{
HttpRuntime.FailIfNoAPTCABit(type, node);
return type;
}
HttpRuntime.FailIfNoAPTCABit(type, (configElement != null) ? configElement.ElementInformation : null, propertyName);
}
return type;
}
示例15: GetElementKey
protected override object GetElementKey(ConfigurationElement element)
{
if (element == null)
throw new ArgumentNullException("element");
return ((EtcdClient)element).Uri;
}