ConfigurationElement.LockAllAttributesExcept プロパティ

定義

ロックされている属性のコレクションを取得します。

C#
public System.Configuration.ConfigurationLockCollection LockAllAttributesExcept { get; }

プロパティ値

要素のロックされている属性 (プロパティ) の ConfigurationLockCollection

次の例は、 を使用する方法を LockAllAttributesExcept示しています。

C#
// Show how to use LockAllAttributesExcept.
// It locks and unlocks all urls elements 
// except the port.
static void LockAllAttributesExcept()
{

    try
    {
        // Get current configuration file.
        System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

        // Get the MyUrls section.
        UrlsSection myUrlsSection =
            config.GetSection("MyUrls") as UrlsSection;

        if (myUrlsSection == null)
            Console.WriteLine(
                "Failed to load UrlsSection.");
        else
        {

            IEnumerator elemEnum =
                 myUrlsSection.Urls.GetEnumerator();

            int i = 0;
            while (elemEnum.MoveNext())
            {

                // Get current element.
                ConfigurationElement element =
                    myUrlsSection.Urls[i];

                // Get current element lock all attributes.
                ConfigurationLockCollection lockAllAttributesExcept =
                    element.LockAllAttributesExcept;

                // Add or remove the lock on all attributes 
                // except port.
                if (lockAllAttributesExcept.Contains("port"))
                    lockAllAttributesExcept.Remove("port");
                else
                    lockAllAttributesExcept.Add("port");

                string lockedAttributes =
                    lockAllAttributesExcept.AttributeList;

                Console.WriteLine(
                    "Element {0} Locked attributes list: {1}",
                    i.ToString(), lockedAttributes);

                i += 1;

                config.Save(ConfigurationSaveMode.Full);
            }
        }
    }
    catch (ConfigurationErrorsException e)
    {
        Console.WriteLine(
            "[LockAllAttributesExcept: {0}]",
            e.ToString());
    }
}

注釈

LockAllAttributesExceptプロパティを使用すると、指定した属性を除き、すべての属性を一度にロックできます。 これを行うには、「例」セクションで説明されているように、 メソッドを使用 Contains します。

注意

LockAllAttributesExceptプロパティを使用すると、ルールを適用する要素の子構成要素が変更されないようにすることができます。 LockItem親要素自体とその子要素に一般的なロックを設定する場合は、 プロパティを使用します。

注意 (継承者)

プロパティと LockAttributes プロパティをLockAllAttributesExcept同時に使用する場合は、最も制限の厳しい規則が適用されます。

適用対象

製品 バージョン
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

こちらもご覧ください