// Methods
        public override IPermission CreatePermission()
        {
#if NET_2_1
            return(null);
#else
            if (this.Unrestricted)
            {
                return(new StrongNameIdentityPermission(PermissionState.Unrestricted));
            }

            if ((name == null) && (key == null) && (version == null))
            {
                return(new StrongNameIdentityPermission(PermissionState.None));
            }

            if (key == null)
            {
                throw new ArgumentException(Locale.GetText(
                                                "PublicKey is required"));
            }
            StrongNamePublicKeyBlob blob = StrongNamePublicKeyBlob.FromString(key);

            Version v = null;
            if (version != null)
            {
                v = new Version(version);
            }

            return(new StrongNameIdentityPermission(blob, name, v));
#endif
        }
Ejemplo n.º 2
0
        private SNIP FromSecurityElement(SecurityElement se)
        {
            string name = se.Attribute("Name");
            StrongNamePublicKeyBlob publickey = StrongNamePublicKeyBlob.FromString(se.Attribute("PublicKeyBlob"));
            string  v = se.Attribute("AssemblyVersion");
            Version assemblyVersion = (v == null) ? null : new Version(v);

            return(new SNIP(publickey, name, assemblyVersion));
        }
        private StrongNameIdentityPermission.SNIP FromSecurityElement(SecurityElement se)
        {
            string name = se.Attribute("Name");
            StrongNamePublicKeyBlob pk = StrongNamePublicKeyBlob.FromString(se.Attribute("PublicKeyBlob"));
            string  text    = se.Attribute("AssemblyVersion");
            Version version = (text != null) ? new Version(text) : null;

            return(new StrongNameIdentityPermission.SNIP(pk, name, version));
        }