特定
public class Original {
public static DoStuff() {
}
}
public class Derived : Original {
}
Run Code Online (Sandbox Code Playgroud)
在打电话时
Derived.DoStuff();
Run Code Online (Sandbox Code Playgroud)
除了要求的奇怪之外,是否有可能在内部DoStuff()检测它被调用的类?
即是有可能的范围内实施DoStuff(),告诉之间的区别Original.DoStuff();和Derived.DoStuff();
我想使用javascript将DOM树的当前状态序列化为字符串。尽管我更喜欢html,但生成的格式并不重要。
是否有捷径可寻?
作为记录,我想使用PhantomJs自动下载页面,使用js脚本进行操作,并保存页面的当前状态(但不保存为图像或pdf)。
我们来看一下经典的一阶函数示例:
function Get-MyName { "George" }
function Say-Hi([scriptblock]$to) {
Write-Host ("Hi "+(& $to))
}
Run Code Online (Sandbox Code Playgroud)
这很好用:
Say-Hi { "Fred Flintstone" }
Run Code Online (Sandbox Code Playgroud)
这不是:
Say-Hi Get-MyName
Run Code Online (Sandbox Code Playgroud)
因为Get-MyName被评估,而不是作为值本身传递.如何将Get-MyName作为值传递?
我在同一个项目中运行WebApi和Mvc(所以它们在进程中).Mvc主要用于服务资产(页面和生成的下载)以及用于ajax数据请求的web api.
为了成为RESTish,大多数WebApi请求都包含一组由以下类生成的链接:
public class ApiLinkMaker
{
public ApiLinkMaker(UrlHelper url, string authority) {
this.url = url;
this.authority = authority;
}
public ApiLinkMaker(ApiController controller)
: this(controller.Url, controller.Request.RequestUri.Authority) { }
public string MakeLink(string controller, string id) {
return "//" + authority + url.Route("DefaultApi", new { controller = controller, id = id });
}
}
Run Code Online (Sandbox Code Playgroud)
那里有一些其他的方法,但这确实是事情的核心,它运作良好.
现在我想优化特定页面.以前我有两个请求
现在我意识到,出于优化目的,在这种情况下最好只做一个.
问题是,由于html是由Mvc生成的,我无法创建似乎有用的Api UrlHelper.
我试过了
var url = new UrlHelper(new HttpRequestMessage(verb, controller.Request.Url.AbsoluteUri));
if (!url.Request.Properties.ContainsKey(HttpPropertyKeys.HttpConfigurationKey)) //http://stackoverflow.com/questions/11053598/how-to-mock-the-createresponset-extension-method-on-httprequestmessage
url.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
Run Code Online (Sandbox Code Playgroud)
但这仍然会爆炸
System.ArgumentException was unhandled by user …Run Code Online (Sandbox Code Playgroud) 我的一个工作需要PowerShell 3.0中ConvertTo-Json提供的命令行开关所以我在Windows Server 2008 R2(SP1)框中安装了WMF 3.0.重新启动后,所有使用作业的powershell都会导致错误:
[workspace] $ powershell.exe "& 'C:\Users\HUDSON~1\AppData\Local\Temp\hudson1263303013566726397.ps1'"
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "powershell.exe" (in directory "C:\hudson\jobs\MyProject\workspace"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at hudson.Proc$LocalProc.<init>(Proc.java:192)
at hudson.Proc$LocalProc.<init>(Proc.java:164)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:639)
at hudson.Launcher$ProcStarter.start(Launcher.java:274)
at hudson.Launcher$ProcStarter.join(Launcher.java:281)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:84)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:60)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:630)
at hudson.model.Build$RunnerImpl.build(Build.java:175)
at hudson.model.Build$RunnerImpl.doRun(Build.java:137)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:429)
at hudson.model.Run.run(Run.java:1366)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:145) …Run Code Online (Sandbox Code Playgroud) 我正在使用 运行命令行实用程序Process.Start。出于调试目的,我希望将其输出流发送到 Visual Studio 的“调试输出”面板 ( Debug.Write)。我想实时执行此操作,而不是等待该过程完成然后立即将其全部写入。
我知道这在理论上是可能的,但我对该对象的经验不够Stream,不知道如何做到这一点。
因此,作为相当普遍的做法,我们使用css内容来定位真正"风格"特定的文本.例如
.label:after { content: ":"; }
Run Code Online (Sandbox Code Playgroud)
然而有人指出,这种事情在某些文化中有所不同.哦,哦.
有没有人有一个很好的模式来处理这种事情,因为CSS文件通常不通过asp.net处理器传递,因此无法访问资源文件.
假设我有两个异步函数
Result1 result1 = await getResult1();
Result2 result2 = await getResult2();
doSomething(result1, result2);
Run Code Online (Sandbox Code Playgroud)
理想情况下,我希望编译器分析我的方法看到它getResult2()不依赖于结果,getResult1()并将其编译为调度两个同时运行的代码,在继续之前等待两者的结果.
问题1:那会发生什么?
问题2:如果没有,我如何做到这一点,假设Result1并且Result2没有共享基类型,因此我无法使用Task.WhenAll()
我有一个客户端VPN密码,我需要从命令行重复输入.我希望在我的powershell $配置文件中查询它,将其存储在shell实例范围内的变量中,然后在其他脚本中重复使用(以便它只存在于内存中),而不是将其存储在磁盘上.
我可以Read-Host用来查询密码,但我更喜欢弹出对话框(Paegent已经弹出一个对话框,我习惯了alt + tab'ing的工作流程,并在我重新启动计算机时输入密码).
什么是最简单的方法来实现相同的效果,Read-Host但有一个小的弹出对话框?
c# ×3
powershell ×3
.net ×2
asp.net ×2
asp.net-mvc ×1
async-await ×1
css ×1
dom ×1
hudson ×1
javascript ×1
localization ×1
mercurial ×1
scriptblock ×1
static ×1
stdout ×1
stream ×1