A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/kubernetes-client/csharp/commit/3dae1cf299df50fb1c62f00b0f5fe04cc4856c41 below:

Refactor LibKubernetesGenerator code structure (#1546) · kubernetes-client/csharp@3dae1cf · GitHub

1 1

using CaseExtensions;

2 2

using NJsonSchema;

3 3

using NSwag;

4 -

using Nustache.Core;

4 +

using Scriban.Runtime;

5 +

using System;

5 6

using System.Collections.Generic;

6 7

using System.Linq;

7 8

using System.Text.RegularExpressions;

8 9 9 10

namespace LibKubernetesGenerator

10 11

{

11 -

internal class GeneralNameHelper : INustacheHelper

12 +

internal class GeneralNameHelper : IScriptObjectHelper

12 13

{

13 14

private readonly ClassNameHelper classNameHelper;

14 15

@@ -17,20 +18,12 @@ public GeneralNameHelper(ClassNameHelper classNameHelper)

17 18

this.classNameHelper = classNameHelper;

18 19

}

19 20 20 -

public void RegisterHelper()

21 +

public void RegisterHelper(ScriptObject scriptObject)

21 22

{

22 -

Helpers.Register(nameof(GetInterfaceName), GetInterfaceName);

23 -

Helpers.Register(nameof(GetMethodName), GetMethodName);

24 -

Helpers.Register(nameof(GetDotNetName), GetDotNetName);

25 -

}

26 - 27 -

public void GetInterfaceName(RenderContext context, IList<object> arguments,

28 -

IDictionary<string, object> options, RenderBlock fn, RenderBlock inverse)

29 -

{

30 -

if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is JsonSchema)

31 -

{

32 -

context.Write(GetInterfaceName(arguments[0] as JsonSchema));

33 -

}

23 +

scriptObject.Import(nameof(GetInterfaceName), new Func<JsonSchema, string>(GetInterfaceName));

24 +

scriptObject.Import(nameof(GetMethodName), new Func<OpenApiOperation, string, string>(GetMethodName));

25 +

scriptObject.Import(nameof(GetDotNetName), new Func<string, string, string>(GetDotNetName));

26 +

scriptObject.Import(nameof(GetDotNetNameOpenApiParameter), new Func<OpenApiParameter, string, string>(GetDotNetNameOpenApiParameter));

34 27

}

35 28 36 29

private string GetInterfaceName(JsonSchema definition)

@@ -68,44 +61,16 @@ private string GetInterfaceName(JsonSchema definition)

68 61

return string.Join(", ", interfaces);

69 62

}

70 63 71 -

public void GetMethodName(RenderContext context, IList<object> arguments, IDictionary<string, object> options,

72 -

RenderBlock fn, RenderBlock inverse)

64 +

public string GetDotNetNameOpenApiParameter(OpenApiParameter parameter, string init)

73 65

{

74 -

if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is OpenApiOperation)

75 -

{

76 -

string suffix = null;

77 -

if (arguments.Count > 1)

78 -

{

79 -

suffix = arguments[1] as string;

80 -

}

66 +

var name = GetDotNetName(parameter.Name);

81 67 82 -

context.Write(GetMethodName(arguments[0] as OpenApiOperation, suffix));

83 -

}

84 -

}

85 - 86 -

public void GetDotNetName(RenderContext context, IList<object> arguments, IDictionary<string, object> options,

87 -

RenderBlock fn, RenderBlock inverse)

88 -

{

89 -

if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is OpenApiParameter)

68 +

if (init == "true" && !parameter.IsRequired)

90 69

{

91 -

var parameter = arguments[0] as OpenApiParameter;

92 -

context.Write(GetDotNetName(parameter.Name));

93 - 94 -

if (arguments.Count > 1 && (arguments[1] as string) == "true" && !parameter.IsRequired)

95 -

{

96 -

context.Write(" = null");

97 -

}

70 +

name += " = null";

98 71

}

99 -

else if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is string)

100 -

{

101 -

var style = "parameter";

102 -

if (arguments.Count > 1)

103 -

{

104 -

style = arguments[1] as string;

105 -

}

106 72 107 -

context.Write(GetDotNetName((string)arguments[0], style));

108 -

}

73 +

return name;

109 74

}

110 75 111 76

public string GetDotNetName(string jsonName, string style = "parameter")


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4