forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpBenchmarks.tt
More file actions
37 lines (36 loc) · 1.09 KB
/
HttpBenchmarks.tt
File metadata and controls
37 lines (36 loc) · 1.09 KB
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
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ output extension=".cs" #>
<#= DownloadCSharpDtos("https://httpbenchmarks.servicestack.net/types/csharp") #>
<#+
public class CodegenOptions
{
bool? MakePartial;
bool? MakeVirtual;
bool? MakeDataContractsExtensible;
bool? InitializeCollections;
bool? AddReturnMarker;
bool? AddDescriptionAsComments;
bool? AddDataContractAttributes;
bool? AddIndexesToDataMembers;
bool? AddResponseStatus;
int? AddImplicitVersion;
string AddDefaultXmlNamespace;
}
#>
<#+
public static string DownloadCSharpDtos(string baseUrl) {
var sb = new System.Text.StringBuilder();
var fields = typeof(CodegenOptions).GetFields(
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var config = new CodegenOptions();
foreach (var f in fields) {
var value = f.GetValue(config);
if (value == null) continue;
if (sb.Length > 0) sb.Append("&");
sb.AppendFormat("{0}={1}", f.Name, value);
}
var qs = sb.ToString();
if (qs.Length > 0) baseUrl += "?" + qs;
return new System.Net.WebClient().DownloadString(baseUrl);
}
#>