小编Sex*_*yMF的帖子

按键从字典中获取项目

我有这个结构:

static Dictionary<int, Dictionary<int, string>> tasks = 
    new Dictionary<int, Dictionary<int, string>>();
Run Code Online (Sandbox Code Playgroud)

它看起来像那样

[1]([8] => "str1")
[3]([8] => "str2")
[2]([6] => "str3")
[5]([6] => "str4")
Run Code Online (Sandbox Code Playgroud)

我想从这个列表中获取所有[8]字符串,意思是str1+ str2
该方法应如下所示:

static List<string> getTasksByNum(int num){

}
Run Code Online (Sandbox Code Playgroud)

我该如何访问它?

c# dictionary multi-level

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

子调用C#面向对象返回类型"this"

我有2个类,每个类在所有函数中返回自己:

public class Parent{
   public Parent SetId(string id){
      ...
      return this
   }
}

public class Child : Parent{
   public Child SetName(string id){
      ...
      return this
   }
}
Run Code Online (Sandbox Code Playgroud)

我想启用这种API:

new Child().SetId("id").SetName("name");
Run Code Online (Sandbox Code Playgroud)

SetName因为无法访问SetId的回报Parent,并SetName为上Child.

怎么样?

c# oop parent-child

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

无法访问已处置的对象 - wcf客户端

我有一个WCF客户端,我遇到了问题.
我不时会遇到这个例外:Cannot access a disposed object.这就是我打开连接的方式:

private static LeverateCrmServiceClient crm = null;

public static CrmServiceClient Get(string crmCertificateName)
        {

            if (crm != null)
            {
                crm.Close();
            }
            try 
            {
                crm = new LeverateCrmServiceClient("CrmServiceEndpoint");
                crm.ClientCredentials.ClientCertificate.SetCertificate(
                               StoreLocation.LocalMachine,
                               StoreName.My,
                               X509FindType.FindBySubjectName,
                               crmCertificateName);
            }
            catch (Exception e) 
            {
                log.Error("Cannot access CRM ", e);
                throw;
            }
            return crm;
        }
Run Code Online (Sandbox Code Playgroud)

如您所见,我每次都关闭并重新打开连接.您认为可能是什么问题?

堆:

System.ServiceModel.Security.MessageSecurityException: Message security verification failed. ---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.ServiceModel.Security.SymmetricSecurityProtocol'.
  at System.ServiceModel.Channels.CommunicationObject.ThrowIfClosedOrNotOpen()
  at System.ServiceModel.Security.MessageSecurityProtocol.VerifyIncomingMessage(Message& message, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)
  --- …
Run Code Online (Sandbox Code Playgroud)

c# wcf-client objectdisposedexception

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

laravel动态添加调度程序

我有一个系统,用户可以通过UI创建后台任务.
任务间隔是每隔几个小时(UI中的用户选择).

当用户通过ui创建任务时,我想动态地将它添加到调度程序.

如示例所示,这是静态的而不是动态的.

protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {
        DB::table('recent_users')->delete();
    })->daily();
}
Run Code Online (Sandbox Code Playgroud)

可能吗?如果没有,有哪些替代方案?

谢谢

scheduled-tasks laravel

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

Angular 5动态变量名称

我想动态地调用一个变量。

export class AppComponent  {
  my_a_variable = 'test a';
  my_b_variable = 'test b';
  type = 'a'; // this variable value will come from another place dynamically.
}
Run Code Online (Sandbox Code Playgroud)

在我的HTML中,我需要像

<div>{{my_{{type}}_variable}}</div>
Run Code Online (Sandbox Code Playgroud)

我知道可以用assoc数组解决,但是我不能在这里使用它。你能帮忙吗?

谢谢。

angular5

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

Github 操作 - 拉取请求与特定标签合并

我想在满足以下约束时触发操作。

pr 合并到主分支并且 pr 包含 label == 'site'。

