-
Notifications
You must be signed in to change notification settings - Fork 447
/
Copy pathHttpModel.cs
37 lines (34 loc) · 1.05 KB
/
HttpModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using NJsonSchema.CodeGeneration;
namespace WebApiClientCore.OpenApi.SourceGenerator
{
/// <summary>
/// 表示WebApiClient的模型描述
/// </summary>
public class HttpModel : CSharpCode
{
/// <summary>
/// 获取使用的命名空间
/// </summary>
public string NameSapce { get; }
/// <summary>
/// WebApiClient的模型描述
/// </summary>
/// <param name="codeArtifact">源代码</param>
/// <param name="nameSpace">命名空间</param>
public HttpModel(CodeArtifact codeArtifact, string nameSpace)
: base(codeArtifact)
{
this.NameSapce = nameSpace;
}
/// <summary>
/// 转换为完整的代码
/// </summary>
/// <returns></returns>
public override string ToString()
{
var cshtml = CSharpHtml.Views<HttpModel>();
var source = cshtml.RenderText(this);
return new CSharpCode(source, this.TypeName, this.Type).ToString();
}
}
}