Exemple #1
0
        /// <summary>Creates a permission that is the union of the current permission and the specified permission.</summary>
        /// <param name="other">A permission to combine with the current permission. It must be of the same type as the current permission. </param>
        /// <returns>A new permission that represents the union of the current permission and the specified permission.</returns>
        /// <exception cref="T:System.ArgumentException">The <paramref name="other" /> parameter is an object that is not of the same type as the current permission. </exception>
        // Token: 0x06002609 RID: 9737 RVA: 0x00089284 File Offset: 0x00087484
        public IPermission Union(IPermission other)
        {
            if (other == null)
            {
                return(this.Copy());
            }
            if (!this.VerifyType(other))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[]
                {
                    base.GetType().FullName
                }));
            }
            PrincipalPermission principalPermission = (PrincipalPermission)other;

            if (this.IsUnrestricted() || principalPermission.IsUnrestricted())
            {
                return(new PrincipalPermission(PermissionState.Unrestricted));
            }
            int num = this.m_array.Length + principalPermission.m_array.Length;

            IDRole[] array = new IDRole[num];
            int      i;

            for (i = 0; i < this.m_array.Length; i++)
            {
                array[i] = this.m_array[i];
            }
            for (int j = 0; j < principalPermission.m_array.Length; j++)
            {
                array[i + j] = principalPermission.m_array[j];
            }
            return(new PrincipalPermission(array));
        }
        /// <summary>创建一个权限,该权限是当前权限与指定权限的并集。</summary>
        /// <returns>一个新权限,它表示当前权限与指定权限的并集。</returns>
        /// <param name="other">将与当前权限合并的权限。它必须与当前权限属于同一类型。</param>
        /// <exception cref="T:System.ArgumentException">
        /// <paramref name="other" /> 参数是与当前权限属于不同类型的对象。</exception>
        public IPermission Union(IPermission other)
        {
            if (other == null)
            {
                return(this.Copy());
            }
            if (!this.VerifyType(other))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", (object)this.GetType().FullName));
            }
            PrincipalPermission principalPermission = (PrincipalPermission)other;

            if (this.IsUnrestricted() || principalPermission.IsUnrestricted())
            {
                return((IPermission) new PrincipalPermission(PermissionState.Unrestricted));
            }
            IDRole[] array = new IDRole[this.m_array.Length + principalPermission.m_array.Length];
            int      index1;

            for (index1 = 0; index1 < this.m_array.Length; ++index1)
            {
                array[index1] = this.m_array[index1];
            }
            for (int index2 = 0; index2 < principalPermission.m_array.Length; ++index2)
            {
                array[index1 + index2] = principalPermission.m_array[index2];
            }
            return((IPermission) new PrincipalPermission(array));
        }
Exemple #3
0
        public void FromXml(SecurityElement elem)
        {
            if (elem == null)
            {
                throw new ArgumentNullException(nameof(elem));
            }

            if (elem.Tag == null || !elem.Tag.Equals("Permission") && !elem.Tag.Equals("IPermission"))
            {
                throw new ArgumentException(SR.Argument_NotAPermissionElement);
            }

            string version = elem.Attribute("version");

            if (version == null || (version != null && !version.Equals("1")))
            {
                throw new ArgumentException(SR.Argument_InvalidXMLBadVersion);
            }

            if (elem.InternalChildren != null && elem.InternalChildren.Count != 0)
            {
                int numChildren = elem.InternalChildren.Count;
                int count       = 0;

                _idArray = new IDRole[numChildren];
                foreach (object curr in elem.Children)
                {
                    _idArray[count++] = new IDRole((SecurityElement)curr);
                }
            }
            else
            {
                _idArray = new IDRole[0];
            }
        }
Exemple #4
0
        public void FromXml(SecurityElement elem)
        {
            CodeAccessPermission.ValidateElement(elem, this);

            if (elem.InternalChildren != null && elem.InternalChildren.Count != 0)
            {
                int numChildren = elem.InternalChildren.Count;
                int count       = 0;

                m_array = new IDRole[numChildren];

                IEnumerator enumerator = elem.Children.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    IDRole idrole = new IDRole();

                    idrole.FromXml((SecurityElement)enumerator.Current);

                    m_array[count++] = idrole;
                }
            }
            else
            {
                m_array = new IDRole[0];
            }
        }
