当前位置: 首页>>代码示例>>C#>>正文


C# PermissionSet.EncodeXml方法代码示例

本文整理汇总了C#中System.Security.PermissionSet.EncodeXml方法的典型用法代码示例。如果您正苦于以下问题:C# PermissionSet.EncodeXml方法的具体用法?C# PermissionSet.EncodeXml怎么用?C# PermissionSet.EncodeXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.PermissionSet的用法示例。


在下文中一共展示了PermissionSet.EncodeXml方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddDeclarativeSecurity

 public void AddDeclarativeSecurity(SecurityAction action, PermissionSet pset)
 {
     if (pset == null)
     {
         throw new ArgumentNullException("pset");
     }
     if ((!Enum.IsDefined(typeof(SecurityAction), action) || (action == SecurityAction.RequestMinimum)) || ((action == SecurityAction.RequestOptional) || (action == SecurityAction.RequestRefuse)))
     {
         throw new ArgumentOutOfRangeException("action");
     }
     if (this.m_methodBuilder.IsTypeCreated())
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated"));
     }
     byte[] blob = pset.EncodeXml();
     TypeBuilder.AddDeclarativeSecurity(this.GetModuleBuilder().GetNativeHandle(), this.GetToken().Token, action, blob, blob.Length);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:ConstructorBuilder.cs

