小编Bor*_*sky的帖子

如何获取包的所有版本的列表?

我想获得一个包的版本列表.这是什么命令行?

在版本中搜索也是很好的,例如:所有版本高于或低于特定版本.

chocolatey

10
推荐指数
3
解决办法
4174
查看次数

使用PowerShell和SMO恢复数据库时显示进度

我有一个用PowerShell和SMO恢复数据库的脚本.现在我知道我可以在恢复对象上将事件处理程序传递给PercentComplete,并在恢复时获得恢复的进度.问题是我不知道如何创建一个事件处理程序并在PowerShell中传递一个函数?我可以在C#中做到这一点

restore.PercentComplete += new PercentCompleteEventHandler(restore_PercentComplete);

static void restore_PercentComplete(object sender, PercentCompleteEventArgs e)
{
  System.Console.WriteLine("{0}", e.Percent);
}
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

谢谢.

sql-server powershell smo event-handling

9
推荐指数
1
解决办法
4314
查看次数

自动部署Windows服务 - 工具

我正在寻找有关将Windows服务自动部署到多台计算机的工具的建议.该工具应该能够: - 停止/启动服务 - 复制文件 - 根据某些CSV/Excel文件修改每个目标服务器上的配置文件

优点:Web界面,通过电子邮件发送通知,压缩/解压缩

以下是我听到的工具,我开始评估,但我想听听那些在自动部署过程中实际应用其中一个(或其他一些工具)的人.

PS在SO上有一个类似的问题,但它没有回答我的问题: WCF服务部署 - 工具

回答问:您计划部署多少台服务器?答:目前有2个数据中心的20台服务器.这些数字可能会在未来增长

问:有多少用户参与设计和执行部署?答:一个人会设计部署,而另一个人(一个人)会执行它

问:您的部署是否需要跨层同步?答:我只需要部署一个Windows服务,没有数据库更改,没有IIS或任何其他Web层

问:审核和报告对您有多重要?答:我希望该工具能够报告其成功与否.看到所有部署的服务器的完整仪表板及其版本和最近的更改也会很高兴.

windows deployment service wcf windows-services

8
推荐指数
1
解决办法
3760
查看次数

当测试并行运行时,FakeItEasy有时无法创建假

在尝试伪造简单的intefrace时,使用FakeItEasy的单元测试会随机失败.它偶尔会在不同的测试中出现并且不稳定.

这是我需要伪造的示例界面:

public interface IJobSuiteFilterApplier
{
     JobSuiteDto FilterJobSuites(JobSuiteDto jobSuiteDto, JobSuiteFilter jobSuiteFilter);
}
Run Code Online (Sandbox Code Playgroud)

这是一段创建假的代码,有时会失败:

var jobSuiteFilterApplier = A.Fake<IJobSuiteFilterApplier>(x => x.Strict());
Run Code Online (Sandbox Code Playgroud)

这是例外细节:

FakeItEasy.Core.FakeCreationException: 
  Failed to create fake of type "QS.TestShell.Server.ExecutionPlanner.Queries.IExecutionPlannerQueryService".

  Below is a list of reasons for failure per attempted constructor:
    No constructor arguments failed:
      No usable default constructor was found on the type QS.TestShell.Server.ExecutionPlanner.Queries.IExecutionPlannerQueryService.
      An exception was caught during this call. Its message was:
      Collection was modified; enumeration operation may not execute.


    at FakeItEasy.Core.DefaultExceptionThrower.ThrowFailedToGenerateProxyWithResolvedConstructors(Type typeOfFake, String reasonForFailureOfUnspecifiedConstructor, IEnumerable`1 resolvedConstructors)
   at FakeItEasy.Creation.FakeObjectCreator.TryCreateFakeWithDummyArgumentsForConstructor(Type …
Run Code Online (Sandbox Code Playgroud)

c# unit-testing mocking fakeiteasy

5
推荐指数
1
解决办法
1306
查看次数

使用Log Injection Module时,在Autofac中显式解析ILog

我使用以下代码为所有需要它的类注册log4net.

public class LogInjectionModule : Module
{
    private readonly string _configPath;

    public LogInjectionModule(string configPath)
    {
        _configPath = configPath;
    }

    protected override void AttachToComponentRegistration(IComponentRegistry registry,
        IComponentRegistration registration)
    {
        XmlConfigurator.Configure(new FileInfo(_configPath));

        registration.Preparing += OnComponentPreparing;
    }

    private static void OnComponentPreparing(object sender, PreparingEventArgs e)
    {
        var t = e.Component.Activator.LimitType;
        e.Parameters = e.Parameters.Union(new[]
                                          {
                                              new ResolvedParameter((p, i) => p.ParameterType == typeof (ILog),
                                                  (p, i) => LogManager.GetLogger(t))
                                          });
    }
}
Run Code Online (Sandbox Code Playgroud)

使用autofac的类型扫描注册所有类:

builder.RegisterAssemblyTypes(typeof (IResourceFinder).Assembly)
 .AsImplementedInterfaces();
Run Code Online (Sandbox Code Playgroud)

它工作正常!

需要明确注册一个类尝试解决ILog并失败

builder.Register(x => new ClassThatNeedsILog(x.Resolve<ILog>())).AsImplementedInterfaces();
Run Code Online (Sandbox Code Playgroud)

这是上课

public class ClassThatNeedsILog
{
    public …
Run Code Online (Sandbox Code Playgroud)

.net c# log4net dependency-injection autofac

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

ReSharper代码注释异步任务&lt;T&gt;

是否可以标记的结果async Task<T>可以为null?使用属性[CanBeNull]不起作用,因为异步Task的返回值永远不会为null。

[CanBeNull] // not working...
private async Task<T> doSomeFancyAsyncStuff([NotNull] object icantbenull) { ...
Run Code Online (Sandbox Code Playgroud)

.net c# resharper annotations async-await

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