Exemple #5
0
 public PrincipalPermission(String name, String role, bool isAuthenticated)
 {
     m_array    = new IDRole[1];
     m_array[0] = new IDRole();
     m_array[0].m_authenticated = isAuthenticated;
     m_array[0].m_id            = name;
     m_array[0].m_role          = role;
 }
 /// <summary>从 XML 编码重新构造具有指定状态的权限。</summary>
 /// <param name="elem">用于重新构造权限的 XML 编码。</param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="elem" /> 参数为 null。</exception>
 /// <exception cref="T:System.ArgumentException">
 /// <paramref name="elem" /> 参数不是有效的权限元素。- 或 -<paramref name="elem" /> 参数的版本号无效。</exception>
 public void FromXml(SecurityElement elem)
 {
     CodeAccessPermission.ValidateElement(elem, (IPermission)this);
     if (elem.InternalChildren != null && elem.InternalChildren.Count != 0)
     {
         int count = elem.InternalChildren.Count;
         int num   = 0;
         this.m_array = new IDRole[count];
         foreach (SecurityElement child in elem.Children)
         {
             IDRole idRole = new IDRole();
             idRole.FromXml(child);
             this.m_array[num++] = idRole;
         }
     }
     else
     {
         this.m_array = new IDRole[0];
     }
 }
Exemple #7
0
        public IPermission Union(IPermission other)
        {
            if (other == null)
            {
                return(this.Copy());
            }
            else if (!VerifyType(other))
            {
                throw new
                      ArgumentException(
                          Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
                          );
            }

            PrincipalPermission operand = (PrincipalPermission)other;

            if (this.IsUnrestricted() || operand.IsUnrestricted())
            {
                return(new PrincipalPermission(PermissionState.Unrestricted));
            }

            // Now we have to do a real union

            int combinedLength = this.m_array.Length + operand.m_array.Length;

            IDRole[] idrolesArray = new IDRole[combinedLength];

            int i, j;

            for (i = 0; i < this.m_array.Length; ++i)
            {
                idrolesArray[i] = this.m_array[i];
            }

            for (j = 0; j < operand.m_array.Length; ++j)
            {
                idrolesArray[i + j] = operand.m_array[j];
            }

            return(new PrincipalPermission(idrolesArray));
        }
Exemple #8
0
 public void FromXml(SecurityElement elem)
 {
     CodeAccessPermission.ValidateElement(elem, this);
     if ((elem.InternalChildren != null) && (elem.InternalChildren.Count != 0))
     {
         int count = elem.InternalChildren.Count;
         int num2  = 0;
         this.m_array = new IDRole[count];
         IEnumerator enumerator = elem.Children.GetEnumerator();
         while (enumerator.MoveNext())
         {
             IDRole role = new IDRole();
             role.FromXml((SecurityElement)enumerator.Current);
             this.m_array[num2++] = role;
         }
     }
     else
     {
         this.m_array = new IDRole[0];
     }
 }
Exemple #9
0
 public PrincipalPermission(PermissionState state)
 {
     if (state == PermissionState.Unrestricted)
     {
         m_array    = new IDRole[1];
         m_array[0] = new IDRole();
         m_array[0].m_authenticated = true;
         m_array[0].m_id            = null;
         m_array[0].m_role          = null;
     }
     else if (state == PermissionState.None)
     {
         m_array    = new IDRole[1];
         m_array[0] = new IDRole();
         m_array[0].m_authenticated = false;
         m_array[0].m_id            = "";
         m_array[0].m_role          = "";
     }
     else
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_InvalidPermissionState"));
     }
 }
