本文整理汇总了C#中IPermission.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IPermission.GetType方法的具体用法?C# IPermission.GetType怎么用?C# IPermission.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPermission
的用法示例。
在下文中一共展示了IPermission.GetType方法的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: 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;
}
示例3: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null) return null;
if (target.GetType() != typeof(ConfigurationPermission)) throw ExceptionUtil.ParameterInvalid("target");
// Create an None permission if either this or other is None
if (_permissionState == PermissionState.None) return new ConfigurationPermission(PermissionState.None);
ConfigurationPermission other = (ConfigurationPermission)target;
return new ConfigurationPermission(other._permissionState);
}
示例4: Union
public override IPermission Union(IPermission target)
{
if (target == null) return Copy();
if (target.GetType() != typeof(ConfigurationPermission)) throw ExceptionUtil.ParameterInvalid("target");
// Create an Unrestricted permission if either this or other is unrestricted
if (_permissionState == PermissionState.Unrestricted)
return new ConfigurationPermission(PermissionState.Unrestricted);
ConfigurationPermission other = (ConfigurationPermission)target;
return new ConfigurationPermission(other._permissionState);
}
示例5: GetToken
public static PermissionToken GetToken(IPermission perm)
{
if (perm == null)
return null;
IBuiltInPermission ibPerm = perm as IBuiltInPermission;
if (ibPerm != null)
return s_theTokenFactory.BuiltInGetToken( ibPerm.GetTokenIndex(), perm, null );
else
return s_theTokenFactory.GetToken(perm.GetType(), perm);
}
示例6: Implies
/// <summary>
/// Checks if the specified permission is "implied" by this object.
/// <para>
/// More specifically, this method returns true if:
/// * perm's class is the same as this object's class, and
/// * perm's name equals.
/// </para>
/// </summary>
/// <param name="perm">The permission to check against.</param>
/// <param name="ignore_case">
/// A <see cref="Boolean"/> indicating a case-sensitive or insensitive
/// comparison(<c>true</c> indicates a case-insensitive comparison.)
/// </param>
/// <returns>
/// <c>true</c> if the specified permission is equal to or implied by this
/// permission; otherwise, false.
/// </returns>
public bool Implies(IPermission perm, bool ignore_case) {
if (perm == null || perm.GetType() != GetType()) {
return false;
}
if (ignore_case) {
return
string.Compare(Name, perm.Name,
StringComparison.InvariantCultureIgnoreCase) == 0;
}
return Name == perm.Name;
}
示例7: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null)
{
return null;
}
if (target.GetType() != typeof(ConfigurationPermission))
{
throw ExceptionUtil.ParameterInvalid("target");
}
if (this._permissionState == PermissionState.None)
{
return new ConfigurationPermission(PermissionState.None);
}
ConfigurationPermission permission = (ConfigurationPermission) target;
return new ConfigurationPermission(permission._permissionState);
}
示例8: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null)
{
return null;
}
if (base.GetType() != target.GetType())
{
throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName }));
}
HostProtectionResource resources = this.m_resources & ((HostProtectionPermission) target).m_resources;
if (resources == HostProtectionResource.None)
{
return null;
}
return new HostProtectionPermission(resources);
}
示例9: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null)
{
return null;
}
if (target.GetType() != typeof(AspNetHostingPermission))
{
throw new ArgumentException(SR.GetString("InvalidArgument", new object[] { (target == null) ? "null" : target.ToString(), "target" }));
}
AspNetHostingPermission permission = (AspNetHostingPermission) target;
if (this.Level <= permission.Level)
{
return new AspNetHostingPermission(this.Level);
}
return new AspNetHostingPermission(permission.Level);
}
示例10: Intersect
public override IPermission Intersect(IPermission target)
{
NavigationPermission navigationPermission = target as NavigationPermission;
if (navigationPermission == null)
{
throw new ArgumentException(string.Format("Incorrect permission is passed: '{0}' instead of '{1}'", target.GetType(), base.GetType()));
}
NavigationAccessList navigationAccessList = new NavigationAccessList();
NavigationPermission navigationPermission2 = new NavigationPermission();
foreach (string current in this.AccessInfo.Items)
{
if (navigationPermission.AccessInfo.Items.Contains(current))
{
navigationAccessList.Items.Add(current);
}
}
navigationPermission2.AccessInfo = navigationAccessList;
return navigationPermission2;
}
示例11: IsSubsetOf
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public override bool IsSubsetOf(IPermission target) {
if (target == null) {
return (IsEmpty);
}
if (target.GetType() != this.GetType())
return false;
ResourcePermissionBase targetPermission = (ResourcePermissionBase)target;
if (targetPermission.IsUnrestricted())
return true;
else if (this.IsUnrestricted())
return false;
return IsContentSubset(this.rootTable, targetPermission.rootTable);
}
示例12: GetToken
public static PermissionToken GetToken(IPermission perm)
{
if (perm == null)
{
return null;
}
IBuiltInPermission permission = perm as IBuiltInPermission;
if (permission != null)
{
return s_theTokenFactory.BuiltInGetToken(permission.GetTokenIndex(), perm, null);
}
return s_theTokenFactory.GetToken(perm.GetType(), perm);
}
示例13: ThrowInvalidPermission
internal static void ThrowInvalidPermission (IPermission target, Type expected)
{
string msg = Locale.GetText ("Invalid permission type '{0}', expected type '{1}'.");
msg = String.Format (msg, target.GetType (), expected);
throw new ArgumentException (msg, "target");
}
示例14: Intersect
public override IPermission Intersect(IPermission target)
{
if (target == null)
return null;
if(this.GetType() != target.GetType())
throw new ArgumentException( Environment.GetResourceString("Argument_WrongType", this.GetType().FullName) );
HostProtectionResource newResources = (HostProtectionResource)((uint)this.m_resources & (uint)((HostProtectionPermission)target).m_resources);
if(newResources == HostProtectionResource.None)
return null;
return new HostProtectionPermission(newResources);
}
示例15: IsSubsetOf
} //FromXml()
public override bool IsSubsetOf(IPermission target)
{
if (target == null) return false;
if (typeof(myperm) != target.GetType()) return false;
return true;
} //IsSubsetOf()