private AssemblyName(AssemblyName other)
			{
				codeBase = other.codeBase;
				culture = other.culture;
				flags = other.flags;
				name = other.name;
				hashAlg = other.hashAlg;
				keyPair = other.keyPair;
				version = (version == null
					? null : (Version)(other.version.Clone()));
				versionCompat = other.versionCompat;
				publicKey = (other.publicKey == null
					? null : (byte[])(other.publicKey.Clone()));
				publicKeyToken = (other.publicKeyToken == null
					? null : (byte[])(other.publicKeyToken.Clone()));
			}
	// Constructor.
	public AssemblyName()
			{
				versionCompat = AssemblyVersionCompatibility.SameMachine;
			}
	// Handle a deserialization callback on this object.
	public void OnDeserialization(Object sender)
			{
				if(info == null)
				{
					return;
				}
				name = info.GetString("_Name");
				publicKey = (byte[])(info.GetValue
					("_PublicKey", typeof(byte[])));
				publicKeyToken = (byte[])(info.GetValue
					("_PublicKeyToken", typeof(byte[])));
				int cultureID = info.GetInt32("_CultureInfo");
				if(cultureID != -1)
				{
					culture = new CultureInfo(cultureID);
				}
				else
				{
					culture = null;
				}
				codeBase = info.GetString("_CodeBase");
				version = (Version)(info.GetValue("_Version", typeof(Version)));
				hashAlg = (AssemblyHashAlgorithm)(info.GetValue
					("_HashAlgorithm", typeof(AssemblyHashAlgorithm)));
				keyPair = (StrongNameKeyPair)(info.GetValue
					("_StrongNameKeyPair", typeof(StrongNameKeyPair)));
				versionCompat = (AssemblyVersionCompatibility)(info.GetValue
					("_VersionCompatibility",
					 typeof(AssemblyVersionCompatibility)));
				flags = (AssemblyNameFlags)(info.GetValue
					("_Flags", typeof(AssemblyNameFlags)));
			}
Example #4
0
#pragma warning restore 169		
		
		public AssemblyName ()
		{
			// defaults
			versioncompat = AssemblyVersionCompatibility.SameMachine;
		}
Example #5
0
		internal AssemblyName (SerializationInfo si, StreamingContext sc)
		{
			name = si.GetString ("_Name");
			codebase = si.GetString ("_CodeBase");
			version = (Version)si.GetValue ("_Version", typeof (Version));
			publicKey = (byte[])si.GetValue ("_PublicKey", typeof (byte[]));
			keyToken = (byte[])si.GetValue ("_PublicKeyToken", typeof (byte[]));
			hashalg = (AssemblyHashAlgorithm)si.GetValue ("_HashAlgorithm", typeof (AssemblyHashAlgorithm));
			keypair = (StrongNameKeyPair)si.GetValue ("_StrongNameKeyPair", typeof (StrongNameKeyPair));
			versioncompat = (AssemblyVersionCompatibility)si.GetValue ("_VersionCompatibility", typeof (AssemblyVersionCompatibility));
			flags = (AssemblyNameFlags)si.GetValue ("_Flags", typeof (AssemblyNameFlags));
			int lcid = si.GetInt32 ("_CultureInfo");
			if (lcid != -1) cultureinfo = new CultureInfo (lcid);
		}
