Changed static csharp generator to now rely on the client name so that it can be easily renamed.

This commit is contained in:
MattMo 2023-02-06 11:37:33 -08:00
parent e4c3ee0673
commit 612a658b77
2 changed files with 8 additions and 8 deletions

View File

@ -17,7 +17,7 @@
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>1.2.4</Version>
<Version>1.2.5</Version>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
</PropertyGroup>

View File

@ -72,13 +72,13 @@ namespace MontoyaTech.Rest.Net
writer.WriteBreak().WriteLine("public static void Init(string baseUrl)").WriteLine("{").Indent();
//Init the base url
writer.WriteLine($"{this.ClientName}.BaseUrl = baseUrl;");
writer.WriteLine("BaseUrl = baseUrl;");
//Init the http client
writer.WriteLine($"{this.ClientName}.HttpClient = new HttpClient();");
writer.WriteLine(@$"{this.ClientName}.HttpClient.DefaultRequestHeaders.Add(""Accept"", ""*/*"");");
writer.WriteLine(@$"{this.ClientName}.HttpClient.DefaultRequestHeaders.Add(""Connection"", ""keep-alive"");");
writer.WriteLine(@$"{this.ClientName}.HttpClient.DefaultRequestHeaders.Add(""Accept-Encoding"", ""identity"");");
writer.WriteLine("HttpClient = new HttpClient();");
writer.WriteLine(@"HttpClient.DefaultRequestHeaders.Add(""Accept"", ""*/*"");");
writer.WriteLine(@"HttpClient.DefaultRequestHeaders.Add(""Connection"", ""keep-alive"");");
writer.WriteLine(@"HttpClient.DefaultRequestHeaders.Add(""Accept-Encoding"", ""identity"");");
writer.Outdent().WriteLine("}");
}
@ -301,7 +301,7 @@ namespace MontoyaTech.Rest.Net
}
if (this.StaticCode)
writer.WriteSeparator().Write('$').Write('"').Write("{Client.BaseUrl}");
writer.WriteSeparator().Write('$').Write('"').Write("{BaseUrl}");
else
writer.WriteSeparator().Write('$').Write('"').Write("{this.Client.BaseUrl}");
@ -346,7 +346,7 @@ namespace MontoyaTech.Rest.Net
//Generate the response code
if (this.StaticCode)
writer.WriteBreak().WriteLine("var response = Client.HttpClient.Send(message);");
writer.WriteBreak().WriteLine("var response = HttpClient.Send(message);");
else
writer.WriteBreak().WriteLine("var response = this.Client.HttpClient.Send(message);");