System.Security.SecurityElement.AddChildNoDuplicates C# (CSharp) Method

AddChildNoDuplicates() private method

private AddChildNoDuplicates ( ISecurityElementFactory child ) : void
child ISecurityElementFactory
return void
        internal void AddChildNoDuplicates(ISecurityElementFactory child)
        {
            if (child == null)
                throw new ArgumentNullException(nameof(child));

            if (_children == null)
            {
                _children = new ArrayList(ChildrenTypical);
                _children.Add(child);
            }
            else
            {
                for (int i = 0; i < _children.Count; ++i)
                {
                    if (_children[i] == child)
                        return;
                }
                _children.Add(child);
            }
        }

Usage Example

Beispiel #1
0
 static internal void SafeChildAdd( SecurityElement parent, ISecurityElementFactory child, bool copy )
 {
     if (child == parent)
         return;
     if (child.GetTag().Equals( "IPermission" ) || child.GetTag().Equals( "Permission" ))
     {
         parent.AddChild( child );
     }
     else if (parent.Tag.Equals( child.GetTag() ))
     {
         Contract.Assert( child is SecurityElement, "SecurityElement expected" );
         SecurityElement elChild = (SecurityElement)child;
         Contract.Assert( elChild.InternalChildren != null,
             "Non-permission elements should have children" );
             
         for (int i = 0; i < elChild.InternalChildren.Count; ++i)
         {
             ISecurityElementFactory current = (ISecurityElementFactory)elChild.InternalChildren[i];
             Contract.Assert( !current.GetTag().Equals( parent.Tag ),
                 "Illegal to insert a like-typed element" );
             parent.AddChildNoDuplicates( current );
         }
     }
     else
     {
         parent.AddChild( (ISecurityElementFactory)(copy ? child.Copy() : child) );
     }
 }
All Usage Examples Of System.Security.SecurityElement::AddChildNoDuplicates