Example #6
0
 public void OnDeserialization(object sender)
 {
     if (this.m_siInfo != null)
     {
         this._Name = this.m_siInfo.GetString("_Name");
         this._PublicKey = (byte[]) this.m_siInfo.GetValue("_PublicKey", typeof(byte[]));
         this._PublicKeyToken = (byte[]) this.m_siInfo.GetValue("_PublicKeyToken", typeof(byte[]));
         int culture = this.m_siInfo.GetInt32("_CultureInfo");
         if (culture != -1)
         {
             this._CultureInfo = new System.Globalization.CultureInfo(culture);
         }
         this._CodeBase = this.m_siInfo.GetString("_CodeBase");
         this._Version = (System.Version) this.m_siInfo.GetValue("_Version", typeof(System.Version));
         this._HashAlgorithm = (AssemblyHashAlgorithm) this.m_siInfo.GetValue("_HashAlgorithm", typeof(AssemblyHashAlgorithm));
         this._StrongNameKeyPair = (StrongNameKeyPair) this.m_siInfo.GetValue("_StrongNameKeyPair", typeof(StrongNameKeyPair));
         this._VersionCompatibility = (AssemblyVersionCompatibility) this.m_siInfo.GetValue("_VersionCompatibility", typeof(AssemblyVersionCompatibility));
         this._Flags = (AssemblyNameFlags) this.m_siInfo.GetValue("_Flags", typeof(AssemblyNameFlags));
         try
         {
             this._HashAlgorithmForControl = (AssemblyHashAlgorithm) this.m_siInfo.GetValue("_HashAlgorithmForControl", typeof(AssemblyHashAlgorithm));
             this._HashForControl = (byte[]) this.m_siInfo.GetValue("_HashForControl", typeof(byte[]));
         }
         catch (SerializationException)
         {
             this._HashAlgorithmForControl = AssemblyHashAlgorithm.None;
             this._HashForControl = null;
         }
         this.m_siInfo = null;
     }
 }
Example #7
0
 internal void Init(string name, byte[] publicKey, byte[] publicKeyToken, System.Version version, System.Globalization.CultureInfo cultureInfo, AssemblyHashAlgorithm hashAlgorithm, AssemblyVersionCompatibility versionCompatibility, string codeBase, AssemblyNameFlags flags, StrongNameKeyPair keyPair)
 {
     this._Name = name;
     if (publicKey != null)
     {
         this._PublicKey = new byte[publicKey.Length];
         Array.Copy(publicKey, this._PublicKey, publicKey.Length);
     }
     if (publicKeyToken != null)
     {
         this._PublicKeyToken = new byte[publicKeyToken.Length];
         Array.Copy(publicKeyToken, this._PublicKeyToken, publicKeyToken.Length);
     }
     if (version != null)
     {
         this._Version = (System.Version)version.Clone();
     }
     this._CultureInfo          = cultureInfo;
     this._HashAlgorithm        = hashAlgorithm;
     this._VersionCompatibility = versionCompatibility;
     this._CodeBase             = codeBase;
     this._Flags             = flags;
     this._StrongNameKeyPair = keyPair;
 }
Example #8
0
        internal void Init(String name, 
                           byte[] publicKey,
                           byte[] publicKeyToken,
                           Version version,
                           CultureInfo cultureInfo,
                           AssemblyHashAlgorithm hashAlgorithm,
                           AssemblyVersionCompatibility versionCompatibility,
                           String codeBase,
                           AssemblyNameFlags flags,
                           StrongNameKeyPair keyPair) // Null if ref, matching Assembly if def
        {
            _Name = name;

            if (publicKey != null) {
                _PublicKey = new byte[publicKey.Length];
                Array.Copy(publicKey, _PublicKey, publicKey.Length);
            }
    
            if (publicKeyToken != null) {
                _PublicKeyToken = new byte[publicKeyToken.Length];
                Array.Copy(publicKeyToken, _PublicKeyToken, publicKeyToken.Length);
            }
    
            if (version != null)
                _Version = (Version) version.Clone();

            _CultureInfo = cultureInfo;
            _HashAlgorithm = hashAlgorithm;
            _VersionCompatibility = versionCompatibility;
            _CodeBase = codeBase;
            _Flags = flags;
            _StrongNameKeyPair = keyPair;
        }
Example #9
0
 /// <include file='doc\AssemblyName.uex' path='docs/doc[@for="AssemblyName.AssemblyName"]/*' />
 public AssemblyName()
 {
     _HashAlgorithm        = AssemblyHashAlgorithm.None;
     _VersionCompatibility = AssemblyVersionCompatibility.SameMachine;
     _Flags = AssemblyNameFlags.None;
 }
Example #10
0
 public AssemblyName()
 {
     // defaults
     versioncompat = AssemblyVersionCompatibility.SameMachine;
 }
