예제 #1
0
		public void Generate(IList<PropertyWithName> props, string baseSaveDirectory, RunConfig config)
		{
			var dir = Path.Combine(baseSaveDirectory, config.Directory);
			if(!Directory.Exists(dir))
			{
				Directory.CreateDirectory(dir);
			}

			var unit = CompilationUnit();
			unit = unit.AddUsing("System").WithLeadingTrivia(new SyntaxTriviaList().Add(GeneratorBase.GetLicenseComment()));

			var names = NamespaceDeclaration(IdentifierName("Sannel.House.ServerSDK"));

			var @interface = InterfaceDeclaration("ICreateHelper")
				.AddModifiers(
					Token(SyntaxKind.PublicKeyword)
				);

			foreach(var prop in props)
			{
				@interface = addType(prop, @interface);
			}

			names = names.AddMembers(@interface);

			unit = unit.AddMembers(names);

			unit = unit.NormalizeWhitespace("\t", true);
			using(var writer = new StreamWriter(File.OpenWrite(Path.Combine(dir, config.FileName))))
			{
				unit.WriteTo(writer);
			}
		}
예제 #2
0
		public void Generate(PropertyWithName pwn, String baseSaveFolder, RunConfig config)
		{
			TestBuilder = config.TestBuilder;
			HttpBuilder = config.HttpBuilder;

			var sf = Path.Combine(baseSaveFolder, config.Directory.ReplaceKeys(pwn, config));
			if (!Directory.Exists(sf))
			{
				Directory.CreateDirectory(sf);
			}

			var syntax = internalGenerate(pwn.PropertyName, pwn.Type).NormalizeWhitespace("\t", true);

			var file = Path.Combine(sf, config.FileName.ReplaceKeys(pwn, config));
			if (File.Exists(file))
			{
				File.Delete(file);
			}
			using (StreamWriter writer = new StreamWriter(File.OpenWrite(file)))
			{
				syntax.WriteTo(writer);
				//formattedNode.WriteTo(writer);
			}
		}
		public void Generate(IList<PropertyWithName> props, string baseSaveDirectory, RunConfig config)
		{
			var dir = Path.Combine(baseSaveDirectory, config.Directory);
			if(!Directory.Exists(dir))
			{
				Directory.CreateDirectory(dir);
			}

			clientBuilder = config.HttpBuilder;
			taskBuilder = config.TaskBuilder;
			testBuilder = config.TestBuilder;
			variables = config.Variables;

			var cu = CompilationUnit();
			cu = cu.AddUsing("System").WithLeadingTrivia(GeneratorBase.GetLicenseComment());
			cu = cu.AddUsings(new string[]
			{
				"System.Threading.Tasks",
				"Newtonsoft.Json",
				"Newtonsoft.Json.Linq"
			});
			cu = cu.AddUsings(clientBuilder.Namespace);
			cu = cu.AddUsings(testBuilder.Namespaces);

			if(String.Compare(variables.GetValue("IsUWP"), "1", true) == 0)
			{
				cu = cu.AddUsing("System.Runtime.InteropServices");
			}

			var namesp = NamespaceDeclaration(IdentifierName("Sannel.House.ServerSDK.Tests"));

			var @class = ClassDeclaration("ServerContextTests")
				.AddModifiers(Token(SyntaxKind.PublicKeyword),
				Token(SyntaxKind.PartialKeyword));


			foreach(var prop in props)
			{
				@class = addType(prop, @class);
			}

			namesp = namesp.AddMembers(@class);

			cu = cu.AddMembers(namesp).NormalizeWhitespace("\t", true);
			using(var writer = new StreamWriter(File.OpenWrite(Path.Combine(dir, config.FileName))))
			{
				cu.WriteTo(writer);
			}
		}