小编Kev*_*ter的帖子

如何将IEnumerable <String>拆分为IEnumerable <string>组

我有一个IEnumerable<string>我想分成三组,所以如果我的输入有6个项目,我会得到一个IEnumerable<IEnumerable<string>>返回的两个项目,每个项目将包含IEnumerable<string>我的字符串内容.

我正在寻找如何使用Linq而不是简单的for循环

谢谢

c# linq

30
推荐指数
4
解决办法
2万
查看次数

Visual Studio无法找到w3wp进程

我有一个间歇性的问题,Visual Studio无法在尝试附加到进程时看到正在运行的W3wp.exe进程,Visual Studio的其他实例可以看到该进程并重新启动visual studio使其出现在附加到进程列表中.

点击刷新按钮没有任何区别,我可以使用Web应用程序,而无法在列表中看到该过程.

有任何想法吗?

c# visual-studio

28
推荐指数
4
解决办法
4万
查看次数

如何将性能计数器添加到我已创建的类别中

我已经创建了一个PerformanceCounterCategory,如下所示

var category = PerformanceCounterCategory.Create("MyCat", "Cat Help",
    PerformanceCounterCategoryType.SingleInstance, "MyCounter", "Counter Help);
Run Code Online (Sandbox Code Playgroud)

如何在类别中添加新计数器以监控其他项目?
我找不到它的api.

.net c# performancecounter

24
推荐指数
1
解决办法
4694
查看次数

为什么Mage.exe不生成compatibleFrameworks属性?

我们使用Mage.exe生成应用程序的清单作为构建过程的一部分.升级到.NET 4后,我们现在发现它生成了无效的清单.

原因是我们生成每个构建的应用程序清单中没有设置compatibleFrameworks属性.

有没有办法可以让Mage.exe添加这个元素,还是应该只更新现有的清单?

clickonce .net-4.0 mage

13
推荐指数
2
解决办法
4327
查看次数

IEquatables实现仅在覆盖基本Equals时调用

我有以下课程

    class Product : IEquatable<Product>
{
    public Guid Id { get; set; }
    public bool Equals(Product other)
    {
        return Id.Equals(other.Id);
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我尝试创建列表项的唯一列表,如下所示

            Guid a = Guid.NewGuid();
        List<Product> listA = new List<Product>();
        listA.Add(new Product(){Id = a});

        List<Product> listB = new List<Product>();
        listB.Add(new Product()
        {
            Id = a
        });
        Debug.Assert(listA.Union(listB).Count()==1);
Run Code Online (Sandbox Code Playgroud)

返回两个项目,直到我覆盖object.Equals方法,一旦我这样做,我的代码如下

class Product : IEquatable<Product>
{
    public Guid Id { get; set; }
    public bool Equals(Product other)
    {
        if (ReferenceEquals(null, other)) return false;
        if (ReferenceEquals(this, other)) return true;
        return other.Id.Equals(Id);
    } …
Run Code Online (Sandbox Code Playgroud)

.net c# generics

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

Visual Studio 2008的Cyclomatic复杂性

是否有任何工具可以在调试符号所在的左侧栏中显示Visual Studio的圈复杂度?

我似乎记得Resharper有一个插件,但不认为它适用于4.5

有没有人见过任何类似的工具,除了VS内置的支持

.net c# visual-studio-2008 visual-studio

6
推荐指数
1
解决办法
1891
查看次数

有谁知道哪里有c#代码或dll可以生成样本信用卡号

对于我们正在开发的应用程序,我需要生成通过Luhn算法但也是唯一的样本信用卡号,因此我们不能使用样本信用卡号.

我们需要能够一次生成大约300个卡号,理想情况下,我可以在生成输入数据时执行此操作.

非常感谢

.net c# credit-card luhn

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

如何在powershell中用美元符号替换字符串

在Powershell中给出以下字符串

$string = "this is a sample of 'my' text $PSP.what do you think"
Run Code Online (Sandbox Code Playgroud)

如何使用-replace函数将字符串转换为

this is a sample of 'my' text Hello.what do you think
Run Code Online (Sandbox Code Playgroud)

我显然需要以某种方式逃避字符串,而且$ PSP在我的脚本中不是声明的变量

我需要更改$ PSP的所有提及其他字符串

powershell

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

如何在Ninject中修饰实现特定接口的所有绑定

我正在使用Jimmy Bogard的Mediatr并试图在这里使用pipleine示例

我的问题是虽然我可以得到所有关闭的泛型类型

     kernel.Bind(
            x =>
                x.FromAssemblyContaining<ExpensiveRequest>()
                    .SelectAllClasses()
                    .InheritedFrom(typeof (IRequestHandler<,>)).BindAllInterfaces()
Run Code Online (Sandbox Code Playgroud)

我不能用MediatorPipeline来装饰它们.

所以,如果我使用StructureMap,我可以使用这样的东西

cfg.For(typeof(IRequestHandler<,>)).DecorateAllWith(typeof(MediatorPipeline<,>));
Run Code Online (Sandbox Code Playgroud)

我无法找到如何使用Ninject实现它,以便在调用我的Mediator时它使用Mediator管道,然后使用原始的Handler

ninject mediatr

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

使用 Stackexchange Redis 时,会创建数千个连接

我们刚刚开始通过 Web 和辅助角色使用 Azure Redis 缓存。我们发现,在相当少量的使用情况下,创建了约 2.5K 个连接。

我们正在使用包装在连接管理器中的 StackExchange.Redis nuget 包

  public class RedisConnManager
{
    private readonly IConfiguration configuration;

    public RedisConnManager(IConfiguration configuration)
    {
        this.configuration = configuration;
    }

    public Lazy<ConnectionMultiplexer> LazyConnection
    {
        get
        {
            return new Lazy<ConnectionMultiplexer>(
                () => ConnectionMultiplexer.Connect(
                    this.configuration.SessionManagerRedisConnectionString));
        }
    }
    public ConnectionMultiplexer Connection => this.LazyConnection.Value;
}
Run Code Online (Sandbox Code Playgroud)

然后使用 Ninject 作为单例将该类注入到需要的依赖类中

           kernel.Bind<RedisConnManager>().To<RedisConnManager>().InSingletonScope();
Run Code Online (Sandbox Code Playgroud)

然后消费如下

 var cache = this.redisConnManager.Connection.GetDatabase();
                key = cachable.GenerateKey();
                RedisValue result = cache.StringGet(key);
Run Code Online (Sandbox Code Playgroud)

我检查过 ConnectionManager 的构造函数不会被多次调用

我们应该看到这么多联系吗?

caching redis lazy-initialization stackexchange.redis

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