Exemple #10
0
        public IPermission Union(IPermission other)
        {
            if (other == null)
            {
                return(Copy());
            }
            else if (!VerifyType(other))
            {
                throw new ArgumentException(SR.Argument_WrongType, GetType().FullName);
            }

            PrincipalPermission operand = (PrincipalPermission)other;

            if (IsUnrestricted() || operand.IsUnrestricted())
            {
                return(new PrincipalPermission(PermissionState.Unrestricted));
            }

            IDRole[] idrolesArray = new IDRole[_idArray.Length + operand._idArray.Length];
            Array.Copy(_idArray, 0, idrolesArray, 0, _idArray.Length);
            Array.Copy(operand._idArray, 0, idrolesArray, _idArray.Length, operand._idArray.Length);

            return(new PrincipalPermission(idrolesArray));
        }
        public void FromXml(SecurityElement elem)
        {
            CodeAccessPermission.ValidateElement( elem, this );

            if (elem.InternalChildren != null && elem.InternalChildren.Count != 0)
            { 
                int numChildren = elem.InternalChildren.Count;
                int count = 0;
                
                m_array = new IDRole[numChildren];
            
                IEnumerator enumerator = elem.Children.GetEnumerator();
            
                while (enumerator.MoveNext())  
                {
                    IDRole idrole = new IDRole();
                    
                    idrole.FromXml( (SecurityElement)enumerator.Current );
                    
                    m_array[count++] = idrole;
                }
            }
            else
                m_array = new IDRole[0];
        }
Exemple #12
0
        /// <summary>Creates and returns a permission that is the intersection of the current permission and the specified permission.</summary>
        /// <param name="target">A permission to intersect with the current permission. It must be of the same type as the current permission. </param>
        /// <returns>A new permission that represents the intersection of the current permission and the specified permission. This new permission will be <see langword="null" /> if the intersection is empty.</returns>
        /// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is not <see langword="null" /> and is not an instance of the same class as the current permission. </exception>
        // Token: 0x06002608 RID: 9736 RVA: 0x00088FB4 File Offset: 0x000871B4
        public IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }
            if (!this.VerifyType(target))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[]
                {
                    base.GetType().FullName
                }));
            }
            if (this.IsUnrestricted())
            {
                return(target.Copy());
            }
            PrincipalPermission principalPermission = (PrincipalPermission)target;

            if (principalPermission.IsUnrestricted())
            {
                return(this.Copy());
            }
            List <IDRole> list = null;

            for (int i = 0; i < this.m_array.Length; i++)
            {
                for (int j = 0; j < principalPermission.m_array.Length; j++)
                {
                    if (principalPermission.m_array[j].m_authenticated == this.m_array[i].m_authenticated)
                    {
                        if (principalPermission.m_array[j].m_id == null || this.m_array[i].m_id == null || this.m_array[i].m_id.Equals(principalPermission.m_array[j].m_id))
                        {
                            if (list == null)
                            {
                                list = new List <IDRole>();
                            }
                            IDRole idrole = new IDRole();
                            idrole.m_id = ((principalPermission.m_array[j].m_id == null) ? this.m_array[i].m_id : principalPermission.m_array[j].m_id);
                            if (principalPermission.m_array[j].m_role == null || this.m_array[i].m_role == null || this.m_array[i].m_role.Equals(principalPermission.m_array[j].m_role))
                            {
                                idrole.m_role = ((principalPermission.m_array[j].m_role == null) ? this.m_array[i].m_role : principalPermission.m_array[j].m_role);
                            }
                            else
                            {
                                idrole.m_role = "";
                            }
                            idrole.m_authenticated = principalPermission.m_array[j].m_authenticated;
                            list.Add(idrole);
                        }
                        else if (principalPermission.m_array[j].m_role == null || this.m_array[i].m_role == null || this.m_array[i].m_role.Equals(principalPermission.m_array[j].m_role))
                        {
                            if (list == null)
                            {
                                list = new List <IDRole>();
                            }
                            list.Add(new IDRole
                            {
                                m_id            = "",
                                m_role          = ((principalPermission.m_array[j].m_role == null) ? this.m_array[i].m_role : principalPermission.m_array[j].m_role),
                                m_authenticated = principalPermission.m_array[j].m_authenticated
                            });
                        }
                    }
                }
            }
            if (list == null)
            {
                return(null);
            }
            IDRole[]    array      = new IDRole[list.Count];
            IEnumerator enumerator = list.GetEnumerator();
            int         num        = 0;

            while (enumerator.MoveNext())
            {
                object obj = enumerator.Current;
                array[num++] = (IDRole)obj;
            }
            return(new PrincipalPermission(array));
        }
