本文整理汇总了C#中System.Security.SecurityElement.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# SecurityElement.AddChild方法的具体用法?C# SecurityElement.AddChild怎么用?C# SecurityElement.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.SecurityElement
的用法示例。
在下文中一共展示了SecurityElement.AddChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToXml
internal SecurityElement ToXml()
{
SecurityElement element2;
SecurityElement element = new SecurityElement("System.Security.Policy.PermissionRequestEvidence");
element.AddAttribute("version", "1");
if (this.m_request != null)
{
element2 = new SecurityElement("Request");
element2.AddChild(this.m_request.ToXml());
element.AddChild(element2);
}
if (this.m_optional != null)
{
element2 = new SecurityElement("Optional");
element2.AddChild(this.m_optional.ToXml());
element.AddChild(element2);
}
if (this.m_denied != null)
{
element2 = new SecurityElement("Denied");
element2.AddChild(this.m_denied.ToXml());
element.AddChild(element2);
}
return element;
}
示例2: Constructor_SecurityElement_RSA
public void Constructor_SecurityElement_RSA ()
{
SecurityElement se = new SecurityElement ("RSASignature");
se.AddChild (new SecurityElement ("Key", "System.Security.Cryptography.RSACryptoServiceProvider"));
se.AddChild (new SecurityElement ("Digest", "System.Security.Cryptography.SHA1CryptoServiceProvider"));
se.AddChild (new SecurityElement ("Formatter", "System.Security.Cryptography.RSAPKCS1SignatureFormatter"));
se.AddChild (new SecurityElement ("Deformatter", "System.Security.Cryptography.RSAPKCS1SignatureDeformatter"));
SignatureDescription sig = new SignatureDescription (se);
Assert.AreEqual ("System.Security.Cryptography.RSACryptoServiceProvider", sig.KeyAlgorithm);
Assert.AreEqual ("System.Security.Cryptography.SHA1CryptoServiceProvider", sig.DigestAlgorithm);
Assert.AreEqual ("System.Security.Cryptography.RSAPKCS1SignatureFormatter", sig.FormatterAlgorithm);
Assert.AreEqual ("System.Security.Cryptography.RSAPKCS1SignatureDeformatter", sig.DeformatterAlgorithm);
}
示例3: ToXml
private SecurityElement ToXml()
{
SecurityElement root = new SecurityElement("System.Xml.XmlSecureResolver");
root.AddAttribute("version", "1");
root.AddChild(new SecurityElement("UncDirectory", _uncDir));
return root;
}
示例4: ToXml
internal SecurityElement ToXml()
{
SecurityElement element = new SecurityElement("System.Security.Policy.ApplicationDirectory");
element.AddAttribute("version", "1");
if (this.m_appDirectory != null)
{
element.AddChild(new SecurityElement("Directory", this.m_appDirectory.ToString()));
}
return element;
}
示例5: CreateElement
private SecurityElement CreateElement ()
{
SecurityElement elem = new SecurityElement ("IPermission");
elem.AddAttribute ("class", "System");
elem.AddAttribute ("version", "1");
SecurityElement child = new SecurityElement ("ConnectAccess");
elem.AddChild (child);
SecurityElement grandchild = new SecurityElement ("ENDPOINT", "some text");
grandchild.AddAttribute ("transport", "All");
grandchild.AddAttribute ("host", "localhost");
grandchild.AddAttribute ("port", "8080");
child.AddChild (grandchild);
SecurityElement grandchild2 = new SecurityElement ("ENDPOINT");
grandchild2.AddAttribute ("transport", "Tcp");
grandchild2.AddAttribute ("host", "www.ximian.com");
grandchild2.AddAttribute ("port", "All");
child.AddChild (grandchild2);
return elem;
}
示例6: FromXml_InvalidVersion
public void FromXml_InvalidVersion ()
{
ApplicationTrust at = new ApplicationTrust ();
SecurityElement se = at.ToXml ();
SecurityElement w = new SecurityElement (se.Tag);
w.AddAttribute ("version", "2");
foreach (SecurityElement child in se.Children)
w.AddChild (child);
at.FromXml (w);
}
示例7: CalculatePolicy
internal PolicyStatement CalculatePolicy( String host, String scheme, String port )
{
SecurityElement webPerm = CreateWebPermission( host, scheme, port );
SecurityElement root = new SecurityElement( "PolicyStatement" );
SecurityElement permSet = new SecurityElement( "PermissionSet" );
permSet.AddAttribute( "class", "System.Security.PermissionSet" );
permSet.AddAttribute( "version", "1" );
if (webPerm != null)
permSet.AddChild( webPerm );
root.AddChild( permSet );
PolicyStatement policy = new PolicyStatement();
policy.FromXml( root );
return policy;
}
示例8: FromXml_WithPermissionWithoutClass
public void FromXml_WithPermissionWithoutClass ()
{
SecurityElement child = new SecurityElement ("IPermission");
child.AddAttribute ("version", "1");
SecurityElement se = new SecurityElement ("PermissionSet");
se.AddAttribute ("class", "PermissionSet");
se.AddAttribute ("version", "1");
se.AddChild (child);
PermissionSet ps = new PermissionSet (PermissionState.None);
ps.FromXml (se);
}
示例9: FromXml_PermissionWithoutNamespace
public void FromXml_PermissionWithoutNamespace ()
{
SecurityElement child = new SecurityElement ("IPermission");
child.AddAttribute ("class", "EnvironmentPermission");
child.AddAttribute ("version", "1");
child.AddAttribute ("Read", "USERNAME");
SecurityElement se = new SecurityElement ("PermissionSet");
se.AddAttribute ("class", "PermissionSet");
se.AddAttribute ("version", "1");
se.AddChild (child);
PermissionSet ps = new PermissionSet (PermissionState.None);
ps.FromXml (se);
}
示例10: ProcessAssemblyXml
static bool ProcessAssemblyXml (TextWriter tw, AssemblyDefinition ad)
{
SecurityElement se = new SecurityElement ("Assembly");
se.AddAttribute ("Name", ad.Name.FullName);
if (ad.SecurityDeclarations.Count > 0) {
se.AddChild (AddSecurityXml (ad.SecurityDeclarations));
}
ArrayList tlist = new ArrayList ();
ArrayList mlist = new ArrayList ();
foreach (ModuleDefinition module in ad.Modules) {
foreach (TypeDefinition type in module.Types) {
SecurityElement klass = new SecurityElement ("Class");
SecurityElement methods = new SecurityElement ("Methods");
SecurityElement typelem = null;
if (type.SecurityDeclarations.Count > 0) {
typelem = AddSecurityXml (type.SecurityDeclarations);
}
if (mlist.Count > 0)
mlist.Clear ();
foreach (MethodDefinition method in type.Methods) {
if (method.SecurityDeclarations.Count > 0) {
SecurityElement meth = new SecurityElement ("Method");
AddAttribute (meth, "Name", method.ToString ());
meth.AddChild (AddSecurityXml (method.SecurityDeclarations));
mlist.Add (meth);
}
}
// sort methods
mlist.Sort (Comparer);
foreach (SecurityElement method in mlist) {
methods.AddChild (method);
}
if ((typelem != null) || ((methods.Children != null) && (methods.Children.Count > 0))) {
AddAttribute (klass, "Name", type.ToString ());
if (typelem != null)
klass.AddChild (typelem);
if ((methods.Children != null) && (methods.Children.Count > 0))
klass.AddChild (methods);
tlist.Add (klass);
}
}
// sort types
tlist.Sort (Comparer);
foreach (SecurityElement type in tlist) {
se.AddChild (type);
}
}
tw.WriteLine (se.ToString ());
return true;
}
示例11: ToXml
internal SecurityElement ToXml()
{
SecurityElement element = new SecurityElement("System.Security.Policy.Site");
element.AddAttribute("version", "1");
if (this.m_name != null)
{
element.AddChild(new SecurityElement("Name", this.m_name.ToString()));
}
return element;
}
示例12: ToXml
public virtual SecurityElement ToXml ()
{
SecurityElement se = new SecurityElement (tagName);
se.AddAttribute ("class", GetType ().FullName);
se.AddAttribute ("version", version.ToString ());
if (state == PermissionState.Unrestricted)
se.AddAttribute ("Unrestricted", "true");
// required for permissions that do not implement IUnrestrictedPermission
foreach (IPermission p in list) {
se.AddChild (p.ToXml ());
}
return se;
}
示例13: 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) );
}
}
示例14: InternalToXml
internal SecurityElement InternalToXml()
{
SecurityElement elTrunk = new SecurityElement("PermissionSet");
elTrunk.AddAttribute( "class", this.GetType().FullName);
elTrunk.AddAttribute( "version", "1" );
if (m_Unrestricted)
{
elTrunk.AddAttribute(s_str_Unrestricted, "true" );
}
if (this.m_permSet != null)
{
int maxIndex = this.m_permSet.GetMaxUsedIndex();
for (int i = m_permSet.GetStartingIndex(); i <= maxIndex; ++i)
{
Object obj = this.m_permSet.GetItem( i );
if (obj != null)
{
if (obj is IPermission)
{
if (!m_Unrestricted)
elTrunk.AddChild( ((IPermission)obj).ToXml() );
}
else
{
elTrunk.AddChild( (SecurityElement)obj );
}
}
}
}
return elTrunk ;
}
示例15: ToXml
// internal helper which takes in the hardcoded permission name to avoid lookup at runtime
// can be called from classes that derive from PermissionSet
internal SecurityElement ToXml(String permName)
{
SecurityElement elTrunk = new SecurityElement("PermissionSet");
elTrunk.AddAttribute( "class", permName );
elTrunk.AddAttribute( "version", "1" );
PermissionSetEnumeratorInternal enumerator = new PermissionSetEnumeratorInternal(this);
if (m_Unrestricted)
{
elTrunk.AddAttribute(s_str_Unrestricted, "true" );
}
while (enumerator.MoveNext())
{
IPermission perm = (IPermission)enumerator.Current;
if (!m_Unrestricted)
elTrunk.AddChild( perm.ToXml() );
}
return elTrunk;
}