當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。