Exemplo n.º 1
0
		internal int Run(TypeScriptConfig config)
		{
			Entities entity = new Entities();
			Resource resource = new Resource();
			IndexExport index = new IndexExport();

			entity.Run(config.Entity, index);
			resource.Run(config.Resource, index);

			return 0;
		}
Exemplo n.º 2
0
		internal void Run(TypeScriptResource config, IndexExport index)
		{
			if (config.Resources == null || config.Resources.Count <= 0)
				return;

			StringBuilderIndented builder = new StringBuilderIndented();

			builder
				.AppendLine("import { Injectable } from \"@angular/core\";");

			if (config.LazyLoad)
			{
				builder
					.AppendLine("import { Http, Response } from \"@angular/http\";")
					.AppendLine("import { Observable } from \"rxjs/Observable\";");
			}

			builder
				.AppendLine("import { Map } from \"../entity\";")
				.AppendLine();

			Resources = new List<GeneratorResourceEntity>();

			GetResouces(config);
			BuildLanguageSuported(builder);
			BuildInterface(builder);

			if (!config.LazyLoad)
				BuildClass(config, builder);

			BuidService(config, builder);

			if (!Directory.Exists(config.Path))
				Directory.CreateDirectory(config.Path);

			var file = config.File.GetSelector() + ".service.ts";

			WriteFile(config.Path.ToLower(), file, builder);

			Index.Run(config.Path);

			index.Run(config.Path);
			Console.WriteLine("Generate resource typescript - OK");
		}
Exemplo n.º 3
0
		internal void Run(TypeScriptEntity config, IndexExport index)
		{
            Config = config;

			TSClass = new List<TypeScriptClass>();
			TSEnums = new List<TypeScriptEnum>();

            GeneratedEntities = new List<string>();

			LoadEnums();
			LoadProperties();

			if (!Directory.Exists(config.Path))
				Directory.CreateDirectory(config.Path);

			ProcessEnum();
			ProcessTypes();

			Index.Run(config.Path);

			index.Run(config.Path);
			Console.WriteLine("Generate entity typescript - OK");
		}
Exemplo n.º 4
0
		internal int Run(AngularConfig config, string[] args)
		{
			var appCommand = new CommandLineApplication(false)
			{
				Name = "Angular Generator",
				FullName = "Angular Generator",
				Description = "Angular Generator can generate Component, Service and Pipe",
			};

			var help = appCommand.HelpOption("-h|--help");
			var name = appCommand.Argument("[terms]", "Name of items to be generate");

			var feature = appCommand.Option("-f|--feature", "Feature", CommandOptionType.SingleValue);
			var component = appCommand.Option("-c|--component", "Generate a new Component with HTML, TS and SCSS", CommandOptionType.NoValue);
			var service = appCommand.Option("-s|--service", "Generate a new Angular service", CommandOptionType.NoValue);

			appCommand.OnExecute(() =>
			{
				if (appCommand.OptionHelp.HasValue())
				{
					appCommand.ShowHelp();
					return 0;
				}

				IndexExport index = new IndexExport();

				if (component.HasValue())
				{
					var erro = false;

					if (!feature.HasValue())
					{
						Console.WriteLine("Name of component doesn't specified");
						erro = true;
					}

					if (string.IsNullOrEmpty(name.Value) || !feature.HasValue())
					{
						Console.WriteLine("Name of component doesn't specified");
						erro = true;
					}

					if (erro)
					{
						return -1;
					}

					Component componentWritter = new Component();

					string path = ParsePath(config, feature.Value(), ItemType.Component);

					componentWritter.Run(path, feature.Value(), config.HtmlRoot, config.StyleInclude, GetItems(appCommand, name));
					index.Run(path);

					return 0;
				}

				if (service.HasValue())
				{
					if (string.IsNullOrEmpty(name.Value))
					{
						Console.WriteLine("Name of component/feature doesn't specified");
						return -1;
					}

					Service serviceWritter = new Service();
					string path = ParsePath(config, string.Empty, ItemType.Service);

					serviceWritter.Run(path, GetItems(appCommand, name));
					index.Run(path);

					return 0;
				}

				appCommand.ShowHelp();
				return 0;
			});

			var arguments = args.ToList();
			arguments.Remove("-a");

			return appCommand.Execute(arguments.ToArray());
		}