當前位置: 首頁>>代碼示例>>C#>>正文


C# ConfigurationSection.IsReadOnly方法代碼示例

本文整理匯總了C#中System.Configuration.ConfigurationSection.IsReadOnly方法的典型用法代碼示例。如果您正苦於以下問題:C# ConfigurationSection.IsReadOnly方法的具體用法?C# ConfigurationSection.IsReadOnly怎麽用?C# ConfigurationSection.IsReadOnly使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Configuration.ConfigurationSection的用法示例。


在下文中一共展示了ConfigurationSection.IsReadOnly方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SetFX45DefaultValue

        // If a configuration section has a default value coming from 4.0 config and the AppDomain is opted in to auto-config upgrade,
        // set the configuration section element explicitly to its new 4.5 value. If the property has been explicitly set, no change
        // will be made.
        internal static void SetFX45DefaultValue(ConfigurationSection configSection, ConfigurationProperty property, object newDefaultValue) {
            if (BinaryCompatibility.Current.TargetsAtLeastFramework45 && !configSection.IsReadOnly()) {
                PropertyInformation propInfo = configSection.ElementInformation.Properties[property.Name];
                Debug.Assert(propInfo != null);
                Debug.Assert(propInfo.Type.IsInstanceOfType(newDefaultValue));

                if (propInfo.ValueOrigin == PropertyValueOrigin.Default) {
                    try {
                        propInfo.Value = newDefaultValue;
                    }
                    catch (ConfigurationErrorsException) {
                        // Calling the Value setter might throw if the configuration element is locked.
                        // We can technically override the "is locked?" check by calling the appropriate
                        // method, but for now let's just honor the locks and ignore these errors. The
                        // config sections we're touching shouldn't really ever be locked anyway, so
                        // nobody should ever run into this in practice.
                    }
                }
            }
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:23,代碼來源:ConfigUtil.cs


注:本文中的System.Configuration.ConfigurationSection.IsReadOnly方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。