这就是我想到的,创建 pr 时运行的问题。
当我将它合并到 main 时什么也没有发生。
我究竟做错了什么?

name: Build and push site
on:
  pull_request:
    branches: [main]
    types: [labeled, closed]

jobs:
  build-push-site:
    if: github.event.pull_request.merged == true && contains( github.event.pull_request.labels.*.name, 'site')
    uses: avifatal/nx-tokenct/.github/workflows/build-push.yml@main
    with:
      ...
Run Code Online (Sandbox Code Playgroud)

(受到拉取请求具有特定标签时运行 Github 操作的启发)
谢谢

github-actions

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

c#在编译/构建之前生成c#代码(如java中的maven插件)

我在c#.net中有一个项目.
我需要挂钩"pre build"事件,这样我就可以运行ac#class,它将为同一个项目生成其他c#类.
我知道在java中你可以使用maven插件生成源代码,是否可以在.net中使用?

谢谢.

c# code-generation pre-build-event

3
推荐指数
1
解决办法
4885
查看次数

Bootstrap - 导航栏固定顶部在另一个div内

我有一个div width:500px,并height:300px在页面的中间.
我希望这个div 里面有我的导航栏固定顶部.你可以请更正我的html/css来完成它吗?谢谢

http://jsfiddle.net/MgcDU/7874/

<div class="container" style="width:500px;height:300px;border:solid black 1px;overflow:scroll">
    <div class="row">
        <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
            <div class="navbar-inner" style="padding:10px">
                <div class="btn-group">
                    <button type="button" class="btn btn-default dropdown-toggle" style="height:70px;" data-toggle="dropdown">
                        <div class="icon-some"></div>Dropdown <span class="caret"></span>

                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="#">Dropdown link</a>
                        </li>
                        <li><a href="#">Dropdown link</a>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
    </div>
    <div id="wrapper">
        <div id="content">
            <p>some content</p>
            <p>some content</p>
            <p>some content</p>
            <p>some content</p>
            <p>some content</p>
            <p>some content</p>
            <p>some content</p>
            <p>some content</p>
            <p>some content</p>
            <p>some content</p>
            <p>some …
Run Code Online (Sandbox Code Playgroud)

html css twitter-bootstrap

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

Castle 无法解析所有已注册的组件

我有以下课程。

public interface ICampaignDal : ICrudDal<Campaign>
{
}
public class CampaignDal : BaseDal<Campaign>, ICampaignDal
{
}

public interface IPixelDal : ICrudDal<Pixel>
{
}
public class PixelDal : BaseDal<Pixel>, IPixelDal
{
}


public interface ICrudDal<T> where T : BaseEntity, new()
{
}
Run Code Online (Sandbox Code Playgroud)

这就是我注册它们的方式:

Container.Register(
     Types.FromAssembly(typeof (ICrudDal<>).Assembly)
             .BasedOn(typeof (ICrudDal<>)).WithServiceAllInterfaces());
Run Code Online (Sandbox Code Playgroud)

当我解决这个问题时,它工作正常:

Container.Resolve<ICampaignDal>();
Run Code Online (Sandbox Code Playgroud)

但是这个:

Container.Resolve<IPixelDal>();
Run Code Online (Sandbox Code Playgroud)

会产生一个错误:

"Type DataAccessLayer.IPixelDal is abstract.\r\n As such, it is not possible to instansiate it as implementation of service 'DataAccessLayer.IPixelDal'. Did you forget to proxy it?"

c# dependency-injection castle-windsor

3
推荐指数
1
解决办法
2313
查看次数

PhpStorm 生成构造函数参数功能的快捷方式

PhpStorm 中是否有快捷方式生成与$model2相同的代码$model1

class Test{    
    private $model1;
    public function __construct(string $model1, $model2)
    {
       $this->model1 = $model1;
       ....          
    }
}
Run Code Online (Sandbox Code Playgroud)

phpstorm

3
推荐指数
1
解决办法
2518
查看次数