使用Open XML for Excel DocumentFormat.OpenXml.Spreadsheet,如何仅将文本的一部分设置为粗体?
var cell = new Cell {
//DataType = CellValues.InlineString,
CellReference = "A" + 1
};
// TODO: Set "bold text" to bold style
//var inlineString = new InlineString();
//inlineString.AppendChild(new Text { Text = "Normal text... bold text..." });
//cell.AppendChild(inlineString);
Run Code Online (Sandbox Code Playgroud)
注释掉现在使用的代码,但应该或可能应该更改.
在 ASP.NET Core 中,使用Swashbuckle.AspNetCore,如何保护对 Swagger UI 的访问与使用 -[Authorize]属性装饰它的方式相同?
[Authorize]当有人试图访问/swagger我的网络应用程序上的-URL时,我希望(等价于)-attribute 执行,就像对于通常装饰的控制器/操作一样,以便AuthenticationHandler<T>执行我的自定义。
如果我有许多目录名称作为文字字符串或包含在变量中,那么将这些目录组合在一起以形成完整路径的最简单方法是什么?
我知道
Path.Combine但这只需要2个字符串参数,我需要一个可以采用任意数量目录参数的解决方案.
例如:
string folder1 = "foo";
string folder2 = "bar";
CreateAPath("C:", folder1, folder2, folder1, folder1, folder2, "MyFile.txt")
有任何想法吗?C#是否支持方法中的无限args?
将ViewState移动到页面底部的最新和最好的方法是什么?
这可以在IHttpHandler中完成,可以在web.config中指定拦截对"*.aspx"的请求吗?
<httpHandlers>
<add verb="*" path="*.aspx" type="MyApp.OptimizedPageHandler" />
<httpHandlers>
Run Code Online (Sandbox Code Playgroud)
其他选择是,这可以在IHttpModule中完成,但这不是高效的,因为它将拦截所有请求.
它也可以在一个派生自Page或MasterPage类的类中完成,但这不是模块化的.
对此有任何性能损失吗?
有人一直在谈论Enums一般违反清洁守则原则,所以我正在寻找人们最喜欢的Enum反模式和替代解决方案.
例如,我见过这样的代码:
switch(enumValue) {
case myEnum.Value1:
// ...
break;
case myEnum.Value2:
// ...
break;
}
Run Code Online (Sandbox Code Playgroud)
它比带有魔术字符串的switch语句更好一步,但这可能已经通过工厂,容器或其他模式更好地解决了.
甚至像这样的老派代码:
if(enumValue == myEnum.Value1) {
// ...
} else if (enumValue == myEnum.Value2) {
// ...
}
Run Code Online (Sandbox Code Playgroud)
您对枚举有哪些其他反模式和更好的实现?
如何做一个textarea和input type="text" 高亮和可复制的iOS设备?
这不起作用:
<textarea readonly="readonly">Totally readonly, cannot be copied</textarea>
Run Code Online (Sandbox Code Playgroud)
也不是:
<textarea disabled="disabled">Totally readonly, cannot be copied</textarea>
Run Code Online (Sandbox Code Playgroud)
编辑:文本区域不断更新,因此对其进行一次性转换将不起作用.
textarea的内容也可以是HTML.
我有一个JSFiddle,我测试了这个:http://jsfiddle.net/sebnilsson/jfvWZ/
使用psake 4.5.0我试着运行我的default.ps1文件很多不同的方法,同时传递-properties和-parameters,但这些值只是忽略在根范围中的.ps1-script.
执行relative(在子文件夹中使用psake):
.\psake-4.5.0\psake.ps1 .\default.ps1 BuildSolution -properties @{"a"="a";"b"="b";"c"="c";"d"="d"} -parameters @{"w"="w";"x"="x";"y"="y";"z"="z"}
Run Code Online (Sandbox Code Playgroud)
使用导入的模块执行:
Import-Module .\psake-4.5.0\psake.psm1
Invoke-Psake .\default.ps1 BuildSolution -properties @{"a"="a";"b"="b";"c"="c";"d"="d"} -parameters @{"w"="w";"x"="x";"y"="y";"z"="z"}
Run Code Online (Sandbox Code Playgroud)
通过安装的Chocolatey-package执行:
psake .\default.ps1 BuildSolution -properties "@{'a'='a';'b'='b';'c'='c';'d'='d'}" -parameters "@{'w'='w';'x'='x';'y'='y';'z'='z'}"
Run Code Online (Sandbox Code Playgroud)
执行cmd.exe:
psake-4.5.0\psake.cmd default.ps1 BuildSolution -properties "@{'a'='a';'b'='b';'c'='c';'d'='d'}" -parameters "@{'w'='w';'x'='x';'y'='y';'z'='z'}"
Run Code Online (Sandbox Code Playgroud)
现在,default.ps1只是调试所有这些值:
// Since "properties" doesn't get populated, I also try "Param"
Param(
$w = $w, // Trying to populate from passed param
$x …Run Code Online (Sandbox Code Playgroud) 您可以使用 nLite(或选择的工具)删除 Vista 中的哪些功能和服务,以使 Vista 的虚拟 PC 映像尽可能小?
VPC 必须与 Visual Studio 中的开发配合使用。
今天正常安装的 Vista 大约是 12-14 GB,当我让它与 4 GB 的 Visual Studio 一起工作时,这很愚蠢。但对于 Visual Studio,它的总大小约为 8 GB,对于在多个副本中移动来说有点沉重。
如何lock根据特定的字符串键执行?
public void PerformUpdate(string key)
{
// TODO: Refine this, since they key-string won't
// be the same instance between calls
lock(key)
{
PerformUpdateImpl()
}
}
Run Code Online (Sandbox Code Playgroud)
我试图将锁定对象保留在一个ConcurrentDictionary,但不知怎的,这也不会阻止.
当使用EmbeddableDocumentStore对RavenDB,在什么地方得到的数据存储在磁盘上?
var documentStore = new EmbeddableDocumentStore { DataDirectory = "TestApp" };
Run Code Online (Sandbox Code Playgroud)
DataDirectory和磁盘位置之间是否存在关联?
更新:使用截至2011-08-09的最新版本.它是一个控制台应用程序,所以没有ASP.NET目录.
c# ×5
.net ×1
asp.net ×1
asp.net-core ×1
build ×1
copy-paste ×1
enums ×1
excel ×1
filesystems ×1
html ×1
ios ×1
locking ×1
openxml ×1
openxml-sdk ×1
psake ×1
ravendb ×1
readonly ×1
swagger-ui ×1
swashbuckle ×1
textarea ×1
viewstate ×1
virtual-pc ×1
webforms ×1