小编SGa*_*att的帖子

如何将PowerShell的Format-List输出作为字符串?

我想将Format-List命令的输出写入事件日志,所以我需要它作为字符串.

有没有一种通用的方法可以做到这一点,而不依赖于知道什么是格式化?

powershell powershell-3.0

20
推荐指数
1
解决办法
1万
查看次数

WCF中AppDomain的生命周期是多少?

WCF中AppDomain的生命周期是多少?

它与InstanceContextMode,ConcurrencyMode和/或AspNetCompatibilityRequirements RequirementsMode有关吗?

我想知道我的静态变量将存在多长时间以及它们必须重新创建的频率.

wcf static appdomain instancecontextmode

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

如何使用try-catch-finally重构代码

我必须创建一堆看起来像这样的方法.更改的内容将是方法名称,返回类型和中间标记的行 - 其余的将是相同的.是否有一种干净的方式来重构这个,以便我不重复自己?

private bool CanPerform(WindowsIdentity identity, string applicationName, int operation)
{
    IAzApplication3 application = null;
    IAzClientContext3 context = null;
    try
    {
        application = this.store.OpenApplication(applicationName, null) as IAzApplication3;

        ulong token = (ulong)identity.Token.ToInt64();
        context = application.InitializeClientContextFromToken(token, null) as IAzClientContext3;

        // lines that change go here
    }
    catch (COMException e)
    {
        throw new SecurityException(string.Format("Unable to check operation '{0}'", operation), e);
    }
    finally
    {
        Marshal.FinalReleaseComObject(context);
        Marshal.FinalReleaseComObject(application);
    }
}
Run Code Online (Sandbox Code Playgroud)

我意识到这可能是基本的东西,但我一个人工作,所以没有人问.

c# refactoring

2
推荐指数
1
解决办法
446
查看次数