AddChildNoDuplicates() private method

private AddChildNoDuplicates ( ISecurityElementFactory child ) : void
child ISecurityElementFactory
return void
Exemplo n.º 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) );
     }
 }
 internal static void SafeChildAdd(SecurityElement parent, ISecurityElementFactory child, bool copy)
 {
     if (child != parent)
     {
         if (child.GetTag().Equals("IPermission") || child.GetTag().Equals("Permission"))
         {
             parent.AddChild(child);
         }
         else if (parent.Tag.Equals(child.GetTag()))
         {
             SecurityElement element = (SecurityElement) child;
             for (int i = 0; i < element.InternalChildren.Count; i++)
             {
                 ISecurityElementFactory factory = (ISecurityElementFactory) element.InternalChildren[i];
                 parent.AddChildNoDuplicates(factory);
             }
         }
         else
         {
             parent.AddChild(copy ? ((ISecurityElementFactory) child.Copy()) : child);
         }
     }
 }