Beispiel #1
0
        public static void Compile(CompileArgs args)
        {
            Console.WriteLine("Compiling...");
            string source = File.ReadAllText(args.Source);
            string compiled;

            switch (args.SourceType)
            {
            case SchemaSourceType.TL:
                compiled = TLSchemaCompiler.CompileFromTL(source, args.Namespace);
                break;

            case SchemaSourceType.JSON:
                compiled = TLSchemaCompiler.CompileFromJson(source, args.Namespace);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            File.WriteAllText(args.Destination, compiled);
            Console.WriteLine("Compilation done successfully.");
        }
Beispiel #2
0
        public static void Compile(CompileArgs args)
        {
            Console.WriteLine("Compiling...");
            string source = File.ReadAllText(args.Source);
            string outputSchemaFileName = string.Format("{0}.cs", args.Namespace);
            string outputSchemaMethodsImplFileName = string.Format("{0}.MethodsImpl.cs", args.Namespace);

            var compilationParams = new CompilationParams(args.Namespace, args.MethodsInterfaceName);
            
            TLSchema schema = TLSchema.Build(args.SourceType, source);
            
            string compiledSchema = schema.Compile(compilationParams);
            File.WriteAllText(outputSchemaFileName, compiledSchema);

            if (args.IncludeMethodsImplementation)
            {
                string compiledSchemaMethodsImpl = schema.CompileMethodsImpl(compilationParams);
                File.WriteAllText(outputSchemaMethodsImplFileName, compiledSchemaMethodsImpl);
            }

            Console.WriteLine("Compilation done successfully.");
        }
Beispiel #3
0
        public static void Compile(CompileArgs args)
        {
            Console.WriteLine("Compiling...");
            string source = File.ReadAllText(args.Source);
            string outputSchemaFileName            = string.Format("{0}.cs", args.Namespace);
            string outputSchemaMethodsImplFileName = string.Format("{0}.MethodsImpl.cs", args.Namespace);

            var compilationParams = new CompilationParams(args.Namespace, args.MethodsInterfaceName);

            TLSchema schema = TLSchema.Build(args.SourceType, source);

            string compiledSchema = schema.Compile(compilationParams);

            File.WriteAllText(outputSchemaFileName, compiledSchema);

            if (args.IncludeMethodsImplementation)
            {
                string compiledSchemaMethodsImpl = schema.CompileMethodsImpl(compilationParams);
                File.WriteAllText(outputSchemaMethodsImplFileName, compiledSchemaMethodsImpl);
            }

            Console.WriteLine("Compilation done successfully.");
        }