Ejemplo n.º 1
0
        /// <summary>
        /// Selects a set of nodes from a file given an XPath query
        /// </summary>
        /// <param name="file">the file to select nodes from</param>
        /// <param name="statement">the XPath query</param>
        /// <returns>string[] with the node's string representation</returns>
        internal static string[] Select(string file, string statement)
        {
            // create the query
            XmlQuery query = new XmlQuery();

            // load the file
            query.Load(file);

            // return strings on the query
            ArrayList result = new ArrayList();

            query.Select(statement);
            while (query.Iterator.MoveNext())
            {
                result.Add(query.Iterator.Current.Value);
            }
            return((string[])result.ToArray(typeof(string)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds full trust assemblies to a policy level
        /// </summary>
        /// <param name="policyLevel">The policy level to add full trust assemblies</param>
        /// <param name="fullTrustAssembliesPath">The file containing the public key blob</param>
        private void AddFullTrustAssemblies(PolicyLevel policyLevel, string fullTrustAssembliesPath)
        {
            // create the query to get the membership conditions
            XmlQuery membershipConditions = new XmlQuery();

            membershipConditions.Load(fullTrustAssembliesPath);
            membershipConditions.Select("/FullTrustAssemblies/PublicKeyBlob");

            // for each mc found...
            while (membershipConditions.Iterator.MoveNext())
            {
                // create a mc object
                StrongNameMembershipCondition fullTrustedMC = StrongNameMembershipConditionBuilder.StrongNameMembershipConditionFromPublicKeyBlob(membershipConditions.Iterator.Current.ToString());

                // add the full trust mc
                //error CS0618: 'System.Security.Policy.PolicyLevel.AddFullTrustAssembly(System.Security.Policy.StrongNameMembershipCondition)' is obsolete: 'Because all GAC assemblies always get full trust, the full trust list is no longer meaningful. You should install any assemblies that are used in security policy in the GAC to ensure they are trusted.'
                //policyLevel.AddFullTrustAssembly(fullTrustedMC);
            }
        }
Ejemplo n.º 3
0
        internal DuplicatesHashtable Read(string file)
        {
            // query the given file
            XmlQuery q = new XmlQuery();

            q.Load(file);
            const string query = @"/Variables/Variable[@Name and @Value]";

            q.Select(query);

            // build the table with the values
            DuplicatesHashtable t = new DuplicatesHashtable();

            while (q.Iterator.MoveNext())
            {
                // add (name, val) to the table
                const string nameAttrib  = "Name";
                const string valueAttrib = "Value";
                t.Add(q.Iterator.Current.GetAttribute(nameAttrib, String.Empty), q.Iterator.Current.GetAttribute(valueAttrib, String.Empty));
            }

            // return the table
            return(t);
        }