我的要求是使用 IOptions 模式从 local.settings.json 读取值
我的 localsettings.json:
{
  "IsEncrypted": false,
  "Values": {
    "MyOptions:MyCustomSetting": "Foobar",
    "MyOptions:DatabaseName": "Confirmed",
    "MyOptions:Schema": "User",
    "MyOptions:Role": "Dev",
    "MyOptions:UserName": "Avinash"
  }
}
Run Code Online (Sandbox Code Playgroud)
我的绑定类看起来像:
public class MyOptions
    {
        public string MyCustomSetting { get; set; }
        public string DatabaseName { get; set; }
        public string Schema { get; set; }
        public string Role { get; set; }
        public string UserName { get; set; }
    }
Run Code Online (Sandbox Code Playgroud)
启动文件
[assembly: FunctionsStartup(typeof(FunctionApp2.Startup))]
namespace FunctionApp2
{
    public class Startup : FunctionsStartup
    {
        public override void …Run Code Online (Sandbox Code Playgroud) c# .net-core asp.net-core azure-functions azure-function-app
我有一堂课如下:
 public class CosmosRepository: ICosmosRepository
 {
        private ICosmoDBSettings cosmoDbSettings;
        private CosmosClient cosmosClient;
        private static readonly object syncLock = new object();
        // The database we will create
        private Database database;
        public CosmosRepository(ICosmoDBSettings cosmoDBSettings)
        {
            this.cosmoDbSettings = cosmoDBSettings;
            this.InitializeComponents();
        }
        private void InitializeComponents()
        {
            try
            {
                if (cosmosClient != null)
                {
                    return;
                }
                lock (syncLock)
                {
                    if (cosmosClient != null)
                    {
                        return;
                    }
                    this.cosmosClient = new CosmosClient(
                        cosmoDbSettings.CosmosDbUri
                        , cosmoDbSettings.CosmosDbAuthKey
                        , new CosmosClientOptions
                            {
                                ConnectionMode = ConnectionMode.Direct
                            }
                        );
                    this.database = this.cosmosClient.CreateDatabaseIfNotExistsAsync(cosmoDbSettings.DocumentDbDataBaseName).Result; …Run Code Online (Sandbox Code Playgroud) 我参考了许多建议在项目级别抑制警告或错误的博客,但我担心的是在解决方案级别抑制相同的警告。
我找到了一种解决方法,可以使用 VisualStudio 解决方案下解决方案项目文件夹下的 .editorConfig 文件在解决方案级别抑制警告或错误。但是这个 .editorConfig 文件将抑制 VisualStudio 解决方案中的警告/错误,但不会抑制构建管道中的警告/错误
有人可以帮我解决这个问题吗?
c# model-view-controller visual-studio .net-core asp.net-core