本文整理汇总了C#中System.Security.Permissions.StorePermission.Intersect方法的典型用法代码示例。如果您正苦于以下问题:C# StorePermission.Intersect方法的具体用法?C# StorePermission.Intersect怎么用?C# StorePermission.Intersect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Permissions.StorePermission
的用法示例。
在下文中一共展示了StorePermission.Intersect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Intersect_Unrestricted
public void Intersect_Unrestricted ()
{
// Intersection with unrestricted == Copy
// a. source (this) is unrestricted
StorePermission sp1 = new StorePermission (PermissionState.Unrestricted);
StorePermission sp2 = new StorePermission (PermissionState.None);
StorePermission result = (StorePermission) sp1.Intersect (sp2);
Assert.IsNull (result, "target NoFlags");
for (int i = 1; i < (int) StorePermissionFlags.AllFlags; i++) {
// 8 isn't a valid value (so we exclude it from the rest of the loop)
if ((i & 8) == 8)
continue;
sp2.Flags = (StorePermissionFlags) i;
result = (StorePermission) sp1.Intersect (sp2);
Assert.AreEqual (sp2.Flags, result.Flags, "target " + sp2.Flags.ToString ());
}
// b. destination (target) is unrestricted
sp2.Flags = StorePermissionFlags.NoFlags;
result = (StorePermission) sp2.Intersect (sp1);
Assert.IsNull (result, "target NoFlags");
for (int i = 1; i < (int) StorePermissionFlags.AllFlags; i++) {
// 8 isn't a valid value (so we exclude it from the rest of the loop)
if ((i & 8) == 8)
continue;
sp2.Flags = (StorePermissionFlags) i;
result = (StorePermission) sp2.Intersect (sp1);
Assert.AreEqual (sp2.Flags, result.Flags, "source " + sp2.Flags.ToString ());
}
}
示例4: Intersect_Self
public void Intersect_Self ()
{
StorePermission sp = new StorePermission (PermissionState.None);
sp.Flags = StorePermissionFlags.NoFlags; // 0
StorePermission result = (StorePermission) sp.Intersect (sp);
Assert.IsNull (result, "NoFlags");
for (int i = 1; i < (int) StorePermissionFlags.AllFlags; i++) {
// 8 isn't a valid value (so we exclude it from the rest of the loop)
if ((i & 8) == 8)
continue;
sp.Flags = (StorePermissionFlags) i;
result = (StorePermission) sp.Intersect (sp);
Assert.AreEqual (sp.Flags, result.Flags, sp.Flags.ToString ());
}
}
示例5: Intersect_None
public void Intersect_None ()
{
StorePermission sp1 = new StorePermission (PermissionState.None);
StorePermission sp2 = new StorePermission (PermissionState.None);
for (int i = 0; i < (int) StorePermissionFlags.AllFlags; i++) {
// 8 isn't a valid value (so we exclude it from the rest of the loop)
if ((i & 8) == 8)
continue;
sp1.Flags = (StorePermissionFlags) i;
// 1. Intersect None with ppl
StorePermission result = (StorePermission) sp1.Intersect (sp2);
Assert.IsNull (result, "None N " + sp1.Flags.ToString ());
// 2. Intersect ppl with None
result = (StorePermission) sp2.Intersect (sp1);
Assert.IsNull (result, sp1.Flags.ToString () + "N None");
}
}
示例6: Intersect_Null
public void Intersect_Null ()
{
StorePermission sp = new StorePermission (PermissionState.None);
// No intersection with null
for (int i = 0; i < (int) StorePermissionFlags.AllFlags; i++) {
// 8 isn't a valid value (so we exclude it from the rest of the loop)
if ((i & 8) == 8)
continue;
sp.Flags = (StorePermissionFlags) i;
Assert.IsNull (sp.Intersect (null), sp.Flags.ToString ());
}
}