小编lin*_*ncx的帖子

Unity:无法从不同的程序集注册类型

我正在尝试Dependency injection在我的MVC应用程序中实现.我正在使用Unity.Mvc3.dllIoC.我只是想知道Unity如何不能从另一个程序集中注册类型.这是代码:

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();

    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);

    var container = new UnityContainer();

    // ok: register type from this assembly
    container.RegisterType<IMessages, Messages>();

    // fail: register type from another assembly (service reference)
    container.RegisterType<IPlayerService, PlayerService>();

    DependencyResolver.SetResolver(new UnityDependencyResolver(container));
}

public class UnityDependencyResolver : IDependencyResolver
{
    private readonly IUnityContainer _container;

    public UnityDependencyResolver(IUnityContainer container)
    {
        this._container = container;
    }

    public object GetService(Type serviceType)
    {
        try
        {
            return _container.Resolve(serviceType);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    public IEnumerable<object> GetServices(Type …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc dependency-injection unity-container

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

如何在GitBash中禁用SSH并改为使用HTTPS

我在连接到Bitbucket的时候正在使用SSH,而且Bitbucket使用的端口22突然被阻止,所以我决定使用HTTPS选项.如何在git bash中禁用ssh并使用HTTPS代替?我已经重新安装了git,但它仍然使用SSH/Putty进行连接.

谢谢.

git ssh https

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

惰性(T)用法/初始化

我试图弄清楚这两种懒惰用法之间的区别是什么,哪一种更适合使用,或者只是一样?

Dim context As New Lazy(Of DbContext)

Dim context As Lazy(Of DbContext) = New Lazy(Of DbContext)(Function() New DbContext())
Run Code Online (Sandbox Code Playgroud)

vb.net lazy-evaluation

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

重构此Lambda表达式

我需要重构此代码,以便数据服务不会每行项查询两个workType.提前致谢.

        _attributeGroups = attributeGroups.Select(attributeGroupRowModel =>
            new AttributeGroupRowModel()
        {
            Name = attributeGroupRowModel.Name,               
            WorkType = workTypes.First(wt => wt.Id == attributeGroupRowModel.WorkTypeId).Description,
            IsExpired = workTypes.First(wt => wt.Id == attributeGroupRowModel.WorkTypeId).IsExpired, //todo: not efficient, to be refactored
        }).ToList();
Run Code Online (Sandbox Code Playgroud)

c# lambda

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

JQuery:单击复选框时更改元素的样式

我有一个 html 元素(使用 MVC3 Razor)

       <h2 class="price">
              @Html.LabelFor(vm => vm.Price)
              @Html.Encode(@Model.Price)
       </h2>
        <div id="checkbox-price">
              @Html.CheckBoxFor(vm => vm.IncludeToPayment) Include in payment.
        </div>
Run Code Online (Sandbox Code Playgroud)

当用户使用 JQUEry 取消选中/选中复选框时,如何更改 h2 元素的样式(在这种情况下,我想对内部的项目进行文本装饰:划线)?

提前致谢。

jquery checkboxfor

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