// ReSharper disable InconsistentNaming public DynamicTypeInfo WithField(string fieldName, Type fieldType) // ReSharper restore InconsistentNaming { var value = new DynamicFieldInfo( this, fieldName, fieldType); #if DEBUG Console.WriteLine(".field ({0}) {1}", fieldType, fieldName); #endif _fields.Add( value ); if (_typeBuilder != null) { value.FieldBuilder = _typeBuilder.DefineField( fieldName, fieldType, FieldAttributes.Private ); } return(this); }
public FieldInfo GetFieldInfo(string fieldName) { DynamicFieldInfo result = fieldsField.First(f => f.Name.Equals(fieldName)); if (result == null) { return(null); } EnsureTypeBuilder(); return(result.FieldBuilder); }