示例#1
0
 public override FmtToken Format(FmtToken directives) =>
 FmtToken.Concat(
     directives,
     "{",
     FmtToken.Block(Fields.Select(f => FmtToken.Concat(f.Format(), ",")))
     .WithIntegerTokenMap(),
     "}"
     ).WithTokenNames(null, "", "core", "");
示例#2
0
 public override FmtToken Format(FmtToken directives) =>
 FmtToken.Concat(
     Implements.Length > 0 ? FmtToken.Concat(" implements ", FmtToken.Concat(Implements.Select(f => FmtToken.Concat(f, " "))).WithIntegerTokenMap())
                               : "",
     directives,
     "{",
     FmtToken.Block(Fields.Select(f => FmtToken.Concat(f, ",")))
     .WithIntegerTokenMap(),
     "}"
     )
 .WithTokenNames("core.implements", null, "", "core.fields", "");
示例#3
0
        public FmtToken Format(string rootType)
        {
            if (Entities.Length >= 0 && Types.Any(t => t.Name == rootType))
            {
                throw new InvalidOperationException($"Type with name '{rootType}' already exists in the schema so it can't be root type.");
            }

            return(FmtToken.Block(
                       FmtToken.Block(Types).WithIntegerTokenMap(),
                       Entities.Length == 0 && rootType != null ? "" :
                       FmtToken.Concat("type ", rootType, "{", FmtToken.Block(Entities).WithIntegerTokenMap(), "}")
                       )
                   .WithTokenNames(
                       "types",
                       "entities"
                       ));
        }