예제 #1
0
 protected string[] GenerateCode(TypeScriptGenerationOptions options, ICustomTypeGenerator customTypeGenerator, Type rootType)
 {
     var generator = new TypeScriptGenerator(options, customTypeGenerator, new TypesProvider(rootType));
     if (JavaScriptTypeChecker == JavaScriptTypeChecker.Flow && options.EnumGenerationMode == EnumGenerationMode.TypeScriptEnum)
         throw new ArgumentException("Invalid EnumGenerationMode for JavaScriptTypeChecker.Flow");
     return generator.Generate().Select(x => x.GenerateCode(new DefaultCodeGenerationContext(JavaScriptTypeChecker)).Replace("\r\n", "\n")).ToArray();
 }
 public TypeScriptGenerator([NotNull] TypeScriptGenerationOptions options, [NotNull] ICustomTypeGenerator customTypeGenerator, [NotNull] IRootTypesProvider rootTypesProvider)
 {
     Options = options ?? throw new ArgumentNullException(nameof(options));
     this.customTypeGenerator = customTypeGenerator ?? throw new ArgumentNullException(nameof(customTypeGenerator));
     rootTypes        = rootTypesProvider?.GetRootTypes() ?? throw new ArgumentNullException(nameof(rootTypesProvider));
     typeUnitFactory  = new DefaultTypeScriptGeneratorOutput();
     typeDeclarations = new Dictionary <TypeDeclarationKey, ITypeBuildingContext>();
 }
예제 #3
0
 public TypeScriptGenerator(TypeScriptGenerationOptions options, ICustomTypeGenerator customTypeGenerator, IRootTypesProvider typesProvider, ITypeInfo[] types = null)
 {
     Options                  = options ?? throw new ArgumentNullException(nameof(options));
     TypesProvider            = typesProvider ?? throw new ArgumentNullException(nameof(typesProvider));
     this.customTypeGenerator = customTypeGenerator ?? throw new ArgumentNullException(nameof(customTypeGenerator));
     rootTypes                = typesProvider?.GetRootTypes() ?? throw new ArgumentNullException(nameof(typesProvider));
     typeUnitFactory          = new DefaultTypeScriptGeneratorOutput();
     typeDeclarations         = new Dictionary <ITypeInfo, ITypeBuildingContext>();
 }
예제 #4
0
        protected void GenerateFiles(ICustomTypeGenerator customTypeGenerator, string folderName, params Type[] rootTypes)
        {
            var path = $"{TestContext.CurrentContext.TestDirectory}/{folderName}/{JavaScriptTypeChecker}";
            if (Directory.Exists(path))
                Directory.Delete(path, recursive : true);
            Directory.CreateDirectory(path);

            var generator = new TypeScriptGenerator(TestOptions, customTypeGenerator, new TypesProvider(rootTypes));
            generator.GenerateFiles(path, JavaScriptTypeChecker);
        }
        protected string[] GenerateCode(TypeScriptGenerationOptions options, ICustomTypeGenerator customTypeGenerator, IRootTypesProvider typesProvider)
        {
            var generator = new TypeScriptGenerator(options, customTypeGenerator, typesProvider);

            return(generator.Generate().Select(x => x.GenerateCode(new DefaultCodeGenerationContext()).Replace("\r\n", "\n")).ToArray());
        }
예제 #6
0
 protected string[] GenerateCode(ICustomTypeGenerator customTypeGenerator, Type rootType)
 {
     return GenerateCode(TestOptions, customTypeGenerator, rootType);
 }
 protected string[] GenerateCode(ICustomTypeGenerator customTypeGenerator, Type rootType)
 {
     return(GenerateCode(TypeScriptGenerationOptions.Default, customTypeGenerator, rootType));
 }