public static BreveGenerator Create(Type type, BreveInfo info) { return(new BreveGenerator(info) { Format = type.Construct <BreveFormat>() }); }
public static BreveGenerator Create <T>(BreveInfo info) where T : BreveFormat, new() { BreveGenerator generator = new BreveGenerator(info) { Format = new T() }; return(generator); }
public JavaBreveGenerator(BreveInfo breve) : base(breve) { this._classFormat = @"public class {ClassName}{{ {Properties} }}"; this._propertyFormat = @" {PropertyType} {PropertyField}; public {PropertyType} {PropertyName}(){{ return {PropertyField}; }} public {ClassName} {PropertyName}({PropertyType} value){{ {PropertyField} = value; return this; }} "; }
public static BreveGenerator Create(Languages lang, BreveInfo info) { BreveGenerator generator = new JavaBreveGenerator(info); switch (lang) { case Languages.Invalid: break; case Languages.cs: generator = new CSharpBreveGenerator(info); break; case Languages.java: break; default: break; } return(generator); }
public void Go(string inputFile, string outputFile, string literalName = "breve") { string json = inputFile.JsonFromJsLiteralFile(literalName); JObject obj = (JObject)JsonConvert.DeserializeObject(json); BreveInfo info = new BreveInfo(literalName.PascalCase(), obj, Language); FileInfo file = new FileInfo(outputFile); StringBuilder output = new StringBuilder(); StringBuilder properties = new StringBuilder(); Info.Properties.Each(bp => { properties.Append(Format.PropertyFormat.NamedFormat(new { PropertyType = bp.PropertyType, PropertyField = bp.PropertyField, ClassName = bp.ClassName, PropertyName = bp.PropertyName })); }); output.Append(Format.ClassFormat.NamedFormat(new { ClassName = Info.ClassName, Properties = properties.ToString() })); output.ToString().SafeWriteToFile(file.FullName); }
public BreveGenerator(BreveInfo info) { this.Info = info; }
public CSharpBreveGenerator(BreveInfo info) : base(info) { }
public CSharpBreveGenerator(BreveInfo info) : base(info) { Language = Languages.cs; Format = new CSharpFormat(); }
public JavaBreveGenerator(BreveInfo breve) : base(breve) { Language = Languages.java; Format = new JavaFormat(); }