Example #11
0
        internal unsafe void FillName(MonoAssemblyName *native, string codeBase, bool addVersion, bool addPublickey, bool defaultToken, bool assemblyRef)
        {
            this.name = RuntimeMarshal.PtrToUtf8String(native->name);

            this.major    = native->major;
            this.minor    = native->minor;
            this.build    = native->build;
            this.revision = native->revision;

            this.flags = (AssemblyNameFlags)native->flags;

            this.hashalg = (AssemblyHashAlgorithm)native->hash_alg;

            this.versioncompat          = AssemblyVersionCompatibility.SameMachine;
            this.processor_architecture = (ProcessorArchitecture)native->arch;

            if (addVersion)
            {
                this.version = new Version(this.major, this.minor, this.build, this.revision);
            }

            this.codebase = codeBase;

#if NETCORE
            if (native->culture != IntPtr.Zero)
            {
                this.cultureinfo = CultureInfo.GetCultureInfo(RuntimeMarshal.PtrToUtf8String(native->culture));
            }
#else
            if (native->culture != IntPtr.Zero)
            {
                this.cultureinfo = CultureInfo.CreateCulture(RuntimeMarshal.PtrToUtf8String(native->culture), assemblyRef);
            }
#endif

            if (native->public_key != IntPtr.Zero)
            {
                this.publicKey = RuntimeMarshal.DecodeBlobArray(native->public_key);
                this.flags    |= AssemblyNameFlags.PublicKey;
            }
            else if (addPublickey)
            {
                this.publicKey = EmptyArray <byte> .Value;
                this.flags    |= AssemblyNameFlags.PublicKey;
            }

            // MonoAssemblyName keeps the public key token as an hexadecimal string
            if (native->public_key_token [0] != 0)
            {
                byte[] keyToken = new byte [8];
                for (int i = 0, j = 0; i < 8; ++i)
                {
                    keyToken [i]  = (byte)(RuntimeMarshal.AsciHexDigitValue(native->public_key_token [j++]) << 4);
                    keyToken [i] |= (byte)RuntimeMarshal.AsciHexDigitValue(native->public_key_token [j++]);
                }
                this.keyToken = keyToken;
            }
            else if (defaultToken)
            {
                this.keyToken = EmptyArray <byte> .Value;
            }
        }
Example #12
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Reflection.AssemblyName" /> class.</summary>
 public AssemblyName()
 {
     this.versioncompat = AssemblyVersionCompatibility.SameMachine;
 }
        public static void Translate(this ITranslator translator, ref AssemblyName assemblyName)
        {
            if (!translator.TranslateNullable(assemblyName))
            {
                return;
            }

            string                       name    = null;
            Version                      version = null;
            AssemblyNameFlags            flags   = default;
            ProcessorArchitecture        processorArchitecture = default;
            CultureInfo                  cultureInfo           = null;
            AssemblyHashAlgorithm        hashAlgorithm         = default;
            AssemblyVersionCompatibility versionCompatibility  = default;
            string                       codeBase = null;

            byte[] publicKey      = null;
            byte[] publicKeyToken = null;

            if (translator.Mode == TranslationDirection.WriteToStream)
            {
                name    = assemblyName.Name;
                version = assemblyName.Version;
                flags   = assemblyName.Flags;
                processorArchitecture = assemblyName.ProcessorArchitecture;
                cultureInfo           = assemblyName.CultureInfo;
                hashAlgorithm         = assemblyName.HashAlgorithm;
                versionCompatibility  = assemblyName.VersionCompatibility;
                codeBase = assemblyName.CodeBase;

                publicKey      = assemblyName.GetPublicKey(); // TODO: no need to serialize, public key is not used anywhere in context of RAR, only public key token
                publicKeyToken = assemblyName.GetPublicKeyToken();
            }

            translator.Translate(ref name);
            translator.Translate(ref version);
            translator.TranslateEnum(ref flags, (int)flags);
            translator.TranslateEnum(ref processorArchitecture, (int)processorArchitecture);
            translator.Translate(ref cultureInfo);
            translator.TranslateEnum(ref hashAlgorithm, (int)hashAlgorithm);
            translator.TranslateEnum(ref versionCompatibility, (int)versionCompatibility);
            translator.Translate(ref codeBase);

            translator.Translate(ref publicKey);
            translator.Translate(ref publicKeyToken);

            if (translator.Mode == TranslationDirection.ReadFromStream)
            {
                assemblyName = new AssemblyName
                {
                    Name    = name,
                    Version = version,
                    Flags   = flags,
                    ProcessorArchitecture = processorArchitecture,
                    CultureInfo           = cultureInfo,
                    HashAlgorithm         = hashAlgorithm,
                    VersionCompatibility  = versionCompatibility,
                    CodeBase = codeBase,
                    // AssemblyName.KeyPair is not used anywhere, additionally StrongNameKeyPair is not supported in .net core 5-
                    // and throws platform not supported exception when serialized or deserialized
                    KeyPair = null,
                };

                assemblyName.SetPublicKey(publicKey);
                assemblyName.SetPublicKeyToken(publicKeyToken);
            }
        }
