Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ========================//ELF\\=====================================
- #XMPP: hakt@xmpp.jp
- #Wire: @hakt
- =====================================================================
- using System;
- using MS.Internal.WindowsBase;
- namespace System.Security.Permissions
- {
- /// <summary>The <see cref="T:System.Security.Permissions.WebBrowserPermission" /> object controls the ability to create the WebBrowser control.</summary>
- // Token: 0x020001ED RID: 493
- [Serializable]
- public sealed class WebBrowserPermission : CodeAccessPermission, IUnrestrictedPermission
- {
- /// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.WebBrowserPermission" /> class.</summary>
- // Token: 0x0600145D RID: 5213 RVA: 0x00049D58 File Offset: 0x00047F58
- public WebBrowserPermission()
- {
- this._webBrowserPermissionLevel = WebBrowserPermissionLevel.Safe;
- }
- /// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.WebBrowserPermission" /> class by specifying a permission state.</summary>
- /// <param name="state">An enumerated value of <see cref="T:System.Security.Permissions.PermissionState" />.</param>
- // Token: 0x0600145E RID: 5214 RVA: 0x00049D67 File Offset: 0x00047F67
- public WebBrowserPermission(PermissionState state)
- {
- if (state == PermissionState.Unrestricted)
- {
- this._webBrowserPermissionLevel = WebBrowserPermissionLevel.Unrestricted;
- return;
- }
- if (state == PermissionState.None)
- {
- this._webBrowserPermissionLevel = WebBrowserPermissionLevel.None;
- return;
- }
- throw new ArgumentException(SR.Get("InvalidPermissionState"));
- }
- /// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.WebBrowserPermission" /> class by specifying the Web browser permission level.</summary>
- /// <param name="webBrowserPermissionLevel">An enumerated value of <see cref="T:System.Security.Permissions.WebBrowserPermissionLevel" />.</param>
- // Token: 0x0600145F RID: 5215 RVA: 0x00049D95 File Offset: 0x00047F95
- public WebBrowserPermission(WebBrowserPermissionLevel webBrowserPermissionLevel)
- {
- WebBrowserPermission.VerifyWebBrowserPermissionLevel(webBrowserPermissionLevel);
- this._webBrowserPermissionLevel = webBrowserPermissionLevel;
- }
- /// <summary>Returns a value indicating whether the current permission is unrestricted.</summary>
- /// <returns>
- /// <see langword="true" /> if the <see cref="P:System.Security.Permissions.WebBrowserPermission.Level" /> property is set to <see cref="F:System.Security.Permissions.WebBrowserPermissionLevel.Unrestricted" />; otherwise, <see langword="false" />.</returns>
- // Token: 0x06001460 RID: 5216 RVA: 0x00049DAA File Offset: 0x00047FAA
- public bool IsUnrestricted()
- {
- return this._webBrowserPermissionLevel == WebBrowserPermissionLevel.Unrestricted;
- }
- /// <summary>Determines whether the current permission is a subset of the specified permission.</summary>
- /// <param name="target">A permission that is to be tested for the subset relationship. This permission must be of the same type as the current permission.</param>
- /// <returns>
- /// <see langword="true" /> if the current permission is a subset of the specified permission; otherwise, <see langword="false" />.</returns>
- // Token: 0x06001461 RID: 5217 RVA: 0x00049DB8 File Offset: 0x00047FB8
- public override bool IsSubsetOf(IPermission target)
- {
- if (target == null)
- {
- return this._webBrowserPermissionLevel == WebBrowserPermissionLevel.None;
- }
- WebBrowserPermission webBrowserPermission = target as WebBrowserPermission;
- if (webBrowserPermission != null)
- {
- return this._webBrowserPermissionLevel <= webBrowserPermission._webBrowserPermissionLevel;
- }
- throw new ArgumentException(SR.Get("TargetNotWebBrowserPermissionLevel"));
- }
- /// <summary>Creates and returns a permission that is the intersection of the current permission and the specified permission.</summary>
- /// <param name="target">A permission to intersect with the current permission. It must be of the same type as the current permission.</param>
- /// <returns>The intersection of two permissions is a permission that describes the state that they both describe in common. Only a demand that passes both original permissions will be valid for the intersected permission.</returns>
- // Token: 0x06001462 RID: 5218 RVA: 0x00049E00 File Offset: 0x00048000
- public override IPermission Intersect(IPermission target)
- {
- if (target == null)
- {
- return null;
- }
- WebBrowserPermission webBrowserPermission = target as WebBrowserPermission;
- if (webBrowserPermission == null)
- {
- throw new ArgumentException(SR.Get("TargetNotWebBrowserPermissionLevel"));
- }
- WebBrowserPermissionLevel webBrowserPermissionLevel = (this._webBrowserPermissionLevel < webBrowserPermission._webBrowserPermissionLevel) ? this._webBrowserPermissionLevel : webBrowserPermission._webBrowserPermissionLevel;
- if (webBrowserPermissionLevel == WebBrowserPermissionLevel.None)
- {
- return null;
- }
- return new WebBrowserPermission(webBrowserPermissionLevel);
- }
- /// <summary>Creates a permission that is the union of the current permission and the specified permission.</summary>
- /// <param name="target">A permission to combine with the current permission. It must be of the same type as the current permission.</param>
- /// <returns>A new permission that represents the union of the current permission and the specified permission.</returns>
- // Token: 0x06001463 RID: 5219 RVA: 0x00049E54 File Offset: 0x00048054
- public override IPermission Union(IPermission target)
- {
- if (target == null)
- {
- return this.Copy();
- }
- WebBrowserPermission webBrowserPermission = target as WebBrowserPermission;
- if (webBrowserPermission == null)
- {
- throw new ArgumentException(SR.Get("TargetNotWebBrowserPermissionLevel"));
- }
- WebBrowserPermissionLevel webBrowserPermissionLevel = (this._webBrowserPermissionLevel > webBrowserPermission._webBrowserPermissionLevel) ? this._webBrowserPermissionLevel : webBrowserPermission._webBrowserPermissionLevel;
- if (webBrowserPermissionLevel == WebBrowserPermissionLevel.None)
- {
- return null;
- }
- return new WebBrowserPermission(webBrowserPermissionLevel);
- }
- /// <summary>Creates and returns an identical copy of the current permission.</summary>
- /// <returns>A copy of the current permission.</returns>
- // Token: 0x06001464 RID: 5220 RVA: 0x00049EAD File Offset: 0x000480AD
- public override IPermission Copy()
- {
- return new WebBrowserPermission(this._webBrowserPermissionLevel);
- }
- /// <summary>Creates an XML encoding of the permission and its current state.</summary>
- /// <returns>An XML encoding of the permission, including any state information.</returns>
- // Token: 0x06001465 RID: 5221 RVA: 0x00049EBC File Offset: 0x000480BC
- public override SecurityElement ToXml()
- {
- SecurityElement securityElement = new SecurityElement("IPermission");
- securityElement.AddAttribute("class", base.GetType().AssemblyQualifiedName);
- securityElement.AddAttribute("version", "1");
- if (this.IsUnrestricted())
- {
- securityElement.AddAttribute("Unrestricted", bool.TrueString);
- }
- else
- {
- securityElement.AddAttribute("Level", this._webBrowserPermissionLevel.ToString());
- }
- return securityElement;
- }
- /// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary>
- /// <param name="securityElement">The XML encoding to use to reconstruct the permission.</param>
- // Token: 0x06001466 RID: 5222 RVA: 0x00049F34 File Offset: 0x00048134
- public override void FromXml(SecurityElement securityElement)
- {
- if (securityElement == null)
- {
- throw new ArgumentNullException("securityElement");
- }
- string text = securityElement.Attribute("class");
- if (text == null || text.IndexOf(base.GetType().FullName, StringComparison.Ordinal) == -1)
- {
- throw new ArgumentNullException("securityElement");
- }
- string text2 = securityElement.Attribute("Unrestricted");
- if (text2 != null && bool.Parse(text2))
- {
- this._webBrowserPermissionLevel = WebBrowserPermissionLevel.Unrestricted;
- return;
- }
- this._webBrowserPermissionLevel = WebBrowserPermissionLevel.None;
- string text3 = securityElement.Attribute("Level");
- if (text3 != null)
- {
- this._webBrowserPermissionLevel = (WebBrowserPermissionLevel)Enum.Parse(typeof(WebBrowserPermissionLevel), text3);
- return;
- }
- throw new ArgumentException(SR.Get("BadXml", new object[]
- {
- "level"
- }));
- }
- /// <summary>Gets or sets the current value of the Web browser permission level.</summary>
- /// <returns>The current value of the Web browser permission level.</returns>
- // Token: 0x17000421 RID: 1057
- // (get) Token: 0x06001467 RID: 5223 RVA: 0x00049FEC File Offset: 0x000481EC
- // (set) Token: 0x06001468 RID: 5224 RVA: 0x00049FF4 File Offset: 0x000481F4
- public WebBrowserPermissionLevel Level
- {
- get
- {
- return this._webBrowserPermissionLevel;
- }
- set
- {
- WebBrowserPermission.VerifyWebBrowserPermissionLevel(value);
- this._webBrowserPermissionLevel = value;
- }
- }
- // Token: 0x06001469 RID: 5225 RVA: 0x0004A003 File Offset: 0x00048203
- internal static void VerifyWebBrowserPermissionLevel(WebBrowserPermissionLevel level)
- {
- if (level < WebBrowserPermissionLevel.None || level > WebBrowserPermissionLevel.Unrestricted)
- {
- throw new ArgumentException(SR.Get("InvalidPermissionLevel"));
- }
- }
- // Token: 0x0400154E RID: 5454
- private WebBrowserPermissionLevel _webBrowserPermissionLevel;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement