当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.ConfigurationElement类代码示例

本文整理汇总了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);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:ConfigUtil.cs

示例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);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:WsdlHelpGeneratorElement.cs

示例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);
 }
开发者ID:enticify,项目名称:Enticify.Cs2009.Components,代码行数:7,代码来源:ConfigurableOrderPipelinesProcessor.cs

示例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;
 }
开发者ID:chenchunwei,项目名称:Infrastructure,代码行数:7,代码来源:IgnorePostfixConfigurationElementCollection.cs

示例6: GetElementKey

        protected override object GetElementKey(ConfigurationElement element)
        {
            if (element == null)
                throw new ArgumentNullException("element");

            return ((RepositoryElement)element).Name;
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:7,代码来源:RepositoriesCollection.cs

示例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;
 }
开发者ID:chenchunwei,项目名称:Infrastructure,代码行数:7,代码来源:ServiceConfigurationElementCollection.cs

示例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;
            }
        }
开发者ID:chcosta,项目名称:corefx,代码行数:25,代码来源:ConfigurationLockCollection.cs

示例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();
        }
开发者ID:chcosta,项目名称:corefx,代码行数:34,代码来源:ConfigurationSection.cs

示例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);
            }
        }
开发者ID:marcosb,项目名称:CommonCore,代码行数:31,代码来源:AutoConfigurationSection.cs

示例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
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:AppSettingsSection.cs

示例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;
 }
开发者ID:ridercz,项目名称:MvcLocalization,代码行数:7,代码来源:LocaleElement.cs

示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:ConfigUtil.cs

示例15: GetElementKey

            protected override object GetElementKey(ConfigurationElement element)
            {
                if (element == null)
                    throw new ArgumentNullException("element");

                return ((EtcdClient)element).Uri;
            }
开发者ID:haimn100,项目名称:etcetera,代码行数:7,代码来源:EtcdConfigurationSection.cs


注:本文中的System.Configuration.ConfigurationElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。