Made AttributeBuilder not a singleton, replaced multiple methods per attribute with a single method that returns all the attributes in a single sweep.
This commit is contained in:
@@ -5,23 +5,29 @@ using System.Collections.Generic;
|
||||
namespace CodeGenerator {
|
||||
public class AttributeBuilder {
|
||||
|
||||
private static AttributeBuilder _instance;
|
||||
public static AttributeBuilder Instance => _instance ??= new();
|
||||
|
||||
private CodeTypeDeclaration _attrDecl = new();
|
||||
|
||||
private List<(Type, string)> _fields = new();
|
||||
private List<(Type, string, string)> _properties = new();
|
||||
|
||||
public AttributeBuilder New() {
|
||||
public AttributeBuilder() {
|
||||
_attrDecl.IsClass = true;
|
||||
_attrDecl.Attributes = MemberAttributes.Public;
|
||||
_attrDecl.BaseTypes.Add(typeof(Attribute));
|
||||
}
|
||||
|
||||
public AttributeBuilder(string name) : this() {
|
||||
_attrDecl.Name = name;
|
||||
}
|
||||
|
||||
public AttributeBuilder New() {
|
||||
_attrDecl = new CodeTypeDeclaration();
|
||||
_fields.Clear();
|
||||
_properties.Clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
public AttributeBuilder New(string name) {
|
||||
New();
|
||||
public AttributeBuilder SetName(string name) {
|
||||
_attrDecl.Name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user