Exemple #13
0
        public IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }
            else if (!VerifyType(target))
            {
                throw new
                      ArgumentException(
                          Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
                          );
            }
            else if (this.IsUnrestricted())
            {
                return(target.Copy());
            }

            PrincipalPermission operand = (PrincipalPermission)target;

            if (operand.IsUnrestricted())
            {
                return(this.Copy());
            }

            List <IDRole> idroles = null;

            for (int i = 0; i < this.m_array.Length; ++i)
            {
                for (int j = 0; j < operand.m_array.Length; ++j)
                {
                    if (operand.m_array[j].m_authenticated == this.m_array[i].m_authenticated)
                    {
                        if (operand.m_array[j].m_id == null ||
                            this.m_array[i].m_id == null ||
                            this.m_array[i].m_id.Equals(operand.m_array[j].m_id))
                        {
                            if (idroles == null)
                            {
                                idroles = new List <IDRole>();
                            }

                            IDRole idrole = new IDRole();

                            idrole.m_id = operand.m_array[j].m_id == null ? this.m_array[i].m_id : operand.m_array[j].m_id;

                            if (operand.m_array[j].m_role == null ||
                                this.m_array[i].m_role == null ||
                                this.m_array[i].m_role.Equals(operand.m_array[j].m_role))
                            {
                                idrole.m_role = operand.m_array[j].m_role == null ? this.m_array[i].m_role : operand.m_array[j].m_role;
                            }
                            else
                            {
                                idrole.m_role = "";
                            }

                            idrole.m_authenticated = operand.m_array[j].m_authenticated;

                            idroles.Add(idrole);
                        }
                        else if (operand.m_array[j].m_role == null ||
                                 this.m_array[i].m_role == null ||
                                 this.m_array[i].m_role.Equals(operand.m_array[j].m_role))
                        {
                            if (idroles == null)
                            {
                                idroles = new List <IDRole>();
                            }

                            IDRole idrole = new IDRole();

                            idrole.m_id            = "";
                            idrole.m_role          = operand.m_array[j].m_role == null ? this.m_array[i].m_role : operand.m_array[j].m_role;
                            idrole.m_authenticated = operand.m_array[j].m_authenticated;

                            idroles.Add(idrole);
                        }
                    }
                }
            }

            if (idroles == null)
            {
                return(null);
            }
            else
            {
                IDRole[] idrolesArray = new IDRole[idroles.Count];

                IEnumerator idrolesEnumerator = idroles.GetEnumerator();
                int         index             = 0;

                while (idrolesEnumerator.MoveNext())
                {
                    idrolesArray[index++] = (IDRole)idrolesEnumerator.Current;
                }

                return(new PrincipalPermission(idrolesArray));
            }
        }
 public PrincipalPermission( PermissionState state )
 {
     if (state == PermissionState.Unrestricted)
     {
         m_array = new IDRole[1];
         m_array[0] = new IDRole();
         m_array[0].m_authenticated = true;
         m_array[0].m_id = null;
         m_array[0].m_role = null;
     }
     else if (state == PermissionState.None)
     {
         m_array = new IDRole[1];
         m_array[0] = new IDRole();
         m_array[0].m_authenticated = false;
         m_array[0].m_id = "";
         m_array[0].m_role = "";
     }
     else
         throw new ArgumentException(Environment.GetResourceString("Argument_InvalidPermissionState"));
 }
Exemple #15
0
 private PrincipalPermission(IDRole[] array)
 {
     _idArray = array;
 }
Exemple #16
0
        public IPermission Union(IPermission other)
        {
            if (other == null)
            {
                return Copy();
            }
            else if (!VerifyType(other))
            {
                throw new ArgumentException(SR.Argument_WrongType, GetType().FullName);
            }

            PrincipalPermission operand = (PrincipalPermission)other;

            if (IsUnrestricted() || operand.IsUnrestricted())
            {
                return new PrincipalPermission(PermissionState.Unrestricted);
            }

            IDRole[] idrolesArray = new IDRole[_idArray.Length + operand._idArray.Length];
            Array.Copy(_idArray, 0, idrolesArray, 0, _idArray.Length);
            Array.Copy(operand._idArray, 0, idrolesArray, _idArray.Length, operand._idArray.Length);

            return new PrincipalPermission(idrolesArray);
        }
