小编Muh*_*eed的帖子

如何向 C# 9 记录添加注释

C# 9 记录有一个简短的形式,如下所示:

public record Car(int CarId, int Cylinders, string Make, string Model);
Run Code Online (Sandbox Code Playgroud)

如何将文档注释添加到记录的属性中?请注意,这是不同的这一哪个询问长形式等问题。

c# comments record c#-9.0

5
推荐指数
1
解决办法
477
查看次数

在Windows 8 Metro风格的应用程序中使用.NET GeoCoordinate.GetDistanceTo等效

Metro风格Windows 8应用程序中System.Device.Location.GeoCoordinate.GetDistanceTo方法的等效项是什么.

Metro应用程序具有Geocoordinate类(使用小写"C")但没有GetDistanceTo方法.

其次,Metro Geocoordinate类没有构造函数.我该如何创建它的实例.

.net c# getdistance microsoft-metro windows-8

4
推荐指数
1
解决办法
7839
查看次数

添加Slow Cheetah转换配置文件作为另一个项目的参考

我有一个带有Slow Cheetah'ed配置文件的类库项目.

在过去,很容易使用"添加为链接"将配置文件添加到其他项目.如何使用Slow Cheetah实现这一点,因为配置文件是动态的?

我需要某种配置文件的添加引用,或者如果没有办法这样做,我必须再次复制配置文件和Slow Cheetah.

configuration app-config config web-config slowcheetah

4
推荐指数
1
解决办法
1784
查看次数

范围/角色/基于组的访问控制

我正在使用Azure Active Directory,并尝试了解此处描述的三种类型的访问控制.每种方法的优点和缺点是什么?何时使用它们:

  • 基于范围的访问控制使用oauth2Permissions我的清单部分,我可以添加读写权限,如下所示:

    {
      "adminConsentDescription": "Allow the application read access to MyApi on behalf of the signed-in user.",
      "adminConsentDisplayName": "Read access to MyApi",
      "id": "56d944c0-f3aa-4f80-9472-9c1414383abf",
      "isEnabled": true,
      "type": "User",
      "userConsentDescription": "Allow the application read access to MyApi on your behalf.",
      "userConsentDisplayName": "Read access to MyApi",
      "value": "read_my_api"
    },
    {
      "adminConsentDescription": "Allow the application write access to MyApi on behalf of the signed-in user.",
      "adminConsentDisplayName": "Write access to MyApi",
      "id": "6d66a2bd-c8c7-4ee0-aef4-9424b51b4967",
      "isEnabled": true,
      "type": "User",
      "userConsentDescription": …

oauth access-control azure oauth-2.0 azure-active-directory

4
推荐指数
2
解决办法
1299
查看次数

调用外部可执行文件时抑制 Powershell 错误

我有一个正在调用外部可执行文件的 PowerShell 脚本,并且我想抑制由此产生的任何错误。如何才能实现这一点。使用 PowerShell cmdlet,我可以使用 的标准-ErrorAction参数SilentlyContinue,但这是一个外部可执行文件:

someExe --argument
Run Code Online (Sandbox Code Playgroud)

error-handling powershell executable powershell-cmdlet

4
推荐指数
1
解决办法
4740
查看次数

处理DocumentDB中的每秒请求单位(RUs/s)峰值

DocumentDB最困难的事情之一是确定每天运行应用程序所需的每秒请求单位数(RUs/s),以及使用高峰期间.当你弄错了,DocumentDB客户端将抛出异常,这是一个糟糕的使用模型.

如果我的应用程序在当天的特定时间使用更高数量的每秒请求单元数(RU/s),那么我如何在DocumentDB中处理此问题?我不想整天设置一个非常高的RU/s因为我会得到相应的收费.我也不想每次都登录Azure门户.

azure azure-cosmosdb request-unit

4
推荐指数
1
解决办法
1193
查看次数

哪些版本的Windows Server与.NET Core Runtime RID匹配

我将以下运行时定位到我的project.json文件中的.NET Core Web应用程序:

"runtimes": {
  "win10-x64": { },
  "win8-x64": { },
  "win7-x64": { }
}
Run Code Online (Sandbox Code Playgroud)

上面的运行时RID对应哪个版本的Windows Server?官方文档没有列出它们.特别是,应该使用哪个RID来定位:

  • Windows Server 2008
  • Windows Server 2008 R2
  • Windows Server 2012
  • Windows Server 2012 R2
  • Windows Server 2016

.net-core project.json asp.net-core

4
推荐指数
1
解决办法
1143
查看次数

如何从HttpContext获取ASP.NET Core MVC筛选器

我正在尝试编写一些中间件,并且需要知道当前的操作方法(如果有)是否具有特定的过滤器属性,因此我可以根据其存在来更改行为。

因此,是否有可能IList<IFilterMetadata>像在ResourceExecutingContext实现a时所做的那样获取类型的过滤器集合IResourceFilter

c# httpcontext asp.net-core-mvc asp.net-core asp.net-core-middleware

4
推荐指数
2
解决办法
1442
查看次数

从 ARM 模板设置 Azure 应用程序配置中的值

可以从 ARM 模板创建 Azure KeyVault 机密。您是否也可以以同样的方式从 ARM 模板在 Azure 应用程序配置中创建设置?如果此功能存在,我找不到任何相关文档。

azure azure-configuration azure-rm-template azure-app-configuration

4
推荐指数
1
解决办法
1432
查看次数

替代传递IOC容器

我有以下几个依赖的基类:

public abstract class ViewModel
{
    private readonly ILoggingService loggingService;

    public ViewModel(
        ILoggingService loggingService,
        ...)
    {
        this.loggingService = loggingService;
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的派生类中,我不想重复此基类构造函数中的所有参数,所以我这样做:

public abstract class ViewModel
{
    private readonly IUnityContainer container;
    private ILoggingService loggingService;
    ...

    public ViewModel(IUnityContainer container)
    {
        this.container = container;
    }

    public ILoggingService LoggingService
    {
        get
        {
            if (this.loggingService == null)
            {
                this.loggingService = this.container.Resolve<IUnityContainer>();
            }

            return this.loggingService;
        }
    }

    ...
}
Run Code Online (Sandbox Code Playgroud)

现在我的派生类只需要将一个东西传递给我的基类构造函数.我也有很好的效果,只有在需要时才能解析我的依赖项.

但是,我已经知道传递一个IOC容器是一个坏主意.什么是最好的替代设计模式,记住传入的许多服务已经作为单身人士在我的IOC容器中注册?

.net c# design-patterns ioc-container inversion-of-control

3
推荐指数
2
解决办法
2254
查看次数