/// <summary> /// Adds the definition of a constructor the type should implement. /// </summary> /// <param name="definition">Definition to add.</param> public void AddConstructorDefinition(ConstructorDefinition definition) { if (definition == null) { throw new ArgumentNullException(nameof(definition)); } if (mConstructors.Contains(definition, ConstructorDefinition.SignatureEquality)) { throw new CodeGenException("A constructor with the same signature is already part of the definition."); } mConstructors.Add(definition); }
/// <summary> /// When overridden in a derived class, adds code to a constructor of the type in creation. /// </summary> /// <param name="msil">IL Generator attached to the appropriate constructor.</param> /// <param name="definition">Definition of the constructor being implemented.</param> protected virtual void OnImplementConstructor(ILGenerator msil, ConstructorDefinition definition) { }
/// <summary> /// Is called by <see cref="CodeGenEngine"/> to add code to a constructor. /// </summary> /// <param name="msil">IL Generator attached to the appropriate constructor.</param> /// <param name="definition">Definition of the constructor being implemented.</param> void ICodeGenModule.ImplementConstruction(ILGenerator msil, ConstructorDefinition definition) { OnImplementConstructor(msil, definition); }
/// <summary> /// Adds code to a constructor of the type in creation calling the <see cref="ImplementConstructor"/> callback. /// </summary> /// <param name="msil">IL Generator attached to the appropriate constructor.</param> /// <param name="definition">Definition of the constructor being implemented.</param> protected override void OnImplementConstructor(ILGenerator msil, ConstructorDefinition definition) { ImplementConstructor?.Invoke(this, msil, definition); }