示例2: AddDeclarativeSecurity

 public void AddDeclarativeSecurity(SecurityAction action, PermissionSet pset)
 {
     if (pset == null)
     {
         throw new ArgumentNullException("pset");
     }
     this.ThrowIfGeneric();
     if ((!Enum.IsDefined(typeof(SecurityAction), action) || (action == SecurityAction.RequestMinimum)) || ((action == SecurityAction.RequestOptional) || (action == SecurityAction.RequestRefuse)))
     {
         throw new ArgumentOutOfRangeException("action");
     }
     this.m_containingType.ThrowIfCreated();
     byte[] blob = null;
     int cb = 0;
     if (!pset.IsEmpty())
     {
         blob = pset.EncodeXml();
         cb = blob.Length;
     }
     TypeBuilder.AddDeclarativeSecurity(this.m_module.GetNativeHandle(), this.MetadataTokenInternal, action, blob, cb);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:21,代码来源:MethodBuilder.cs

示例3: AddDeclarativeSecurityNoLock

        [System.Security.SecurityCritical]  // auto-generated
        private void AddDeclarativeSecurityNoLock(SecurityAction action, PermissionSet pset)
        {
            if (pset == null)
                throw new ArgumentNullException("pset");

#pragma warning disable 618
            if (!Enum.IsDefined(typeof(SecurityAction), action) ||
                action == SecurityAction.RequestMinimum ||
                action == SecurityAction.RequestOptional ||
                action == SecurityAction.RequestRefuse)
            {
                throw new ArgumentOutOfRangeException("action");
            }
#pragma warning restore 618

            Contract.EndContractBlock();

            ThrowIfCreated();

            // Translate permission set into serialized format(uses standard binary serialization format).
            byte[] blob = null;
            int length = 0;
            if (!pset.IsEmpty())
            {
                blob = pset.EncodeXml();
                length = blob.Length;
            }

            // Write the blob into the metadata.
            AddDeclarativeSecurity(m_module.GetNativeHandle(), m_tdType.Token, action, blob, length);
        }
开发者ID:uQr,项目名称:referencesource,代码行数:32,代码来源:typebuilder.cs

示例4: AddDeclarativeSecurity

        [System.Security.SecuritySafeCritical]  // auto-generated
        public void AddDeclarativeSecurity(SecurityAction action, PermissionSet pset)
        {
            if (pset == null)
                throw new ArgumentNullException("pset");

#pragma warning disable 618
            if (!Enum.IsDefined(typeof(SecurityAction), action) ||
                action == SecurityAction.RequestMinimum ||
                action == SecurityAction.RequestOptional ||
                action == SecurityAction.RequestRefuse)
            {
                throw new ArgumentOutOfRangeException("action");
            }
#pragma warning restore 618
            Contract.EndContractBlock();

            // Cannot add declarative security after type is created.
            if (m_methodBuilder.IsTypeCreated())
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated"));
    
            // Translate permission set into serialized format (use standard binary serialization).
            byte[] blob = pset.EncodeXml();
    
            // Write the blob into the metadata.
            TypeBuilder.AddDeclarativeSecurity(GetModuleBuilder().GetNativeHandle(), GetToken().Token, action, blob, blob.Length);
        }
开发者ID:Rayislandstyle,项目名称:dotnet-coreclr,代码行数:27,代码来源:ConstructorBuilder.cs

示例5: AddDeclarativeSecurity

        public void AddDeclarativeSecurity(SecurityAction action, PermissionSet pset)
        {
            ThrowIfGeneric ();

            if (pset == null)
                throw new ArgumentNullException("pset");

            if (!Enum.IsDefined(typeof(SecurityAction), action) || 
                action == SecurityAction.RequestMinimum ||
                action == SecurityAction.RequestOptional ||
                action == SecurityAction.RequestRefuse )
                throw new ArgumentOutOfRangeException("action");

            // cannot declarative security after type is created
            m_containingType.ThrowIfCreated();

            // Translate permission set into serialized format (uses standard binary serialization format).
            byte[] blob = null;
            if (!pset.IsEmpty())
                blob = pset.EncodeXml();

            // Write the blob into the metadata.
            TypeBuilder.InternalAddDeclarativeSecurity (m_module, MetadataTokenInternal, action, blob);
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:24,代码来源:methodbuilder.cs

示例6: AddDeclarativeSecurity

 [System.Security.SecurityCritical]  // auto-generated
 private void AddDeclarativeSecurity(PermissionSet pset, SecurityAction action)
 {
     // Translate sets into internal encoding (uses standard binary serialization).
     byte[] blob = pset.EncodeXml();
     AddDeclarativeSecurity(GetNativeHandle(), action, blob, blob.Length);
 }
开发者ID:ChuangYang,项目名称:coreclr,代码行数:7,代码来源:AssemblyBuilder.cs

示例7: CreateSerialized

        // Internal routine used to create a temporary permission set (given a
        // set of security attribute classes as input) and return the serialized
        // version. May actually return two sets, split into CAS and non-CAS
        // variants.
        private static byte[] CreateSerialized(Object[] attrs, ref byte[] nonCasBlob)
        {
            // Create two new (empty) sets.
            PermissionSet casPset = new PermissionSet(false);
            PermissionSet nonCasPset = new PermissionSet(false);
    
            // Most security attributes generate a single permission. The
            // PermissionSetAttribute class generates an entire permission set we
            // need to merge, however.
            for (int i = 0; i < attrs.Length; i++)
                if (attrs[i] is PermissionSetAttribute)
                {
                    PermissionSet pset = null;

                    pset = ((PermissionSetAttribute)attrs[i]).CreatePermissionSet();

                    if (pset == null)
                    {
                        throw new ArgumentException( Environment.GetResourceString( "Argument_UnableToGeneratePermissionSet" ) );
                    }

                    if (pset.m_normalPermSet != null)
                    {
                        for (int j = 0; j <= pset.m_normalPermSet.GetMaxUsedIndex(); ++j)
                        {
                            IPermission perm = (IPermission)pset.m_normalPermSet.GetItem(j);
                            if (perm != null)
                            {
                                if (perm is CodeAccessPermission)
                                    casPset.AddPermission(perm);
                                else
                                    nonCasPset.AddPermission(perm);
                            }
                        }
                    }

                    if (pset.IsUnrestricted())
                        casPset.SetUnrestricted(true);

                    if (pset.m_unrestrictedPermSet != null)
                    {
                        for (int j = 0; j <= pset.m_unrestrictedPermSet.GetMaxUsedIndex(); ++j)
                        {
                            IPermission perm = (IPermission)pset.m_unrestrictedPermSet.GetItem(j);
                            if (perm != null)
                            {
                                if (perm is CodeAccessPermission)
                                    casPset.AddPermission(perm);
                                else
                                    nonCasPset.AddPermission(perm);
                            }
                        }
                    }

                }
                else
                {
                    IPermission perm = ((SecurityAttribute)attrs[i]).CreatePermission();
                    if (perm is CodeAccessPermission)
                        casPset.AddPermission(perm);
                    else
                        nonCasPset.AddPermission(perm);
                }

            // Serialize the set(s).
            if (!nonCasPset.IsEmpty())
                nonCasBlob = nonCasPset.EncodeXml();
            return casPset.IsEmpty() ? null : casPset.EncodeXml();
        }
开发者ID:ArildF,项目名称:masters,代码行数:73,代码来源:permissionset.cs

示例8: GetSafePermissionSet

	// Internal routine.  Called by native code to create a safe binary encoding
	// given an action.
        internal static byte[] GetSafePermissionSet(int action)
        {
            PermissionSet permSet;
        
            switch (action)
            {
            case (int)System.Security.Permissions.SecurityAction.Demand:
            case (int)System.Security.Permissions.SecurityAction.Deny:
            case (int)System.Security.Permissions.SecurityAction.LinkDemand:
            case (int)System.Security.Permissions.SecurityAction.InheritanceDemand:
            case (int)System.Security.Permissions.SecurityAction.RequestOptional:
                permSet = new PermissionSet(true);
                break;
    
            case (int)System.Security.Permissions.SecurityAction.PermitOnly:
            case (int)System.Security.Permissions.SecurityAction.Assert:
            case (int)System.Security.Permissions.SecurityAction.RequestMinimum:
            case (int)System.Security.Permissions.SecurityAction.RequestRefuse:
                permSet = new PermissionSet(false);
                break;
    
            default :
                BCLDebug.Assert(false, "false");
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"));
            }
            
            return permSet.EncodeXml();
        }
开发者ID:ArildF,项目名称:masters,代码行数:30,代码来源:permissionset.cs

示例9: AddDeclarativeSecurityNoLock

        private void AddDeclarativeSecurityNoLock(SecurityAction action, PermissionSet pset)
        {
            ThrowIfGeneric();

            if (pset == null)
                throw new ArgumentNullException("pset");

            if (!Enum.IsDefined(typeof(SecurityAction), action) || 
                action == SecurityAction.RequestMinimum ||
                action == SecurityAction.RequestOptional ||
                action == SecurityAction.RequestRefuse )
                throw new ArgumentOutOfRangeException("action");

            ThrowIfCreated();

            // Translate permission set into serialized format(uses standard binary serialization format).
            byte[] blob = null;
            if (!pset.IsEmpty())
                blob = pset.EncodeXml();

            // Write the blob into the metadata.
            InternalAddDeclarativeSecurity(m_module, m_tdType.Token, action, blob);
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:23,代码来源:typebuilder.cs

示例10: AddDeclarativeSecurity

        // Add declarative security to the class.
        //
        /// <include file='doc\TypeBuilder.uex' path='docs/doc[@for="TypeBuilder.AddDeclarativeSecurity"]/*' />
        public void AddDeclarativeSecurity(SecurityAction action, PermissionSet pset)
        {
            try
            {
                Enter();

                BCLDebug.Log("DYNIL","## DYNIL LOGGING: TypeBuilder.AddDeclarativeSecurity( )");

                if ((action < SecurityAction.Demand) || (action > SecurityAction.InheritanceDemand))
                    throw new ArgumentOutOfRangeException("action");

                if (pset == null)
                    throw new ArgumentNullException("pset");

                ThrowIfCreated();

                // Translate permission set into serialized format (uses standard binary serialization format).
                byte[] blob = null;
                if (!pset.IsEmpty())
                    blob = pset.EncodeXml();

                // Write the blob into the metadata.
                InternalAddDeclarativeSecurity(m_module, m_tdType.Token, action, blob);
            }
            finally
            {
                Exit();
            }
        }
开发者ID:ArildF,项目名称:masters,代码行数:32,代码来源:typebuilder.cs

示例11: AddDeclarativeSecurity

     // Add declarative security to the constructor.
     //
     /// <include file='doc\ConstructorBuilder.uex' path='docs/doc[@for="ConstructorBuilder.AddDeclarativeSecurity"]/*' />
     public void AddDeclarativeSecurity(SecurityAction action, PermissionSet pset)
     {
         if ((action < SecurityAction.Demand) || (action > SecurityAction.InheritanceDemand))
         throw new ArgumentOutOfRangeException("action");
 
         if (pset == null)
             throw new ArgumentNullException("pset");
 
         // Cannot add declarative security after type is created.
         if (m_methodBuilder.IsTypeCreated())
             throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated"));
 
         // Translate permission set into serialized format (use standard binary serialization).
         byte[] blob = pset.EncodeXml();
 
         // Write the blob into the metadata.
         TypeBuilder.InternalAddDeclarativeSecurity(GetModule(), GetToken().Token, action, blob);
     }
开发者ID:ArildF,项目名称:masters,代码行数:21,代码来源:constructorbuilder.cs


注:本文中的System.Security.PermissionSet.EncodeXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。