我想将我的代码库迁移到可为空的引用。迁移策略之一包括#nullable disable向所有文件添加前缀。我怎样才能自动完成呢?
如果我把Lazy放在我的对象的构造函数中,并且X没有在容器中注册,我得到了依赖项解析异常.
为什么我得到这个例外?我不喜欢它,因为我无法在运行时选择组件.用例示例:
class Controller
{
public Controller(Lazy<A> a, Lazy<B> b) { /* (...) */ }
Lazy<A> a;
Lazy<B> b;
public IActionResult Get(){
if(someConfig)
return Json(a.Value.Execute());
else
return Json(b.Value.Execute());
}
}
Run Code Online (Sandbox Code Playgroud)
为此,我需要注册组件A和B.即使从未使用过B,我的程序也会失败.我希望B是可选的,仍然由autofac管理.
如果我有组件列表,并且只想使用一个组件,这就是更大的问题.例如:
class Controller
{
Controller(IEnumerable<Component> components) { /* (...) */ }
IActionResult Get()
{
return components.First(n => n.Name == configuredComponent).Execute();
}
}
Run Code Online (Sandbox Code Playgroud)
我不再得到异常是没有注册的东西,但是一切都是构建的.使用起来也很尴尬.
Microsoft.AspNetCore.Authentication.AuthenticationProperties.ExpiresUtc传递给in 的日期HttpContext.SignInAsync和传递给 的日期有什么区别Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions.ExpireTimeSpan?
两者的文档都说它控制time at which the authentication ticket expires. 那么我应该使用哪一个在一段时间后放弃登录呢?
我在 terraform 模块中定义了自定义资源:
resource "aws_alb_target_group" "whatever"
{
....
}
Run Code Online (Sandbox Code Playgroud)
事实证明whatever这个名字不好,我需要更新它。
经典的方法是登录到每个环境并执行terraform state mv,但是我有很多环境,并且没有自动化执行此类操作。
如何在不手动移动状态的情况下更改资源名称(仅通过编辑 terraform 模块和应用计划)?