在一些情况下,我最常使用"混蛋注射".当我有一个"适当的"依赖注入构造函数时:
public class ThingMaker {
...
public ThingMaker(IThingSource source){
_source = source;
}
Run Code Online (Sandbox Code Playgroud)
但是,对于我打算作为公共API(其他开发团队将使用的类)的类,我永远找不到比编写具有最可能需要的依赖项的默认"bastard"构造函数更好的选择:
public ThingMaker() : this(new DefaultThingSource()) {}
...
}
Run Code Online (Sandbox Code Playgroud)
这里明显的缺点是,这会对DefaultThingSource产生静态依赖; 理想情况下,没有这种依赖性,消费者总是会注入他们想要的任何IThingSource.但是,这太难用了; 消费者希望新建一个ThingMaker并开始制作物品,然后几个月后,在需要时注入其他东西.在我看来,这只留下了几个选项:
男孩,#3肯定看起来很有吸引力.还有另一种更好的选择吗?#1或#2似乎不值得.
在处理.vue文件时使用ESLint和Prettier的Visual Studio代码中,我似乎无法正确地自动修复vue/max-attributes-per-line.
例如,将vue/max-attributes-per-line设置为'off',并且我尝试手动添加换行符,它会将其更正为始终使每个元素不超过一行,无论它是否为81,120 ,200或更多字符宽. 我怎样才能弄清楚什么是强制我的标记元素到一行?
我正在使用ESLint版本5.1.0和Visual Studio代码(没有Prettier扩展),Prettier 1.14.2.
这是.vue文件中的示例 - 无论我做什么,什么时候,我都无法使用多行 'vue/max-attributes-per-line': 'off'.每次我保存,它都会强制标记的长行全部在一行上.
<template>
<font-awesome-icon v-if="statusOptions.icon" :icon="statusOptions.icon" :spin="statusOptions.isIconSpin" :class="['saving-indicator', 'pl-1', 'pt-1', statusOptions.iconClasses]" />
</template>
Run Code Online (Sandbox Code Playgroud)
如果我设置'vue/max-attributes-per-line': 2,它的格式如此,有一个换行符(这也是非常错误的).
<font-awesome-icon v-if="statusOptions.icon"
:icon="statusOptions.icon" :spin="statusOptions.isIconSpin" :class="['saving-indicator', 'pl-1', 'pt-1', statusOptions.iconClasses]" />
Run Code Online (Sandbox Code Playgroud)
如果我尝试手动重新格式化,那么当我保存时它只会恢复到上面的状态.
另外,当我按下Ctrl + S时,它似乎重新格式化了两次:首先它重新格式化以将其全部放在一行上,然后半秒后,上面的格式化结果. 有什么想法?造成这种奇怪的原因是 - 有多个重组器正在运行吗?我怎么弄清楚第一个禁用它的是什么?
VS Code工作区设置:
{
"editor.formatOnType": false,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"[javascript]": {
"editor.tabSize": 2
},
"[vue]": {
"editor.tabSize": 2
},
"[csharp]": {
"editor.tabSize": 4
},
"javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
"javascript.referencesCodeLens.enabled": true,
"vetur.validation.script": false,
"vetur.validation.template": false, …Run Code Online (Sandbox Code Playgroud) 在我的Vue + Vuex项目中,我正在尝试使用Visual Studio Code进行调试.我使用Chrome调试工具正确启动调试器,并正确使用地图,但当我尝试在.js或.vue文件中放置断点时,VS Code似乎将断点放在错误的位置.例如,在这里我尝试在第40行的一个getter中放置一个断点,但最后会有15行:
这是VS Code中的错误,还是其他一些问题?有关如何修复的任何建议?
其他行上的其他断点具有相同的行为,出现在后面的行上,但我无法检测到模式.它发生在.js和.vue文件中,它发生在Object声明和根级传统函数定义中.
我正在使用VS Code 1.24.0.
在Windows Server 2008下的IIS7中,我有一个虚拟目录,其中包含匿名访问和Windows身份验证.在我的web.config中,我有:
<authentication mode="Windows"/>
<authorization>
<allow roles="MYGROUP"/>
<deny users="*"/>
</authorization>
Run Code Online (Sandbox Code Playgroud)
和
<system.webServer>
<!-- IIS7 security settings -->
<security>
<authorization>
<add accessType="Deny" users="*"/>
<add accessType="Allow" roles="MYGROUP"/>
</authorization>
</security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
然而,当我从IE访问default.aspx并在Global.asax.vb Application_AuthenticateRequest()中设置断点时,我得到一个空的HttpContext.Current.User,我期待我自己的身份.几乎就像匿名访问一样?
我该怎么做才能解决这个问题?一切似乎都适用于IIS6.
在我的 Blazor WebAssembly 客户端中,我有以下应用程序设置:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
}
}
Run Code Online (Sandbox Code Playgroud)
那么,为什么在本地运行时,我的浏览器控制台仍然会出现无尽的问题呢?
info: System.Net.Http.HttpClient.MyNamedClientName.ClientHandler[101]
Received HTTP response headers after 190ms - 200 blazor.webassembly.js:1:9737
info: System.Net.Http.HttpClient.MyNamedClientName.LogicalHandler[101]
End processing HTTP request after 193ms - 200 blazor.webassembly.js:1:9737
info: System.Net.Http.HttpClient.MyNamedClientName.ClientHandler[101]
Received HTTP response headers after 267ms - 200 blazor.webassembly.js:1:9737
info: System.Net.Http.HttpClient.MyNamedClientName.LogicalHandler[101]
End processing HTTP request after 274ms - 200 blazor.webassembly.js:1:9737
info: System.Net.Http.HttpClient.MyNamedClientName.ClientHandler[101]
Received HTTP response headers after 316ms - 200 blazor.webassembly.js:1:9737
info: System.Net.Http.HttpClient.MyNamedClientName.LogicalHandler[101]
End processing HTTP request after 319ms - …Run Code Online (Sandbox Code Playgroud) 在服务器端 ASP.NET 中,我们可以asp-append-version=true对 .cshtml 文件中的静态资产进行处理,以便自动将文件的哈希附加到文件名。但是,在 Blazor WebAssembly 中,这不起作用,这是有道理的,因为我有一个简单的 index.html 文件,它引导 Blazor 并引用静态文件,而不是服务器修改的文件。
那么在 Blazor WebAssembly 的 index.html 文件中是否有一种好方法可以将哈希附加到静态文件的 URL 中,结果类似于旧的asp-append-version=true?例如,要 make <link href="css/site.css" rel="stylesheet" />become <link href="css/site.css?v=1234abc..." rel="stylesheet" />,因此在部署时更改 site.css 将导致所有客户端 GET 新更改的静态文件,而不是依赖缓存?
我读了这篇文章,但仍然遇到问题:
我有我的 Blazor WebAssembly 站点,其中有一个静态 index.html 文件,可以以正常方式引导 Blazor。在其中<head>,我有<link href="css/app.min.css" rel="stylesheet" />。该文件是使用部署时的 Dockerfile RUN 步骤从 SCSS 构建的。
根据该问题,我不需要缓存清除 URL,因为 Blazor 会根据需要自动请求一个新的 URL。然而,当我部署站点并在 Firefox 中打开它时,我得到了旧样式,并在 Firefox 开发人员工具网络选项卡中看到 app.min.css 是从磁盘缓存中检索的。我必须按 Ctrl+F5 才能获取新样式。
那么这个链条到底出了什么问题呢?在我看来,每次部署时我仍然需要 CSS 的缓存清除 URL。 需要进行哪些设置才能在站点二进制文件更改时下载我的 CSS(按照 Steve Sanderson 在该问题中建议的方式)?
在SSIS中,我已经有一个使用WSDL发送SMS的Web服务任务.我确实能够使用此任务发送短信.
我想从数据库中为此任务提供供应值,例如手机号码,消息正文,用户ID等.
如何创建可以作为Web Service任务的输入传递的复杂类型用户变量?
我们RAISERROR在SQL Server中使用.语法是RAISERROR('Some Message.', 16, 1).
有什么用的参数值16,并1用RAISERROR()在我的例子吗?我在网上搜索,发现这些参数称为Severity和State.文档告诉我们这些值的一些深奥含义,但没有给我们如何使用它们或为什么提供良好的指导.
我想知道的是什么意思Severity和State?它们应该如何使用?
如何让我的vnext API返回XML和JSON?
我认为使用带有application/xml的content-type可以像以前一样工作.请注意,我尝试使用Accept:application/xml.
但似乎没有.
编辑:
这是我的project.json文件:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
"Microsoft.AspNet.Mvc": "6.0.0-beta4",
"Microsoft.AspNet.Mvc.Xml": "6.0.0-beta4"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
]
}
Run Code Online (Sandbox Code Playgroud)
这是我的startup.cs:
public class Startup
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.ConfigureMvc(options =>
{ …Run Code Online (Sandbox Code Playgroud) asp.net-core ×2
blazor ×2
c# ×2
vue.js ×2
.net ×1
asp.net ×1
constructor ×1
content-type ×1
css ×1
debugging ×1
eslint ×1
iis-7 ×1
oop ×1
prettier ×1
sql-server ×1
ssis ×1
vuex ×1
web-services ×1
xml ×1