示例#1
0
		/// <summary>
		/// Uses the specified interning provider to intern
		/// strings and lists in this entity.
		/// This method does not test arbitrary objects to see if they implement ISupportsInterning;
		/// instead we assume that those are interned immediately when they are created (before they are added to this entity).
		/// </summary>
		public virtual void ApplyInterningProvider(InterningProvider provider)
		{
			if (provider == null)
				throw new ArgumentNullException("provider");
			FreezableHelper.ThrowIfFrozen(this);
			name = provider.Intern(name);
			attributes = provider.InternList(attributes);
			constraints = provider.InternList(constraints);
		}
 void SetFlag(byte flag, bool value)
 {
     FreezableHelper.ThrowIfFrozen(this);
     if (value)
     {
         this.flags |= flag;
     }
     else
     {
         this.flags &= unchecked ((byte)~flag);
     }
 }
示例#3
0
        /// <summary>
        /// Adds a type forwarder.
        /// This adds both an assembly attribute and an internal forwarder entry, which will be used
        /// by the resolved assembly to provide the forwarded types.
        /// </summary>
        /// <param name="typeName">The name of the type.</param>
        /// <param name="referencedType">The reference used to look up the type in the target assembly.</param>
        public void AddTypeForwarder(TopLevelTypeName typeName, ITypeReference referencedType)
        {
            if (referencedType == null)
            {
                throw new ArgumentNullException("referencedType");
            }
            FreezableHelper.ThrowIfFrozen(this);
            var attribute = new DefaultUnresolvedAttribute(typeForwardedToAttributeTypeRef, new[] { KnownTypeReference.Type });

            attribute.PositionalArguments.Add(new TypeOfConstantValue(referencedType));
            assemblyAttributes.Add(attribute);

            typeForwarders[typeName] = referencedType;
        }
示例#4
0
        /// <summary>
        /// Adds a new top-level type definition to this assembly.
        /// </summary>
        /// <remarks>DefaultUnresolvedAssembly does not support partial classes.
        /// Adding more than one part of a type will cause an ArgumentException.</remarks>
        public void AddTypeDefinition(IUnresolvedTypeDefinition typeDefinition)
        {
            if (typeDefinition == null)
            {
                throw new ArgumentNullException("typeDefinition");
            }
            if (typeDefinition.DeclaringTypeDefinition != null)
            {
                throw new ArgumentException("Cannot add nested types.");
            }
            FreezableHelper.ThrowIfFrozen(this);
            var key = new TopLevelTypeName(typeDefinition.Namespace, typeDefinition.Name, typeDefinition.TypeParameters.Count);

            typeDefinitions.Add(key, typeDefinition);
        }
 protected void ThrowIfFrozen()
 {
     FreezableHelper.ThrowIfFrozen(this);
 }