Example #1
0
		private InterfaceDeclarationSyntax addType(PropertyWithName pwn, InterfaceDeclarationSyntax @interface)
		{
			var method = MethodDeclaration(ParseTypeName($"I{pwn.Type.Name}"), $"Create{pwn.Type.Name}")
				.WithSemicolonToken(Token(SyntaxKind.SemicolonToken));

			return @interface.AddMembers(method);
		}
Example #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);
			}
		}
		private ClassDeclarationSyntax addType(PropertyWithName p, ClassDeclarationSyntax @class)
		{
			var tn = ParseTypeName(p.PropertyName);
			var pi = p.Type.GetProperties();
			var method = createGetMethod(p.Type, pi)
				.WithLeadingTrivia(Trivia(RegionDirectiveTrivia(true)
					.WithEndOfDirectiveToken(
						Token(TriviaList().Add(PreprocessingMessage(p.PropertyName)),
							SyntaxKind.EndOfDirectiveToken,
							TriviaList())
					)
				));

			method = method.WithTrailingTrivia(
				Trivia(
					EndRegionDirectiveTrivia(true)
				)
			);

			return @class.AddMembers(method);
		}
		private ClassDeclarationSyntax addType(PropertyWithName pwn, ClassDeclarationSyntax @class)
		{
			var tn = ParseTypeName(pwn.Type.Name);
			var pi = pwn.Type.GetProperties();

			var method = createGetMethod(pwn.Type, pi)
				.WithLeadingTrivia(Trivia(RegionDirectiveTrivia(true)
					.WithEndOfDirectiveToken(
						Token(TriviaList().Add(PreprocessingMessage(pwn.Type.Name)),
							SyntaxKind.EndOfDirectiveToken,
							TriviaList())
					)
				));

			method = method.WithTrailingTrivia(
				Trivia(
					EndRegionDirectiveTrivia(true)
				)
				);

			return @class.AddMembers(method);

			/*cu.NormalizeWhitespace("\t", true).WriteTo(writer);
			writer.WriteLine();
			writer.WriteLine();*/

		}