本文整理匯總了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.
}
}
}
}