예제 #1
0
 public static BreveGenerator Create(Type type, BreveInfo info)
 {
     return(new BreveGenerator(info)
     {
         Format = type.Construct <BreveFormat>()
     });
 }
예제 #2
0
        public static BreveGenerator Create <T>(BreveInfo info) where T : BreveFormat, new()
        {
            BreveGenerator generator = new BreveGenerator(info)
            {
                Format = new T()
            };

            return(generator);
        }
예제 #3
0
        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;
    }}
";
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
 public BreveGenerator(BreveInfo info)
 {
     this.Info = info;
 }
예제 #7
0
 public CSharpBreveGenerator(BreveInfo info)
     : base(info)
 {
 }
예제 #8
0
 public CSharpBreveGenerator(BreveInfo info)
     : base(info)
 {
     Language = Languages.cs;
     Format   = new CSharpFormat();
 }
예제 #9
0
 public JavaBreveGenerator(BreveInfo breve)
     : base(breve)
 {
     Language = Languages.java;
     Format   = new JavaFormat();
 }