Exemplo n.º 1
0
        public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
        {
            if (customBuilder == null)
            {
                throw new ArgumentNullException("customBuilder");
            }

            string attrname = customBuilder.Ctor.ReflectedType.FullName;

            byte[] data;
            int    pos;

            if (attrname == "System.Reflection.AssemblyVersionAttribute")
            {
                version = create_assembly_version(customBuilder.string_arg());
                return;
            }
            else if (attrname == "System.Reflection.AssemblyCultureAttribute")
            {
                culture = GetCultureString(customBuilder.string_arg());
            }
            else if (attrname == "System.Reflection.AssemblyAlgorithmIdAttribute")
            {
                data   = customBuilder.Data;
                pos    = 2;
                algid  = (uint)data [pos];
                algid |= ((uint)data [pos + 1]) << 8;
                algid |= ((uint)data [pos + 2]) << 16;
                algid |= ((uint)data [pos + 3]) << 24;
            }
            else if (attrname == "System.Reflection.AssemblyFlagsAttribute")
            {
                data   = customBuilder.Data;
                pos    = 2;
                flags  = (uint)data [pos];
                flags |= ((uint)data [pos + 1]) << 8;
                flags |= ((uint)data [pos + 2]) << 16;
                flags |= ((uint)data [pos + 3]) << 24;
                return;
            }

            if (cattrs != null)
            {
                CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
                cattrs.CopyTo(new_array, 0);
                new_array [cattrs.Length] = customBuilder;
                cattrs = new_array;
            }
            else
            {
                cattrs     = new CustomAttributeBuilder [1];
                cattrs [0] = customBuilder;
            }
        }
Exemplo n.º 2
0
		public void SetCustomAttribute( CustomAttributeBuilder customBuilder) 
		{
			if (customBuilder == null)
				throw new ArgumentNullException ("customBuilder");

			if (IsCompilerContext) {
				string attrname = customBuilder.Ctor.ReflectedType.FullName;
				byte [] data;
				int pos;

				if (attrname == "System.Reflection.AssemblyVersionAttribute") {
					version = create_assembly_version (customBuilder.string_arg ());
					return;
				} else if (attrname == "System.Reflection.AssemblyCultureAttribute") {
					culture = GetCultureString (customBuilder.string_arg ());
				} else if (attrname == "System.Reflection.AssemblyAlgorithmIdAttribute") {
					data = customBuilder.Data;
					pos = 2;
					algid = (uint) data [pos];
					algid |= ((uint) data [pos + 1]) << 8;
					algid |= ((uint) data [pos + 2]) << 16;
					algid |= ((uint) data [pos + 3]) << 24;
				} else if (attrname == "System.Reflection.AssemblyFlagsAttribute") {
					data = customBuilder.Data;
					pos = 2;
					flags |= (uint) data [pos];
					flags |= ((uint) data [pos + 1]) << 8;
					flags |= ((uint) data [pos + 2]) << 16;
					flags |= ((uint) data [pos + 3]) << 24;

					// ignore PublicKey flag if assembly is not strongnamed
					if (sn == null)
						flags &= ~(uint) AssemblyNameFlags.PublicKey;
				}
			}

			if (cattrs != null) {
				CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
				cattrs.CopyTo (new_array, 0);
				new_array [cattrs.Length] = customBuilder;
				cattrs = new_array;
			} else {
				cattrs = new CustomAttributeBuilder [1];
				cattrs [0] = customBuilder;
			}
		}