Exemplo n.º 1
0
    // Summarize the attributes of the specified PolicyStatement on the
    // console window.
    private static void summarizePolicyStatment(
        PolicyStatement policyStatement)
    {
        // Retrieve the class path for policyStatement.
        //<Snippet11>
        string policyStatementClass = policyStatement.ToString();
        //</Snippet11>

        //<Snippet12>
        int hashCode = policyStatement.GetHashCode();
        //</Snippet12>

        string attributeString = "";

        // Retrieve the string representation of the PolicyStatement
        // attributes.
        //<Snippet13>
        if (policyStatement.AttributeString != null)
        {
            attributeString = policyStatement.AttributeString;
        }
        //</Snippet13>

        // Write a summary to the console window.
        Console.WriteLine("\n*** " + policyStatementClass + " summary ***");
        Console.Write("This PolicyStatement has been created with hash ");
        Console.Write("code(" + hashCode + ") ");

        Console.Write("and contains the following attributes: ");
        Console.WriteLine(attributeString);
    }
Exemplo n.º 2
0
        public static void PolicyStatementCallMethods()
        {
            PolicyStatement ps     = new PolicyStatement(new PermissionSet(new PermissionState()));
            PolicyStatement ps2    = ps.Copy();
            bool            equals = ps.Equals(ps2);
            int             hash   = ps.GetHashCode();
            SecurityElement se     = new SecurityElement("");
            PolicyLevel     pl     = (PolicyLevel)Activator.CreateInstance(typeof(PolicyLevel), true);

            ps.FromXml(se);
            ps.FromXml(se, pl);
            se = ps.ToXml();
            se = ps.ToXml(pl);
        }
Exemplo n.º 3
0
        public static void PolicyStatementCallMethods()
        {
            PolicyStatement ps     = new PolicyStatement(new PermissionSet(new PermissionState()));
            PolicyStatement ps2    = ps.Copy();
            bool            equals = ps.Equals(ps2);
            int             hash   = ps.GetHashCode();
            SecurityElement se     = new SecurityElement("");
            PolicyLevel     pl     = (PolicyLevel)FormatterServices.GetUninitializedObject(typeof(PolicyLevel));

            ps.FromXml(se);
            ps.FromXml(se, pl);
            se = ps.ToXml();
            se = ps.ToXml(pl);
        }