Exemple #17
0
        public void FromXml(SecurityElement elem)
        {
            if (elem == null)
                throw new ArgumentNullException(nameof(elem));

            if (elem.Tag == null || !elem.Tag.Equals("Permission") && !elem.Tag.Equals("IPermission"))
                throw new ArgumentException(SR.Argument_NotAPermissionElement);

            string version = elem.Attribute("version");

            if (version == null || (version != null && !version.Equals("1")))
                throw new ArgumentException(SR.Argument_InvalidXMLBadVersion);

            if (elem.Children != null && elem.Children.Count != 0)
            {
                int numChildren = elem.Children.Count;
                int count = 0;

                _idArray = new IDRole[numChildren];
                foreach (object curr in elem.Children)
                {
                    _idArray[count++] = new IDRole((SecurityElement)curr);
                }
            }
            else
                _idArray = new IDRole[0];
        }
 public PrincipalPermission( String name, String role, bool isAuthenticated )
 {
     m_array = new IDRole[1];
     m_array[0] = new IDRole();
     m_array[0].m_authenticated = isAuthenticated;
     m_array[0].m_id = name;
     m_array[0].m_role = role;
 }        
        /// <summary>创建并返回一个权限,该权限是当前权限和指定权限的交集。</summary>
        /// <returns>一个新权限,它表示当前权限与指定权限的交集。交集为空时,新权限将为 null。</returns>
        /// <param name="target">要与当前权限相交的权限。它必须与当前权限属于同一类型。</param>
        /// <exception cref="T:System.ArgumentException">
        /// <paramref name="target" /> 参数不为 null,并且不是与当前权限属于相同类的实例。</exception>
        public IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return((IPermission)null);
            }
            if (!this.VerifyType(target))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", (object)this.GetType().FullName));
            }
            if (this.IsUnrestricted())
            {
                return(target.Copy());
            }
            PrincipalPermission principalPermission = (PrincipalPermission)target;

            if (principalPermission.IsUnrestricted())
            {
                return(this.Copy());
            }
            List <IDRole> idRoleList = (List <IDRole>)null;

            for (int index1 = 0; index1 < this.m_array.Length; ++index1)
            {
                for (int index2 = 0; index2 < principalPermission.m_array.Length; ++index2)
                {
                    if (principalPermission.m_array[index2].m_authenticated == this.m_array[index1].m_authenticated)
                    {
                        if (principalPermission.m_array[index2].m_id == null || this.m_array[index1].m_id == null || this.m_array[index1].m_id.Equals(principalPermission.m_array[index2].m_id))
                        {
                            if (idRoleList == null)
                            {
                                idRoleList = new List <IDRole>();
                            }
                            idRoleList.Add(new IDRole()
                            {
                                m_id            = principalPermission.m_array[index2].m_id == null ? this.m_array[index1].m_id : principalPermission.m_array[index2].m_id,
                                m_role          = principalPermission.m_array[index2].m_role == null || this.m_array[index1].m_role == null || this.m_array[index1].m_role.Equals(principalPermission.m_array[index2].m_role) ? (principalPermission.m_array[index2].m_role == null ? this.m_array[index1].m_role : principalPermission.m_array[index2].m_role) : "",
                                m_authenticated = principalPermission.m_array[index2].m_authenticated
                            });
                        }
                        else if (principalPermission.m_array[index2].m_role == null || this.m_array[index1].m_role == null || this.m_array[index1].m_role.Equals(principalPermission.m_array[index2].m_role))
                        {
                            if (idRoleList == null)
                            {
                                idRoleList = new List <IDRole>();
                            }
                            idRoleList.Add(new IDRole()
                            {
                                m_id            = "",
                                m_role          = principalPermission.m_array[index2].m_role == null ? this.m_array[index1].m_role : principalPermission.m_array[index2].m_role,
                                m_authenticated = principalPermission.m_array[index2].m_authenticated
                            });
                        }
                    }
                }
            }
            if (idRoleList == null)
            {
                return((IPermission)null);
            }
            IDRole[]    array      = new IDRole[idRoleList.Count];
            IEnumerator enumerator = (IEnumerator)idRoleList.GetEnumerator();
            int         num        = 0;

            while (enumerator.MoveNext())
            {
                array[num++] = (IDRole)enumerator.Current;
            }
            return((IPermission) new PrincipalPermission(array));
        }
        public IPermission Union(IPermission other)
        {
            if (other == null)
            {
                return this.Copy();
            }
            else if (!VerifyType(other))
            {
                throw new 
                    ArgumentException(
                                    Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
                                     );
            }
    
            PrincipalPermission operand = (PrincipalPermission)other;
           
            if (this.IsUnrestricted() || operand.IsUnrestricted())
            {
                return new PrincipalPermission( PermissionState.Unrestricted );
            }
    
            // Now we have to do a real union
            
            int combinedLength = this.m_array.Length + operand.m_array.Length;
            IDRole[] idrolesArray = new IDRole[combinedLength];
            
            int i, j;
            for (i = 0; i < this.m_array.Length; ++i)
            {
                idrolesArray[i] = this.m_array[i];
            }
            
            for (j = 0; j < operand.m_array.Length; ++j)
            {
                idrolesArray[i+j] = operand.m_array[j];
            }
            
            return new PrincipalPermission( idrolesArray );

        }    
        public IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return null;
            }
            else if (!VerifyType(target))
            {
                throw new 
                    ArgumentException(
                                    Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
                                     );
            }
            else if (this.IsUnrestricted())
            {
                return target.Copy();
            }
    
            PrincipalPermission operand = (PrincipalPermission)target;
    
            if (operand.IsUnrestricted())
            {
                return this.Copy();
            }
            
            List<IDRole> idroles = null;
            
            for (int i = 0; i < this.m_array.Length; ++i)
            {
                for (int j = 0; j < operand.m_array.Length; ++j)
                {
                    if (operand.m_array[j].m_authenticated == this.m_array[i].m_authenticated)
                    {
                        if (operand.m_array[j].m_id == null ||
                            this.m_array[i].m_id == null ||
                            this.m_array[i].m_id.Equals( operand.m_array[j].m_id ))
                        {
                            if (idroles == null)
                            {
                                idroles = new List<IDRole>();
                            }
                    
                            IDRole idrole = new IDRole();
                            
                            idrole.m_id = operand.m_array[j].m_id == null ? this.m_array[i].m_id : operand.m_array[j].m_id;
                            
                            if (operand.m_array[j].m_role == null ||
                                this.m_array[i].m_role == null ||
                                this.m_array[i].m_role.Equals( operand.m_array[j].m_role))
                            {
                                idrole.m_role = operand.m_array[j].m_role == null ? this.m_array[i].m_role : operand.m_array[j].m_role;
                            }
                            else
                            {
                                idrole.m_role = "";
                            }
                            
                            idrole.m_authenticated = operand.m_array[j].m_authenticated;
                            
                            idroles.Add( idrole );
                        }
                        else if (operand.m_array[j].m_role == null ||
                                 this.m_array[i].m_role == null ||
                                 this.m_array[i].m_role.Equals( operand.m_array[j].m_role))
                        {
                            if (idroles == null)
                            {
                                idroles = new List<IDRole>();
                            }

                            IDRole idrole = new IDRole();
                            
                            idrole.m_id = "";
                            idrole.m_role = operand.m_array[j].m_role == null ? this.m_array[i].m_role : operand.m_array[j].m_role;
                            idrole.m_authenticated = operand.m_array[j].m_authenticated;
                            
                            idroles.Add( idrole );
                        }
                    }
                }
            }
            
            if (idroles == null)
            {
                return null;
            }
            else
            {
                IDRole[] idrolesArray = new IDRole[idroles.Count];
                
                IEnumerator idrolesEnumerator = idroles.GetEnumerator();
                int index = 0;
                
                while (idrolesEnumerator.MoveNext())
                {
                    idrolesArray[index++] = (IDRole)idrolesEnumerator.Current;
                }
                                                                
                return new PrincipalPermission( idrolesArray );
            }
        }