public void WriteSyntax(SyntaxBuilder builder) { builder.Clear(); if (Usings != null && Usings.Any()) { foreach (var u in Usings) { builder.Line($"using {u};"); } builder.Line(); } builder.Line($"namespace {Namespace}"); builder.Block(() => { if (Class != null) { Class.WriteSyntax(builder); } if (Enum != null) { Enum.WriteSyntax(builder); } if (Interface != null) { Interface.WriteSyntax(builder); } }); }
public void WriteSyntax(SyntaxBuilder builder) { builder.Line($"public interface {Name}"); builder.Block(() => { for (int i = 0; i < Methods.Length; i++) { Methods[i].WriteSyntax(builder); if (i != Methods.Length - 1) { builder.Line(); } } }); }
public void WriteSyntax(SyntaxBuilder builder) { if (Summary != null) { Summary.WriteSyntax(builder); } var interfaceString = !string.IsNullOrWhiteSpace(Interface) ? $" : {Interface}" : string.Empty; builder.Line($"public class {Name}{interfaceString}"); builder.Block(() => { var notEmpty = false; if (NestedEnums.Any()) { WriteIterableSyntax(builder, NestedEnums.ToArray()); notEmpty = true; } if (Properties.Any()) { if (notEmpty) { builder.Line(); } WriteIterableSyntax(builder, Properties.ToArray()); notEmpty = true; } if (Methods.Any()) { if (notEmpty) { builder.Line(); } WriteIterableSyntax(builder, Methods); } }); }
public void WriteSyntax(SyntaxBuilder builder) { builder.Line("var request = new Dictionary<string, string>"); builder.Block(() => { var parameters = Method.Parameters?.ToArray() ?? Array.Empty <ApiMethodParameter>(); for (int i = 0; i < parameters.Length; i++) { var parameter = parameters[i]; var mappingString = GetParameterMappingString( parameter.Name.ToBeautifiedName(StringCase.Camel), parameter.GetCSharpType()); builder.Line($"{{\"{parameter.Name}\", {mappingString}}},"); } }, insertSemicolon: true); builder.Line(); builder.Line($"return RequestManager.CreateRequestAsync<{Response.GetCSharpType()}>(\"{Method.FullName}\", accessToken, request);"); }