コード例 #1
0
        private static void DisplayPermissionMembers(
            KeyContainerPermission keyContainerPermParam,
            KeyContainerPermissionAccessEntry[]
            keyContainerPermAccEntryArrayParam)
        {
            KeyContainerPermission keyContainerPerm2 = keyContainerPermParam;

            KeyContainerPermissionAccessEntry[] keyContainerPermAccEntryArray =
                keyContainerPermAccEntryArrayParam;

            // Display the KeyContainerPermission properties.
            //<Snippet12>
            Console.WriteLine("\nFlags value is " +
                              keyContainerPerm2.Flags.ToString());
            //</Snippet12>
            //<Snippet14>
            KeyContainerPermission keyContainerPerm3 =
                (KeyContainerPermission)keyContainerPerm2.Copy();

            Console.WriteLine("Is the copy equal to the original? " +
                              keyContainerPerm3.Equals(keyContainerPerm2));
            //</Snippet14>

            //<Snippet15>
            // Perform an XML roundtrip.
            keyContainerPerm3.FromXml(keyContainerPerm2.ToXml());
            Console.WriteLine("Was the XML roundtrip successful? " +
                              keyContainerPerm3.Equals(keyContainerPerm2));
            //</Snippet15>
            KeyContainerPermission keyContainerPerm4 =
                new KeyContainerPermission(KeyContainerPermissionFlags.Open,
                                           keyContainerPermAccEntryArray);
            //<Snippet16>
            KeyContainerPermission keyContainerPerm5 =
                (KeyContainerPermission)keyContainerPerm2.Intersect(
                    keyContainerPerm4);

            Console.WriteLine("Flags value after the intersection is " +
                              keyContainerPerm5.Flags.ToString());
            //</Snippet16>
            //<Snippet17>
            keyContainerPerm5 = (KeyContainerPermission)keyContainerPerm2.Union(
                keyContainerPerm4);
            //</Snippet17>
            //<Snippet18>
            Console.WriteLine("Flags value after the union is " +
                              keyContainerPerm5.Flags.ToString());
            //</Snippet18>
            //<Snippet19>
            Console.WriteLine("Is one permission a subset of the other? " +
                              keyContainerPerm4.IsSubsetOf(keyContainerPerm2));
            //</Snippet19>
        }