コード例 #1
0
        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);
                }
            });
        }
コード例 #2
0
        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>");
        }
コード例 #3
0
        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();
                    }
                }
            });
        }
コード例 #4
0
        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);
                }
            });
        }
コード例 #5
0
        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();
                }
            }
        }
コード例 #6
0
        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);");
        }
コード例 #7
0
        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},");
                    }
                }
            });
        }
コード例 #8
0
        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; }} ");
        }
コード例 #9
0
 public void WriteSyntax(SyntaxBuilder builder)
 {
     builder.Line($"[{Value}]");
 }