本文整理汇总了C#中IPermission.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# IPermission.Copy方法的具体用法?C# IPermission.Copy怎么用?C# IPermission.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPermission
的用法示例。
在下文中一共展示了IPermission.Copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null)
{
return null;
}
if (!base.VerifyType(target))
{
throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName }));
}
IsolatedStorageFilePermission permission = (IsolatedStorageFilePermission) target;
if (permission.IsUnrestricted())
{
return this.Copy();
}
if (base.IsUnrestricted())
{
return target.Copy();
}
IsolatedStorageFilePermission permission2 = new IsolatedStorageFilePermission(PermissionState.None) {
m_userQuota = IsolatedStoragePermission.min(base.m_userQuota, permission.m_userQuota),
m_machineQuota = IsolatedStoragePermission.min(base.m_machineQuota, permission.m_machineQuota),
m_expirationDays = IsolatedStoragePermission.min(base.m_expirationDays, permission.m_expirationDays),
m_permanentData = base.m_permanentData && permission.m_permanentData,
m_allowed = (IsolatedStorageContainment) ((int) IsolatedStoragePermission.min((long) base.m_allowed, (long) permission.m_allowed))
};
if ((((permission2.m_userQuota == 0L) && (permission2.m_machineQuota == 0L)) && ((permission2.m_expirationDays == 0L) && !permission2.m_permanentData)) && (permission2.m_allowed == IsolatedStorageContainment.None))
{
return null;
}
return permission2;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:IsolatedStorageFilePermission.cs
示例2: Intersect
public override IPermission Intersect(IPermission target)
{
// Handle the easy cases first.
if(target == null)
{
return target;
}
else if(!(target is IsolatedStorageFilePermission))
{
throw new ArgumentException(_("Arg_PermissionMismatch"));
}
else if(((IsolatedStorageFilePermission)target)
.IsUnrestricted())
{
return Copy();
}
else if(IsUnrestricted())
{
return target.Copy();
}
// Get the minimum quota and containment values.
long quota = ((IsolatedStorageFilePermission)target).userQuota;
if(quota > userQuota)
{
quota = userQuota;
}
IsolatedStorageContainment allowed;
allowed = ((IsolatedStorageFilePermission)target).usageAllowed;
if(((int)allowed) > ((int)usageAllowed))
{
allowed = usageAllowed;
}
// Create a new object and intersect the lists.
IsolatedStorageFilePermission perm;
perm = new IsolatedStorageFilePermission(PermissionState.None);
perm.userQuota = quota;
perm.usageAllowed = allowed;
return perm;
}
示例3: Intersect
public override IPermission Intersect(IPermission target)
{
if(target == null)
{
return target;
}
else if(!(target is PublisherIdentityPermission))
{
throw new ArgumentException(_("Arg_PermissionMismatch"));
}
else if(IsSubsetOf(target))
{
return Copy();
}
else if(target.IsSubsetOf(this))
{
return target.Copy();
}
else
{
return null;
}
}
示例4: CreateSingletonSet
//-----------------------------------------------------------+
// H E L P E R
//-----------------------------------------------------------+
private PermissionSet CreateSingletonSet(IPermission perm)
{
PermissionSet permSet = new PermissionSet(false);
permSet.AddPermission(perm.Copy());
return permSet;
}
示例5: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null)
return null;
else if (!VerifyType(target))
{
throw new
ArgumentException(
Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
);
}
IsolatedStorageFilePermission operand = (IsolatedStorageFilePermission)target;
if(operand.IsUnrestricted())
return Copy();
else if(IsUnrestricted())
return target.Copy();
IsolatedStorageFilePermission intersection;
intersection = new IsolatedStorageFilePermission( PermissionState.None );
intersection.m_userQuota = min(m_userQuota,operand.m_userQuota);
intersection.m_machineQuota = min(m_machineQuota,operand.m_machineQuota);
intersection.m_expirationDays = min(m_expirationDays,operand.m_expirationDays);
intersection.m_permanentData = m_permanentData && operand.m_permanentData;
intersection.m_allowed = (IsolatedStorageContainment)min((long)m_allowed,(long)operand.m_allowed);
if ((intersection.m_userQuota == 0) &&
(intersection.m_machineQuota == 0) &&
(intersection.m_expirationDays == 0) &&
(intersection.m_permanentData == false) &&
(intersection.m_allowed == IsolatedStorageContainment.None))
return null;
return intersection;
}
示例6: Intersect
override public IPermission Intersect(IPermission target) { // used during Deny actions
if (null == target) {
return null;
}
if (target.GetType() != this.GetType()) {
throw ADP.PermissionTypeMismatch();
}
if (this.IsUnrestricted()) { // MDAC 84803, NDPWhidbey 29121
return target.Copy();
}
DBDataPermission operand = (DBDataPermission) target;
if (operand.IsUnrestricted()) { // NDPWhidbey 29121
return this.Copy();
}
DBDataPermission newPermission = (DBDataPermission) operand.Copy();
newPermission._allowBlankPassword &= AllowBlankPassword;
if ((null != _keyvalues) && (null != newPermission._keyvalues)) {
newPermission._keyvalues.Clear();
newPermission._keyvaluetree.Intersect(newPermission._keyvalues, _keyvaluetree);
}
else {
// either target.Add or this.Add have not been called
// return a non-null object so IsSubset calls will fail
newPermission._keyvalues = null;
newPermission._keyvaluetree = null;
}
if (newPermission.IsEmpty()) { // no intersection, MDAC 86773
newPermission = null;
}
return newPermission;
}
示例7: Intersect
public IPermission Intersect(IPermission target)
{
if (target == null)
{
return null;
}
else if (!VerifyType(target))
{
throw new
ArgumentException(
Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
);
}
else if (this.IsUnrestricted())
{
return target.Copy();
}
PrincipalPermission operand = (PrincipalPermission)target;
if (operand.IsUnrestricted())
{
return this.Copy();
}
List<IDRole> idroles = null;
for (int i = 0; i < this.m_array.Length; ++i)
{
for (int j = 0; j < operand.m_array.Length; ++j)
{
if (operand.m_array[j].m_authenticated == this.m_array[i].m_authenticated)
{
if (operand.m_array[j].m_id == null ||
this.m_array[i].m_id == null ||
this.m_array[i].m_id.Equals( operand.m_array[j].m_id ))
{
if (idroles == null)
{
idroles = new List<IDRole>();
}
IDRole idrole = new IDRole();
idrole.m_id = operand.m_array[j].m_id == null ? this.m_array[i].m_id : operand.m_array[j].m_id;
if (operand.m_array[j].m_role == null ||
this.m_array[i].m_role == null ||
this.m_array[i].m_role.Equals( operand.m_array[j].m_role))
{
idrole.m_role = operand.m_array[j].m_role == null ? this.m_array[i].m_role : operand.m_array[j].m_role;
}
else
{
idrole.m_role = "";
}
idrole.m_authenticated = operand.m_array[j].m_authenticated;
idroles.Add( idrole );
}
else if (operand.m_array[j].m_role == null ||
this.m_array[i].m_role == null ||
this.m_array[i].m_role.Equals( operand.m_array[j].m_role))
{
if (idroles == null)
{
idroles = new List<IDRole>();
}
IDRole idrole = new IDRole();
idrole.m_id = "";
idrole.m_role = operand.m_array[j].m_role == null ? this.m_array[i].m_role : operand.m_array[j].m_role;
idrole.m_authenticated = operand.m_array[j].m_authenticated;
idroles.Add( idrole );
}
}
}
}
if (idroles == null)
{
return null;
}
else
{
IDRole[] idrolesArray = new IDRole[idroles.Count];
IEnumerator idrolesEnumerator = idroles.GetEnumerator();
int index = 0;
while (idrolesEnumerator.MoveNext())
{
idrolesArray[index++] = (IDRole)idrolesEnumerator.Current;
}
return new PrincipalPermission( idrolesArray );
}
//.........这里部分代码省略.........
示例8: Intersect
public override IPermission Intersect(IPermission target)
{
if(target == null)
{
return target;
}
else if(!(target is SocketPermission))
{
throw new ArgumentException(S._("Arg_PermissionMismatch"));
}
else if(((SocketPermission)target).IsUnrestricted())
{
return Copy();
}
else if(IsUnrestricted())
{
return target.Copy();
}
else
{
SocketPermission perm = new SocketPermission
(PermissionState.None);
EndpointPermission newInfo;
foreach(EndpointPermission info in permissions)
{
foreach(EndpointPermission info2 in
((SocketPermission)target).permissions)
{
newInfo = Intersect(info, info2);
if(newInfo != null)
{
perm.permissions.Add(newInfo);
}
}
}
return perm;
}
}
示例9: Union
// Form the union of two permission objects.
public override IPermission Union(IPermission target)
{
if(target == null)
{
return Copy();
}
else if(target.GetType() != GetType())
{
throw new ArgumentException(S._("Arg_PermissionMismatch"));
}
else if(IsUnrestricted() ||
((ResourcePermissionBase)target).IsUnrestricted())
{
return (ResourcePermissionBase)Activator.CreateInstance
(GetType(),
new Object [] {PermissionState.Unrestricted});
}
else
{
ResourcePermissionBase perm;
perm = (ResourcePermissionBase)(target.Copy());
foreach(ResourcePermissionBaseEntry entry in permissions)
{
if(!perm.Contains(entry))
{
perm.AddPermissionAccess(entry);
}
}
return perm;
}
}
示例10: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null)
{
return null;
}
if (!base.VerifyType(target))
{
throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName }));
}
if (this.IsUnrestricted())
{
return target.Copy();
}
EnvironmentPermission permission = (EnvironmentPermission) target;
if (permission.IsUnrestricted())
{
return this.Copy();
}
StringExpressionSet set = (this.m_read == null) ? null : this.m_read.Intersect(permission.m_read);
StringExpressionSet set2 = (this.m_write == null) ? null : this.m_write.Intersect(permission.m_write);
if (((set == null) || set.IsEmpty()) && ((set2 == null) || set2.IsEmpty()))
{
return null;
}
return new EnvironmentPermission(PermissionState.None) { m_unrestricted = false, m_read = set, m_write = set2 };
}
示例11: Intersect
public override IPermission Intersect(IPermission target)
{
// Handle the easy cases first.
if(target == null)
{
return target;
}
else if(!(target is UIPermission))
{
throw new ArgumentException(_("Arg_PermissionMismatch"));
}
else if(((UIPermission)target)
.IsUnrestricted())
{
return Copy();
}
else if(IsUnrestricted())
{
return target.Copy();
}
// Get the minimum flag values.
UIPermissionWindow w = ((UIPermission)target).window;
if(((int)w) > ((int)window))
{
w = window;
}
UIPermissionClipboard c = ((UIPermission)target).clipboard;
if(((int)c) > ((int)clipboard))
{
c = clipboard;
}
// Create a new object for the intersection.
if(w == UIPermissionWindow.NoWindows &&
c == UIPermissionClipboard.NoClipboard)
{
return null;
}
else
{
return new UIPermission(w, c);
}
}
示例12: Union
// Create the union of two permission objects.
public override IPermission Union(IPermission target)
{
if(target == null)
{
return Copy();
}
else if(!(target is AspNetHostingPermission))
{
throw new ArgumentException
(S._("Arg_PermissionMismatch"));
}
else if(level > ((AspNetHostingPermission)target).level)
{
return Copy();
}
else
{
return target.Copy();
}
}
示例13: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null)
{
return null;
}
else if (!VerifyType(target))
{
throw new
ArgumentException(
String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_WrongType"), this.GetType().FullName)
);
}
else if (this.IsUnrestricted())
{
return target.Copy();
}
EnvironmentPermission operand = (EnvironmentPermission)target;
if (operand.IsUnrestricted())
{
return this.Copy();
}
StringExpressionSet intersectRead = this.m_read == null ? null : this.m_read.Intersect( operand.m_read );
StringExpressionSet intersectWrite = this.m_write == null ? null : this.m_write.Intersect( operand.m_write );
if ((intersectRead == null || intersectRead.IsEmpty()) &&
(intersectWrite == null || intersectWrite.IsEmpty()))
{
return null;
}
EnvironmentPermission intersectPermission = new EnvironmentPermission(PermissionState.None);
intersectPermission.m_unrestricted = false;
intersectPermission.m_read = intersectRead;
intersectPermission.m_write = intersectWrite;
return intersectPermission;
}
示例14: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null)
{
return null;
}
FileIOPermission permission = target as FileIOPermission;
if (permission == null)
{
throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName }));
}
if (this.IsUnrestricted())
{
return target.Copy();
}
if (permission.IsUnrestricted())
{
return this.Copy();
}
FileIOAccess access = (this.m_read == null) ? null : this.m_read.Intersect(permission.m_read);
FileIOAccess access2 = (this.m_write == null) ? null : this.m_write.Intersect(permission.m_write);
FileIOAccess access3 = (this.m_append == null) ? null : this.m_append.Intersect(permission.m_append);
FileIOAccess access4 = (this.m_pathDiscovery == null) ? null : this.m_pathDiscovery.Intersect(permission.m_pathDiscovery);
FileIOAccess access5 = (this.m_viewAcl == null) ? null : this.m_viewAcl.Intersect(permission.m_viewAcl);
FileIOAccess access6 = (this.m_changeAcl == null) ? null : this.m_changeAcl.Intersect(permission.m_changeAcl);
if (((((access == null) || access.IsEmpty()) && ((access2 == null) || access2.IsEmpty())) && (((access3 == null) || access3.IsEmpty()) && ((access4 == null) || access4.IsEmpty()))) && (((access5 == null) || access5.IsEmpty()) && ((access6 == null) || access6.IsEmpty())))
{
return null;
}
return new FileIOPermission(PermissionState.None) { m_unrestricted = false, m_read = access, m_write = access2, m_append = access3, m_pathDiscovery = access4, m_viewAcl = access5, m_changeAcl = access6 };
}
示例15: Union
/// <include file='doc\URLIdentityPermission.uex' path='docs/doc[@for="UrlIdentityPermission.Union"]/*' />
public override IPermission Union(IPermission target)
{
if (target == null)
{
return this.m_url != null ? this.Copy() : null;
}
else if (!VerifyType(target))
{
throw new
ArgumentException(
String.Format(Environment.GetResourceString("Argument_WrongType"), this.GetType().FullName)
);
}
UrlIdentityPermission operand = (UrlIdentityPermission)target;
if (this.m_url == null)
{
return operand.m_url != null ? target.Copy() : null;
}
else if (operand.m_url == null)
{
return this.Copy();
}
URLString url = (URLString)operand.m_url.Union( this.m_url );
if (url == null)
{
return null;
}
else
{
return new UrlIdentityPermission( url );
}
}