本文整理汇总了C#中IPermission类的典型用法代码示例。如果您正苦于以下问题:C# IPermission类的具体用法?C# IPermission怎么用?C# IPermission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPermission类属于命名空间,在下文中一共展示了IPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePermissionElement
internal static SecurityElement CreatePermissionElement(IPermission perm, string permname)
{
SecurityElement element = new SecurityElement("IPermission");
XMLUtil.AddClassAttribute(element, perm.GetType(), permname);
element.AddAttribute("version", "1");
return element;
}
示例2: FrameDescHelper
[System.Security.SecurityCritical] // auto-generated
private static bool FrameDescHelper(FrameSecurityDescriptor secDesc,
IPermission demandIn,
PermissionToken permToken,
RuntimeMethodHandleInternal rmh)
{
return secDesc.CheckDemand((CodeAccessPermission) demandIn, permToken, rmh);
}
示例3: RoleUserController
public RoleUserController(IRoleUser repoRoleUser
, IRole repoRole, IPermission repoPer)
{
dalRoleUser = repoRoleUser;
dalRole = repoRole;
dalPermission = repoPer;
}
示例4: IsSubsetOf
public override bool IsSubsetOf(IPermission target)
{
bool flag;
if (target == null)
{
return !this.unrestricted;
}
try
{
DistributedTransactionPermission permission = (DistributedTransactionPermission) target;
if (!this.unrestricted)
{
return true;
}
if (permission.unrestricted)
{
return true;
}
flag = false;
}
catch (InvalidCastException)
{
throw new ArgumentException(System.Transactions.SR.GetString("ArgumentWrongType"), "target");
}
return flag;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:DistributedTransactionPermission.cs
示例5: TestBase
public TestBase()
{
var builder = new ContainerBuilder();
builder.RegisterType<DatabaseFactory>().As<IDatabaseFactory>().InstancePerLifetimeScope();
builder.RegisterType<UnityOfWork>().As<IUnitOfWork>();
builder.RegisterType<ContactRepostory>().AsImplementedInterfaces();
builder.RegisterType<ContactServices>().AsImplementedInterfaces();
builder.RegisterType<ProductRepository>().AsImplementedInterfaces();
builder.RegisterType<LodgingRepository>().AsImplementedInterfaces();
builder.RegisterType<ResortRepository>().AsImplementedInterfaces();
builder.RegisterType<ProductService>().AsImplementedInterfaces();
builder.RegisterType<LodgingService>().AsImplementedInterfaces();
builder.RegisterType<ResortService>().AsImplementedInterfaces();
#region 权限
builder.RegisterType<PermissionModuleRepository>().AsImplementedInterfaces();
builder.RegisterType<PermissionRoleRepository>().AsImplementedInterfaces();
builder.RegisterType<PermissionReRoleModuleRepostory>().AsImplementedInterfaces();
builder.RegisterType<PermissionSvc>().AsImplementedInterfaces();
#endregion
container= builder.Build();
this.unitOfWork = container.Resolve<IUnitOfWork>();
this.contact=container.Resolve<IContact>();
this.productsvc=container.Resolve<IProduct>();
this.resortSvc = container.Resolve<IResort>();
this.lodgingsvc = container.Resolve<ILodging>();
this.permissionSvc = container.Resolve<IPermission>();
// StartUp();
}
示例6: IsGranted
// Determine if a specific permission has been granted.
public static bool IsGranted(IPermission perm)
{
// Bail out if the requested permission is null.
if(perm == null)
{
return true;
}
// Get the current permission state.
ClrPermissions current = ClrSecurity.GetPermissionsFrom(1);
if(current == null)
{
// Null is equivalent to "unrestricted".
return true;
}
// Build a permission set with just this permission.
PermissionSet set = new PermissionSet(PermissionState.None);
set.AddPermission(perm);
// If "PermitOnly" is set, then only check that set.
if(current.permitOnly != null)
{
return set.IsSubsetOf(current.permitOnly);
}
// The permission must be granted, but not denied.
if(!set.IsSubsetOf(current.granted) ||
set.IsSubsetOf(current.denied))
{
return false;
}
return true;
}
示例7: 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 }));
}
SecurityPermission permission = (SecurityPermission) target;
SecurityPermissionFlag noFlags = SecurityPermissionFlag.NoFlags;
if (permission.IsUnrestricted())
{
if (this.IsUnrestricted())
{
return new SecurityPermission(PermissionState.Unrestricted);
}
noFlags = this.m_flags;
}
else if (this.IsUnrestricted())
{
noFlags = permission.m_flags;
}
else
{
noFlags = this.m_flags & permission.m_flags;
}
if (noFlags == SecurityPermissionFlag.NoFlags)
{
return null;
}
return new SecurityPermission(noFlags);
}
示例8: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null)
return null;
return this.Copy();
}
示例9: Union
//------------------------------------------------------
//
// IPERMISSION IMPLEMENTATION
//
//------------------------------------------------------
public override IPermission Union(IPermission target)
{
if (target == null)
{
return this.Copy();
}
else if (!VerifyType(target))
{
throw new
ArgumentException(
Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
);
}
IsolatedStorageFilePermission operand = (IsolatedStorageFilePermission)target;
if (this.IsUnrestricted() || operand.IsUnrestricted())
{
return new IsolatedStorageFilePermission( PermissionState.Unrestricted );
}
else
{
IsolatedStorageFilePermission union;
union = new IsolatedStorageFilePermission( PermissionState.None );
union.m_userQuota = max(m_userQuota,operand.m_userQuota);
union.m_machineQuota = max(m_machineQuota,operand.m_machineQuota);
union.m_expirationDays = max(m_expirationDays,operand.m_expirationDays);
union.m_permanentData = m_permanentData || operand.m_permanentData;
union.m_allowed = (IsolatedStorageContainment)max((long)m_allowed,(long)operand.m_allowed);
return union;
}
}
示例10: IsSubsetOf
public override bool IsSubsetOf(IPermission target)
{
bool flag;
if (target == null)
{
return (this.access == FileDialogPermissionAccess.None);
}
try
{
FileDialogPermission permission = (FileDialogPermission) target;
if (permission.IsUnrestricted())
{
return true;
}
if (this.IsUnrestricted())
{
return false;
}
int num = ((int) this.access) & 1;
int num2 = ((int) this.access) & 2;
int num3 = ((int) permission.Access) & 1;
int num4 = ((int) permission.Access) & 2;
flag = (num <= num3) && (num2 <= num4);
}
catch (InvalidCastException)
{
throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName }));
}
return flag;
}
示例11: IsSubsetOf
public override bool IsSubsetOf(IPermission target)
{
if (target == null)
{
return ((m_userQuota == 0) &&
(m_machineQuota == 0) &&
(m_expirationDays == 0) &&
(m_permanentData == false) &&
(m_allowed == IsolatedStorageContainment.None));
}
try
{
IsolatedStorageFilePermission operand = (IsolatedStorageFilePermission)target;
if (operand.IsUnrestricted())
return true;
return ((operand.m_userQuota >= m_userQuota) &&
(operand.m_machineQuota >= m_machineQuota) &&
(operand.m_expirationDays >= m_expirationDays) &&
(operand.m_permanentData || !m_permanentData) &&
(operand.m_allowed >= m_allowed));
}
catch (InvalidCastException)
{
throw new
ArgumentException(
Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
);
}
}
示例12: 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
示例13: Intersect
public override IPermission Intersect(IPermission target)
{
//If nothing was passed, return null.
if (null == target)
{
return null;
}
try
{
//Create a new instance of RobocodeInternalPermission from the passed object.
var PassedPermission = (RobocodeInternalPermission) target;
//If one class has an unrestricted value of false, then the
//intersection will have an unrestricted value of false.
//Return the passed class with the unrestricted value of false.
if (!PassedPermission.unrestricted)
{
return target;
}
//Return a copy of the current class if the passed one has
//an unrestricted value of true.
return Copy();
}
//Catch an InvalidCastException.
//Throw ArgumentException to notify the user.
catch (InvalidCastException)
{
throw new ArgumentException("Argument_WrongType", GetType().FullName);
}
}
示例14: GetTokenIndex
// IBuiltInPermission is internal but we can test it's values
// using reflection.
private int GetTokenIndex (IPermission p)
{
Type t = p.GetType ();
int result = (int) t.InvokeMember ("System.Security.Permissions.IBuiltInPermission.GetTokenIndex",
BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
null, p, null);
return result;
}
示例15: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null)
return null;
if (!(target is GacIdentityPermission))
throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName));
return this.Copy();
}