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) { if (string.IsNullOrWhiteSpace(Text)) { return; } var dot = Text.EndsWith('.') ? string.Empty : "."; builder.Line("/// <summary>"); builder.Line($"/// {Text}{dot}"); builder.Line("/// </summary>"); }
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); } }); }
private static void WriteIterableSyntax(SyntaxBuilder builder, ISyntaxEntity[] syntaxEntities) { for (int i = 0; i < syntaxEntities.Length; i++) { syntaxEntities[i].WriteSyntax(builder); if (i != syntaxEntities.Length - 1) { builder.Line(); } } }
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);"); }
public void WriteSyntax(SyntaxBuilder builder) { if (Summary != null) { Summary.WriteSyntax(builder); } builder.Line($"public enum {Name}"); builder.Block(() => { foreach (var key in Keys) { if (int.TryParse(key.Value, out var intValue)) { builder.Line($"{key.Key} = {key.Value},"); } else { new CSharpAttribute($"EnumMember(Value = \"{key.Value}\")").WriteSyntax(builder); builder.Line($"{key.Key},"); } } }); }
public void WriteSyntax(SyntaxBuilder builder) { if (Summary != null) { Summary.WriteSyntax(builder); } if (Attributes != null) { foreach (var attr in Attributes) { new CSharpAttribute(attr).WriteSyntax(builder); } } builder.Line($"public {Type} {Name} {{ get; set; }} "); }
public void WriteSyntax(SyntaxBuilder builder) { builder.Line($"[{Value}]"); }