protected override void FreezeInternal() { base.FreezeInternal(); baseTypes = FreezableHelper.FreezeList(baseTypes); typeParameters = FreezableHelper.FreezeListAndElements(typeParameters); nestedTypes = FreezableHelper.FreezeListAndElements(nestedTypes); members = FreezableHelper.FreezeListAndElements(members); }
/// <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); constraints = provider.InternList(constraints); }
protected override void FreezeInternal() { base.FreezeInternal(); assemblyAttributes = FreezableHelper.FreezeListAndElements(assemblyAttributes); moduleAttributes = FreezableHelper.FreezeListAndElements(moduleAttributes); foreach (var type in typeDefinitions.Values) { FreezableHelper.Freeze(type); } }
/// <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); typeForwarders[typeName] = referencedType; }
/// <summary> /// Adds a new top-level type definition to this assembly. /// </summary> /// <remarks>UnresolvedAssemblySpec 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); }
public override ISupportsInterning Intern(ISupportsInterning obj) { if (obj == null) { return(null); } // ensure objects are frozen when we put them into the dictionary // note that Freeze may change the hash code of the object FreezableHelper.Freeze(obj); ISupportsInterning output; if (supportsInternDict.TryGetValue(obj, out output)) { return(output); } else { supportsInternDict.Add(obj, obj); return(obj); } }
protected virtual void FreezeInternal() { constraints = FreezableHelper.FreezeList(constraints); }