forked from nacos-group/nacos-sdk-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ConfigurationBuilder support (nacos-group#105)
* Add .ConfigureAwait(false) * Suppport ConfigurationBuilder * Add Nacos support ConfigurationBuilder * useGrpc
- Loading branch information
1 parent
be746fe
commit 43cb177
Showing
16 changed files
with
768 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8-bom | ||
end_of_line = crlf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
tab_width = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[.bowerrc|*.yml] | ||
charset = utf-8 | ||
|
||
# Xml project files | ||
[*.*proj] | ||
indent_size = 2 | ||
|
||
# Xml build files | ||
[*.builds] | ||
indent_size = 2 | ||
|
||
# Xml files | ||
[*.{xml,stylecop,resx,ruleset,xsd}] | ||
indent_size = 2 | ||
|
||
# Xml config files | ||
[*.{props,targets,config,nuspec,vsixmanifest,vsct}] | ||
indent_size = 2 | ||
|
||
# JSON files | ||
[*.json] | ||
indent_size = 2 | ||
|
||
# Shell scripts | ||
[*.sh] | ||
end_of_line = lf | ||
|
||
# ReSharper properties | ||
resharper_csharp_wrap_lines=false | ||
resharper_enforce_line_ending_style=true | ||
resharper_js_wrap_lines=false | ||
resharper_protobuf_wrap_lines=false | ||
resharper_use_indent_from_vs=false | ||
resharper_vb_wrap_lines=false | ||
resharper_xmldoc_wrap_lines=false | ||
resharper_xml_wrap_lines=false | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
|
||
<Project> | ||
<Project> | ||
<PropertyGroup> | ||
<LangVersion>latest</LangVersion> | ||
<RepositoryType>git</RepositoryType> | ||
|
||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<NoWarn>$(NoWarn),1573,1591,1712</NoWarn> | ||
<CodeAnalysisRuleSet>..\..\_stylecop\codeanalysis.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<NoWarn>$(NoWarn),1573,1591,1712</NoWarn> | ||
<CodeAnalysisRuleSet>..\..\_stylecop\codeanalysis.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="5.*" PrivateAssets="All" /> | ||
<ItemGroup> | ||
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="5.*" PrivateAssets="All" /> | ||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.*" PrivateAssets="All" Condition="'$(OS)' != 'Windows_NT'" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.*" PrivateAssets="All"/> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
samples/ConfigurationBuilderApp/ConfigurationBuilderApp.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion> | ||
</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{CA0A661F-01D5-4DF7-9CD0-0399F89A8D47}</ProjectGuid> | ||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>ConfigurationBuilderApp</RootNamespace> | ||
<AssemblyName>ConfigurationBuilderApp</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> | ||
<UseIISExpress>true</UseIISExpress> | ||
<Use64BitIISExpress /> | ||
<IISExpressSSLPort /> | ||
<IISExpressAnonymousAuthentication /> | ||
<IISExpressWindowsAuthentication /> | ||
<IISExpressUseClassicPipelineMode /> | ||
<UseGlobalApplicationHostFile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<DocumentationFile>bin\ConfigurationBuilderApp.xml</DocumentationFile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<DocumentationFile>bin\ConfigurationBuilderApp.xml</DocumentationFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Web.DynamicData" /> | ||
<Reference Include="System.Web.Entity" /> | ||
<Reference Include="System.Web.ApplicationServices" /> | ||
<Reference Include="System.ComponentModel.DataAnnotations" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Web.Extensions" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Configuration" /> | ||
<Reference Include="System.Web.Services" /> | ||
<Reference Include="System.EnterpriseServices" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="Web.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Startup.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Nacos.System.Configuration\Nacos.System.Configuration.csproj"> | ||
<Project>{7c20f5fb-33d4-460a-86f4-fc42122fa543}</Project> | ||
<Name>Nacos.System.Configuration</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Owin.Host.SystemWeb"> | ||
<Version>4.2.0</Version> | ||
</PackageReference> | ||
</ItemGroup> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" /> | ||
<ProjectExtensions> | ||
<VisualStudio> | ||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> | ||
<WebProjectProperties> | ||
<UseIIS>True</UseIIS> | ||
<AutoAssignPort>True</AutoAssignPort> | ||
<DevelopmentServerPort>12012</DevelopmentServerPort> | ||
<DevelopmentServerVPath>/</DevelopmentServerVPath> | ||
<IISUrl>http://localhost:12012/</IISUrl> | ||
<NTLMAuthentication>False</NTLMAuthentication> | ||
<UseCustomServer>False</UseCustomServer> | ||
<CustomServerUrl> | ||
</CustomServerUrl> | ||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> | ||
</WebProjectProperties> | ||
</FlavorProperties> | ||
</VisualStudio> | ||
</ProjectExtensions> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using ConfigurationBuilderApp; | ||
using Microsoft.Owin; | ||
using Owin; | ||
using System.Configuration; | ||
using System.Threading.Tasks; | ||
|
||
[assembly: OwinStartup(typeof(Startup))] | ||
|
||
namespace ConfigurationBuilderApp | ||
{ | ||
public class Startup | ||
{ | ||
public void Configuration(IAppBuilder app) | ||
{ | ||
app.Run(context => | ||
{ | ||
context.Response.StatusCode = 404; | ||
|
||
var key = context.Request.Query["key"]; | ||
if (string.IsNullOrWhiteSpace(key)) return Task.CompletedTask; | ||
|
||
var value = ConfigurationManager.AppSettings[key]; | ||
if (value != null) context.Response.StatusCode = 200; | ||
|
||
context.Response.Headers["Content-Type"] = "text/html; charset=utf-8"; | ||
|
||
return context.Response.WriteAsync(value ?? "undefined"); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<configuration> | ||
<configSections> | ||
<section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> | ||
<section name="nacos" type="Nacos.System.Configuration.NacosConfigurationSection, Nacos.System.Configuration" /> | ||
</configSections> | ||
<configBuilders> | ||
<builders> | ||
<add name="nacos" type="Nacos.System.Configuration.NacosConfigurationBuilder, Nacos.System.Configuration" /> | ||
</builders> | ||
</configBuilders> | ||
<nacos tenant="cs" serverAddresses="http://localhost:8848/" userName="test2" password="123456" useGrpc="true"> | ||
<listeners> | ||
<listener dataId="common" /> | ||
<listener dataId="demo" /> | ||
</listeners> | ||
</nacos> | ||
|
||
<appSettings configBuilders="nacos" /> | ||
|
||
<system.web> | ||
<compilation debug="true" targetFramework="4.7.1" /> | ||
<httpRuntime targetFramework="4.7.1" /> | ||
</system.web> | ||
|
||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Memory" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Data.Common" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Diagnostics.StackTrace" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Diagnostics.Tracing" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Globalization.Extensions" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.IO.Compression" culture="neutral" publicKeyToken="b77a5c561934e089" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Net.Http" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Net.Sockets" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Runtime.Serialization.Primitives" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Security.Cryptography.Algorithms" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Security.SecureString" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Threading.Overlapped" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Xml.XPath.XDocument" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
|
||
</configuration> |
Oops, something went wrong.