本文整理汇总了C#中System.Security.Permissions.StorePermission.FromXml方法的典型用法代码示例。如果您正苦于以下问题:C# StorePermission.FromXml方法的具体用法?C# StorePermission.FromXml怎么用?C# StorePermission.FromXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Permissions.StorePermission
的用法示例。
在下文中一共展示了StorePermission.FromXml方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConstructorLevel_Deny_Unrestricted
public void ConstructorLevel_Deny_Unrestricted ()
{
StorePermission p = new StorePermission (StorePermissionFlags.AllFlags);
Assert.AreEqual (StorePermissionFlags.AllFlags, p.Flags, "Flags");
Assert.IsTrue (p.IsUnrestricted (), "IsUnrestricted");
Assert.IsNotNull (p.Copy (), "Copy");
SecurityElement se = p.ToXml ();
Assert.IsNotNull (se, "ToXml");
p.FromXml (se);
Assert.IsNotNull (p.Intersect (p), "Intersect");
Assert.IsTrue (p.IsSubsetOf (p), "IsSubsetOf");
Assert.IsNotNull (p.Union (p), "Union");
}
示例2: ConstructorState_Deny_Unrestricted
public void ConstructorState_Deny_Unrestricted ()
{
StorePermission p = new StorePermission (PermissionState.None);
Assert.AreEqual (StorePermissionFlags.NoFlags, p.Flags, "Flags");
Assert.IsFalse (p.IsUnrestricted (), "IsUnrestricted");
SecurityElement se = p.ToXml ();
Assert.IsNotNull (se, "ToXml");
p.FromXml (se);
Assert.IsTrue (p.IsSubsetOf (p), "IsSubsetOf");
// strange behaviour of Copy under MS fx 2.0 (returns null for NoFlags)
p.Copy ();
p.Intersect (p);
p.Union (p);
}
示例3: FromXml_NoVersion
public void FromXml_NoVersion ()
{
StorePermission sp = new StorePermission (PermissionState.None);
SecurityElement se = sp.ToXml ();
SecurityElement w = new SecurityElement (se.Tag);
w.AddAttribute ("class", se.Attribute ("class"));
sp.FromXml (w);
// version is optional (in this case)
}
示例4: FromXml_WrongVersion
public void FromXml_WrongVersion ()
{
StorePermission sp = new StorePermission (PermissionState.None);
SecurityElement se = sp.ToXml ();
se.Attributes.Remove ("version");
se.Attributes.Add ("version", "2");
sp.FromXml (se);
}
示例5: FromXml_NoClass
public void FromXml_NoClass ()
{
StorePermission sp = new StorePermission (PermissionState.None);
SecurityElement se = sp.ToXml ();
SecurityElement w = new SecurityElement (se.Tag);
w.AddAttribute ("version", se.Attribute ("version"));
sp.FromXml (w);
// note: normally IPermission classes (in corlib) DO NOT care about
// attribute "class" name presence in the XML
}
示例6: FromXml_WrongClass
public void FromXml_WrongClass ()
{
StorePermission sp = new StorePermission (PermissionState.None);
SecurityElement se = sp.ToXml ();
SecurityElement w = new SecurityElement (se.Tag);
w.AddAttribute ("class", "Wrong" + se.Attribute ("class"));
w.AddAttribute ("version", se.Attribute ("version"));
sp.FromXml (w);
// doesn't care of the class name at that stage
// anyway the class has already be created so...
}
示例7: FromXml_WrongTagCase
public void FromXml_WrongTagCase ()
{
StorePermission sp = new StorePermission (PermissionState.None);
SecurityElement se = sp.ToXml ();
se.Tag = "IPERMISSION"; // instead of IPermission
sp.FromXml (se);
// note: normally IPermission classes (in corlib) DO care about the
// IPermission tag
}
示例8: FromXml_Null
public void FromXml_Null ()
{
StorePermission sp = new StorePermission (PermissionState.None);
sp.FromXml (null);
}