本文整理汇总了C#中AspNetHostingPermissionLevel类的典型用法代码示例。如果您正苦于以下问题:C# AspNetHostingPermissionLevel类的具体用法?C# AspNetHostingPermissionLevel怎么用?C# AspNetHostingPermissionLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AspNetHostingPermissionLevel类属于命名空间,在下文中一共展示了AspNetHostingPermissionLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckAspNetPermission
/// <summary>
///
/// </summary>
/// <param name="level"></param>
/// <param name="message"></param>
public static void CheckAspNetPermission(AspNetHostingPermissionLevel level, string message)
{
if (!HasAspNetPermission(level))
{
throw new HttpException(message);
}
}
示例2: CreateControl
// LinkDemand
public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
{
// no public ctor is available but we know the Count property isn't protected
MethodInfo mi = this.Type.GetProperty ("Count").GetGetMethod ();
Assert.IsNotNull (mi, "Count");
return mi.Invoke (css, null);
}
示例3: CreateControl
// LinkDemand
public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
{
// no public ctor is available but we know that it's properties don't have any restrictions
MethodInfo mi = this.Type.GetProperty ("AcceptTypes").GetGetMethod ();
Assert.IsNotNull (mi, "get_AcceptTypes");
return mi.Invoke (response.Cache.VaryByHeaders, null);
}
示例4: CreateControl
// LinkDemand
public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
{
// no public ctor but we know the properties aren't protected
MethodInfo mi = this.Type.GetProperty ("Visible").GetGetMethod ();
Assert.IsNotNull (mi, "Visible");
return mi.Invoke (pager_style, null);
}
示例5: CreateControlStringCtor
private object CreateControlStringCtor (SecurityAction action, AspNetHostingPermissionLevel level)
{
// not public empty (default) ctor - at least not before 2.0
ConstructorInfo ci = this.Type.GetConstructor (new Type[1] { typeof (string) });
Assert.IsNotNull (ci, ".ctor(string)");
return ci.Invoke (new object[1] { tempFile });
}
示例6: CreateControl
public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
{
if ((level != AspNetHostingPermissionLevel.None) && (action == SecurityAction.PermitOnly))
return UnmanagedCreateControl (action, level);
else
return base.CreateControl (action, level);
}
示例7: CreateControl
// LinkDemand
public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
{
// static class 2.0 / no public ctor before (1.x)
MethodInfo mi = this.Type.GetMethod ("EnumToString");
Assert.IsNotNull (mi, "EnumToString");
return mi.Invoke (null, new object[2] { typeof(SecurityAction), SecurityAction.Demand });
}
示例8: FromXml
public override void FromXml(SecurityElement securityElement)
{
if (securityElement == null)
{
throw new ArgumentNullException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" }));
}
if (!securityElement.Tag.Equals("IPermission"))
{
throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" }));
}
string str = securityElement.Attribute("class");
if (str == null)
{
throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" }));
}
if (str.IndexOf(base.GetType().FullName, StringComparison.Ordinal) < 0)
{
throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" }));
}
if (string.Compare(securityElement.Attribute("version"), "1", StringComparison.OrdinalIgnoreCase) != 0)
{
throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "version" }));
}
string str3 = securityElement.Attribute("Level");
if (str3 == null)
{
this._level = AspNetHostingPermissionLevel.None;
}
else
{
this._level = (AspNetHostingPermissionLevel) Enum.Parse(typeof(AspNetHostingPermissionLevel), str3);
}
}
示例9: GetCurrentTrustLevel
/// <summary>
/// Get the current trust level of the hosted application
/// </summary>
/// <returns></returns>
public static AspNetHostingPermissionLevel GetCurrentTrustLevel()
{
if (_knowTrustLevel) return _trustLevel;
foreach (var trustLevel in new[] {
AspNetHostingPermissionLevel.Unrestricted,
AspNetHostingPermissionLevel.High,
AspNetHostingPermissionLevel.Medium,
AspNetHostingPermissionLevel.Low,
AspNetHostingPermissionLevel.Minimal })
{
try
{
new AspNetHostingPermission(trustLevel).Demand();
}
catch (SecurityException)
{
continue;
}
_trustLevel = trustLevel;
_knowTrustLevel = true;
return _trustLevel;
}
_trustLevel = AspNetHostingPermissionLevel.None;
_knowTrustLevel = true;
return _trustLevel;
}
示例10: CreateControl
// LinkDemand
public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
{
ConstructorInfo ci = this.Type.GetConstructor (new Type[7] { typeof (string), typeof (string),
typeof (int), typeof (string), typeof (string), typeof (string), typeof (BuildMethod) });
Assert.IsNotNull (ci, ".ctor(2xstring,int,3xstring,BuildMethod)");
return ci.Invoke (new object[7] { null, null, null, null, null, null, null });
}
示例11: AspNetHostingPermission
public AspNetHostingPermission (PermissionState state)
{
if (PermissionHelper.CheckPermissionState (state, true) == PermissionState.Unrestricted)
_level = AspNetHostingPermissionLevel.Unrestricted;
else
_level = AspNetHostingPermissionLevel.None;
}
示例12: CreateControl
// LinkDemand
public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
{
// there are no public ctor so we're taking a method that we know isn't protected
// (by a Demand) and call it thru reflection so any linkdemand (on the class) will
// be promoted to a Demand
MethodInfo mi = this.Type.GetProperty ("AllKeys").GetGetMethod ();
return mi.Invoke (appstate, null);
}
示例13: AspNetHostingPermission
public AspNetHostingPermission(PermissionState state)
{
if(state == PermissionState.Unrestricted)
{
this.level = AspNetHostingPermissionLevel.Unrestricted;
}
else
{
this.level = AspNetHostingPermissionLevel.None;
}
}
示例14: HasTrustLevel
public bool HasTrustLevel(AspNetHostingPermissionLevel level)
{
bool hasTrustLevel = true;
try {
new AspNetHostingPermission(level).Demand();
}
catch (SecurityException) {
hasTrustLevel = false;
}
return hasTrustLevel;
}
示例15: CreateControl
public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
{
if ((level != AspNetHostingPermissionLevel.None) && (action == SecurityAction.PermitOnly)) {
try {
return FileIOPermissionCreateControl (action, level);
}
catch (TargetInvocationException tie) {
throw tie;
}
}
else
return CreateControlStringCtor (action, level);
}