本文整理汇总了C#中System.Security.Policy.ApplicationTrust.ToXml方法的典型用法代码示例。如果您正苦于以下问题:C# ApplicationTrust.ToXml方法的具体用法?C# ApplicationTrust.ToXml怎么用?C# ApplicationTrust.ToXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Policy.ApplicationTrust
的用法示例。
在下文中一共展示了ApplicationTrust.ToXml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplicationTrustCallMethods
public static void ApplicationTrustCallMethods()
{
ApplicationTrust at = new ApplicationTrust();
SecurityElement se = new SecurityElement("");
at.FromXml(se);
se = at.ToXml();
}
示例2: ApplicationIdentity
public void ApplicationIdentity ()
{
ApplicationTrust at = new ApplicationTrust ();
at.ApplicationIdentity = new ApplicationIdentity ("Mono Unit Test");
Assert.IsNotNull (at.ApplicationIdentity, "not null");
string expected = AdjustLineEnds ("<ApplicationTrust version=\"1\"\r\nFullName=\"Mono Unit Test, Culture=neutral\">\r\n<DefaultGrant>\r\n<PolicyStatement version=\"1\">\r\n<PermissionSet class=\"System.Security.PermissionSet\"\r\nversion=\"1\"/>\r\n</PolicyStatement>\r\n</DefaultGrant>\r\n</ApplicationTrust>\r\n");
Assert.AreEqual (expected, AdjustLineEnds (at.ToXml ().ToString ()), "XML");
}
示例3: Constructor_Empty
public void Constructor_Empty ()
{
ApplicationTrust at = new ApplicationTrust ();
Assert.IsNull (at.ApplicationIdentity, "ApplicationIdentity");
Assert.AreEqual (PolicyStatementAttribute.Nothing, at.DefaultGrantSet.Attributes, "DefaultGrantSet.Attributes");
Assert.AreEqual (String.Empty, at.DefaultGrantSet.AttributeString, "DefaultGrantSet.AttributeString");
Assert.IsTrue (at.DefaultGrantSet.PermissionSet.IsEmpty (), "DefaultGrantSet.PermissionSet.IsEmpty");
Assert.IsFalse (at.DefaultGrantSet.PermissionSet.IsUnrestricted (), "DefaultGrantSet.PermissionSet.IsUnrestricted");
Assert.IsNull (at.ExtraInfo, "ExtraInfo");
Assert.IsFalse (at.IsApplicationTrustedToRun, "IsApplicationTrustedToRun");
Assert.IsFalse (at.Persist, "Persist");
string expected = AdjustLineEnds ("<ApplicationTrust version=\"1\">\r\n<DefaultGrant>\r\n<PolicyStatement version=\"1\">\r\n<PermissionSet class=\"System.Security.PermissionSet\"\r\nversion=\"1\"/>\r\n</PolicyStatement>\r\n</DefaultGrant>\r\n</ApplicationTrust>\r\n");
Assert.AreEqual (expected, AdjustLineEnds (at.ToXml ().ToString ()), "XML");
}
示例4: Add
public int Add(ApplicationTrust trust)
{
if (trust == null)
{
throw new ArgumentNullException("trust");
}
if (trust.ApplicationIdentity == null)
{
throw new ArgumentException(Environment.GetResourceString("Argument_ApplicationTrustShouldHaveIdentity"));
}
if (this.m_storeBounded)
{
this.CommitApplicationTrust(trust.ApplicationIdentity, trust.ToXml().ToString());
return -1;
}
return this.AppTrusts.Add(trust);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:ApplicationTrustCollection.cs
示例5: FromXml_NoChild
public void FromXml_NoChild ()
{
ApplicationTrust at = new ApplicationTrust ();
SecurityElement se = at.ToXml ();
SecurityElement w = new SecurityElement (se.Tag);
w.AddAttribute ("version", "1");
at.FromXml (w);
Assert.IsNull (at.ApplicationIdentity, "ApplicationIdentity");
Assert.AreEqual (PolicyStatementAttribute.Nothing, at.DefaultGrantSet.Attributes, "DefaultGrantSet.Attributes");
Assert.AreEqual (String.Empty, at.DefaultGrantSet.AttributeString, "DefaultGrantSet.AttributeString");
Assert.IsTrue (at.DefaultGrantSet.PermissionSet.IsEmpty (), "DefaultGrantSet.PermissionSet.IsEmpty");
Assert.IsFalse (at.DefaultGrantSet.PermissionSet.IsUnrestricted (), "DefaultGrantSet.PermissionSet.IsUnrestricted");
Assert.IsNull (at.ExtraInfo, "ExtraInfo");
Assert.IsFalse (at.IsApplicationTrustedToRun, "IsApplicationTrustedToRun");
Assert.IsFalse (at.Persist, "Persist");
}
示例6: FromXml_NoVersion
public void FromXml_NoVersion ()
{
ApplicationTrust at = new ApplicationTrust ();
SecurityElement se = at.ToXml ();
SecurityElement w = new SecurityElement (se.Tag);
foreach (SecurityElement child in se.Children)
w.AddChild (child);
at.FromXml (w);
}
示例7: 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);
}
示例8: FromXml_InvalidTag
public void FromXml_InvalidTag ()
{
ApplicationTrust at = new ApplicationTrust ();
SecurityElement se = at.ToXml ();
se.Tag = "MonoTrust";
at.FromXml (se);
}
示例9: ToFromXmlRoundtrip
public void ToFromXmlRoundtrip ()
{
ApplicationTrust at = new ApplicationTrust ();
at.ApplicationIdentity = new ApplicationIdentity ("Mono Unit Test");
at.DefaultGrantSet = new PolicyStatement (new PermissionSet (PermissionState.Unrestricted));
at.ExtraInfo = "Mono";
at.IsApplicationTrustedToRun = true;
at.Persist = true;
SecurityElement se = at.ToXml ();
string expected = AdjustLineEnds ("<ApplicationTrust version=\"1\"\r\nFullName=\"Mono Unit Test, Culture=neutral\"\r\nTrustedToRun=\"true\"\r\nPersist=\"true\">\r\n<DefaultGrant>\r\n<PolicyStatement version=\"1\">\r\n<PermissionSet class=\"System.Security.PermissionSet\"\r\nversion=\"1\"\r\nUnrestricted=\"true\"/>\r\n</PolicyStatement>\r\n</DefaultGrant>\r\n<ExtraInfo Data=\"0001000000FFFFFFFF01000000000000000601000000044D6F6E6F0B\"/>\r\n</ApplicationTrust>\r\n");
Assert.AreEqual (expected, AdjustLineEnds (at.ToXml ().ToString ()), "XML");
ApplicationTrust copy = new ApplicationTrust ();
copy.FromXml (se);
se = copy.ToXml ();
Assert.AreEqual (expected, AdjustLineEnds (at.ToXml ().ToString ()), "Copy");
}
示例10: Persist
public void Persist ()
{
ApplicationTrust at = new ApplicationTrust ();
at.Persist = true;
Assert.IsTrue (at.Persist, "true");
string expected = AdjustLineEnds ("<ApplicationTrust version=\"1\"\r\nPersist=\"true\">\r\n<DefaultGrant>\r\n<PolicyStatement version=\"1\">\r\n<PermissionSet class=\"System.Security.PermissionSet\"\r\nversion=\"1\"/>\r\n</PolicyStatement>\r\n</DefaultGrant>\r\n</ApplicationTrust>\r\n");
Assert.AreEqual (expected, AdjustLineEnds (at.ToXml ().ToString ()), "XML");
at.Persist = false;
Assert.IsFalse (at.Persist, "false");
}
示例11: ExtraInfo_NotSerializable
public void ExtraInfo_NotSerializable ()
{
ApplicationTrust at = new ApplicationTrust ();
at.ExtraInfo = this;
SecurityElement se = at.ToXml ();
}
示例12: ExtraInfo
public void ExtraInfo ()
{
ApplicationTrust at = new ApplicationTrust ();
at.ExtraInfo = "Mono";
Assert.IsNotNull (at.ExtraInfo, "not null");
string expected = AdjustLineEnds ("<ApplicationTrust version=\"1\">\r\n<DefaultGrant>\r\n<PolicyStatement version=\"1\">\r\n<PermissionSet class=\"System.Security.PermissionSet\"\r\nversion=\"1\"/>\r\n</PolicyStatement>\r\n</DefaultGrant>\r\n<ExtraInfo Data=\"0001000000FFFFFFFF01000000000000000601000000044D6F6E6F0B\"/>\r\n</ApplicationTrust>\r\n");
Assert.AreEqual (expected, AdjustLineEnds (at.ToXml ().ToString ()), "XML");
at.ExtraInfo = null;
Assert.IsNull (at.ExtraInfo, "null");
}
示例13: DefaultGrantSet
public void DefaultGrantSet ()
{
ApplicationTrust at = new ApplicationTrust ();
at.DefaultGrantSet = new PolicyStatement (new PermissionSet (PermissionState.Unrestricted));
Assert.IsNotNull (at.DefaultGrantSet, "not null");
string expected = AdjustLineEnds ("<ApplicationTrust version=\"1\">\r\n<DefaultGrant>\r\n<PolicyStatement version=\"1\">\r\n<PermissionSet class=\"System.Security.PermissionSet\"\r\nversion=\"1\"\r\nUnrestricted=\"true\"/>\r\n</PolicyStatement>\r\n</DefaultGrant>\r\n</ApplicationTrust>\r\n");
Assert.AreEqual (expected, AdjustLineEnds (at.ToXml ().ToString ()), "XML");
at.DefaultGrantSet = null;
// returns to defaults
Assert.IsNotNull (at.DefaultGrantSet, "null");
Assert.AreEqual (PolicyStatementAttribute.Nothing, at.DefaultGrantSet.Attributes, "DefaultGrantSet.Attributes");
Assert.AreEqual (String.Empty, at.DefaultGrantSet.AttributeString, "DefaultGrantSet.AttributeString");
Assert.IsTrue (at.DefaultGrantSet.PermissionSet.IsEmpty (), "DefaultGrantSet.PermissionSet.IsEmpty");
Assert.IsFalse (at.DefaultGrantSet.PermissionSet.IsUnrestricted (), "DefaultGrantSet.PermissionSet.IsUnrestricted");
}
示例14: Add
[System.Security.SecurityCritical] // auto-generated
public int Add (ApplicationTrust trust) {
if (trust == null)
throw new ArgumentNullException("trust");
if (trust.ApplicationIdentity == null)
throw new ArgumentException(Environment.GetResourceString("Argument_ApplicationTrustShouldHaveIdentity"));
Contract.EndContractBlock();
// Add the trust decision of the application to the fusion store.
if (m_storeBounded) {
CommitApplicationTrust(trust.ApplicationIdentity, trust.ToXml().ToString());
return -1;
} else {
return AppTrusts.Add(trust);
}
}
示例15: InternalSetApplicationTrust
internal void InternalSetApplicationTrust(ApplicationTrust value)
{
if (value != null)
{
this._ApplicationTrust = value.ToXml().ToString();
return;
}
this._ApplicationTrust = null;
}