Example #14
0
		internal unsafe void FillName (MonoAssemblyName *native, string codeBase, bool addVersion, bool addPublickey, bool defaultToken)
		{
			this.name = RuntimeMarshal.PtrToUtf8String (native->name);

			this.major = native->major;
			this.minor = native->minor;
			this.build = native->build;
			this.revision = native->revision;

			this.flags = (AssemblyNameFlags)native->flags;

			this.hashalg = (AssemblyHashAlgorithm)native->hash_alg;

			this.versioncompat = AssemblyVersionCompatibility.SameMachine;
			this.processor_architecture = (ProcessorArchitecture)native->arch;

			if (addVersion)
				this.version = new Version (this.major, this.minor, this.build, this.revision);

			this.codebase = codeBase;

			if (native->culture != IntPtr.Zero)
				this.cultureinfo = CultureInfo.CreateCulture ( RuntimeMarshal.PtrToUtf8String (native->culture), false);

			if (native->public_key != IntPtr.Zero) {
				this.publicKey = RuntimeMarshal.DecodeBlobArray (native->public_key);
				this.flags |= AssemblyNameFlags.PublicKey;
			} else if (addPublickey) {
				this.publicKey = EmptyArray<byte>.Value;
				this.flags |= AssemblyNameFlags.PublicKey;
			}

			// MonoAssemblyName keeps the public key token as an hexadecimal string
			if (native->public_key_token [0] != 0) {
				byte[] keyToken = new byte [8];
				for (int i = 0, j = 0; i < 8; ++i) {
					keyToken [i] = (byte)(RuntimeMarshal.AsciHexDigitValue (native->public_key_token [j++]) << 4);
					keyToken [i] |= (byte)RuntimeMarshal.AsciHexDigitValue (native->public_key_token [j++]);
				}
				this.keyToken = keyToken;
			} else if (defaultToken) {
				this.keyToken = EmptyArray<byte>.Value;
			}
		}
Example #15
0
 public AssemblyName()
 {
     _versionCompatibility = AssemblyVersionCompatibility.SameMachine;
 }
