public override string Generate(int indent) { var _attributes = string.Empty; foreach (AttributeGenerator attr in attributes) { _attributes += attr.Generate(indent) + "\n"; } var modSpace = (modifier == FieldModifier.None) ? string.Empty : " "; var definition = CodeBuilder.Indent(indent) + scope.AsString() + " " + modifier.AsString() + modSpace + type.As().CSharpName() + " " + name; var output = defaultValue == null && type.IsValueType ? ";" : " = " + (isString ? stringDefault : defaultValue.As().Code(true) + ";"); return(_attributes + definition + output); }
public override string Generate(int indent) { if (string.IsNullOrEmpty(name)) { return(string.Empty); } var _attributes = string.Empty; var count = 0; foreach (AttributeGenerator attr in attributes) { _attributes += attr.Generate(indent) + ((count < attributes.Count - 1) ? "\n" : string.Empty); } var modSpace = (modifier == FieldModifier.None) ? string.Empty : " "; var definition = CodeBuilder.Indent(indent) + scope.AsString().ConstructHighlight() + " " + modifier.AsString().ConstructHighlight() + modSpace + type.As().CSharpName() + " " + name.LegalMemberName(); var output = !isString && (defaultValue == null || defaultValue.Equals(HUMValue.Create().New(type))) ? ";" : " = " + (isString ? stringDefault : defaultValue.As().Code(true) + ";"); return(_attributes + definition + output); }