本文整理汇总了C#中System.Security.SecurityElement.AddChildNoDuplicates方法的典型用法代码示例。如果您正苦于以下问题:C# SecurityElement.AddChildNoDuplicates方法的具体用法?C# SecurityElement.AddChildNoDuplicates怎么用?C# SecurityElement.AddChildNoDuplicates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.SecurityElement
的用法示例。
在下文中一共展示了SecurityElement.AddChildNoDuplicates方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SafeChildAdd
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) );
}
}
示例2: SafeChildAdd
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);
}
}
}