Example #16
0
        public void OnDeserialization(Object sender)
        {
            // Deserialization has already been performed
            if (m_siInfo == null)
                return;

            _Name = m_siInfo.GetString("_Name");
            _PublicKey = (byte[]) m_siInfo.GetValue("_PublicKey", typeof(byte[]));
            _PublicKeyToken = (byte[]) m_siInfo.GetValue("_PublicKeyToken", typeof(byte[]));
#if FEATURE_USE_LCID
            int lcid = (int)m_siInfo.GetInt32("_CultureInfo");
            if (lcid != -1)
                _CultureInfo = new CultureInfo(lcid);
#endif

            _CodeBase = m_siInfo.GetString("_CodeBase");
            _Version = (Version) m_siInfo.GetValue("_Version", typeof(Version));
            _HashAlgorithm = (AssemblyHashAlgorithm) m_siInfo.GetValue("_HashAlgorithm", typeof(AssemblyHashAlgorithm));
            _StrongNameKeyPair = (StrongNameKeyPair) m_siInfo.GetValue("_StrongNameKeyPair", typeof(StrongNameKeyPair));
            _VersionCompatibility = (AssemblyVersionCompatibility)m_siInfo.GetValue("_VersionCompatibility", typeof(AssemblyVersionCompatibility));
            _Flags = (AssemblyNameFlags) m_siInfo.GetValue("_Flags", typeof(AssemblyNameFlags));

            try {
                _HashAlgorithmForControl = (AssemblyHashAlgorithm) m_siInfo.GetValue("_HashAlgorithmForControl", typeof(AssemblyHashAlgorithm));
                _HashForControl = (byte[]) m_siInfo.GetValue("_HashForControl", typeof(byte[]));    
            }
            catch (SerializationException) { // RTM did not have these defined
                _HashAlgorithmForControl = AssemblyHashAlgorithm.None;
                _HashForControl = null;
            }

            m_siInfo = null;
        }
Example #17
0
 internal void Init(string name, byte[] publicKey, byte[] publicKeyToken, System.Version version, System.Globalization.CultureInfo cultureInfo, AssemblyHashAlgorithm hashAlgorithm, AssemblyVersionCompatibility versionCompatibility, string codeBase, AssemblyNameFlags flags, StrongNameKeyPair keyPair)
 {
     this._Name = name;
     if (publicKey != null)
     {
         this._PublicKey = new byte[publicKey.Length];
         Array.Copy(publicKey, this._PublicKey, publicKey.Length);
     }
     if (publicKeyToken != null)
     {
         this._PublicKeyToken = new byte[publicKeyToken.Length];
         Array.Copy(publicKeyToken, this._PublicKeyToken, publicKeyToken.Length);
     }
     if (version != null)
     {
         this._Version = (System.Version) version.Clone();
     }
     this._CultureInfo = cultureInfo;
     this._HashAlgorithm = hashAlgorithm;
     this._VersionCompatibility = versionCompatibility;
     this._CodeBase = codeBase;
     this._Flags = flags;
     this._StrongNameKeyPair = keyPair;
 }
Example #18
0
 public AssemblyName()
 { 
     _HashAlgorithm = AssemblyHashAlgorithm.None;
     _VersionCompatibility = AssemblyVersionCompatibility.SameMachine;
     _Flags = AssemblyNameFlags.None;
 }
Example #19
0
        /// <include file='doc\AssemblyName.uex' path='docs/doc[@for="AssemblyName.OnDeserialization"]/*' />
        public void OnDeserialization(Object sender)
        {
            // Deserialization has already been performed
            if (m_siInfo == null)
                return;

            _Name = m_siInfo.GetString("_Name");
            _PublicKey = (byte[]) m_siInfo.GetValue("_PublicKey", typeof(byte[]));
            _PublicKeyToken = (byte[]) m_siInfo.GetValue("_PublicKeyToken", typeof(byte[]));

            int lcid = (int)m_siInfo.GetInt32("_CultureInfo");
            if (lcid != -1)
                _CultureInfo = new CultureInfo(lcid);

            _CodeBase = m_siInfo.GetString("_CodeBase");
            _Version = (Version) m_siInfo.GetValue("_Version", typeof(Version));
            _HashAlgorithm = (AssemblyHashAlgorithm) m_siInfo.GetValue("_HashAlgorithm", typeof(AssemblyHashAlgorithm));
            _StrongNameKeyPair = (StrongNameKeyPair) m_siInfo.GetValue("_StrongNameKeyPair", typeof(StrongNameKeyPair));
            _Assembly = null;
            _VersionCompatibility = (AssemblyVersionCompatibility)m_siInfo.GetValue("_VersionCompatibility", typeof(AssemblyVersionCompatibility));
            _Flags = (AssemblyNameFlags) m_siInfo.GetValue("_Flags", typeof(AssemblyNameFlags));
    
            m_siInfo = null;
        }