zoukankan      html  css  js  c++  java
  • New Features and changes of Ninject 3.3

    Ninject 3.3 beta1 has gone live. This release mainly focus on bug fix and platform update.

    Support .NET Standard 2.0

    Since version 3.3, Ninject starts to support .net standard 2.0. Microsoft announced .net standard 2.0 at Augest 14th which has more than doubled the set of available APIs. It makes much easier to port Ninject to .net standard 2.0. Previously there are many conditional compilations and even wrong behaviors during 4.0 pilot development. For example ReflectedType is not supported in .NET Standard 1.5. The workaround is to use DeclaringType. However DeclaringType is different with ReflectedType. So in release 3.3, we only support .net standard 2.0 and .net framework 4.5. The only difference is the auto module scanning feature. net framework supports to create and unload AppDomain while .net standard 2.0 doesn't.

    Ninject 3.3 also dropped support for .NET 3.5 and Silverlight.

    Array/List of concrete classes will return empty if the concrete class is not explictly binded

    The is a behavior change. If a concrete class is self bindable, but user didn't bind it explicitly, when request a list of it, it is more naturally to return an empty list rather than a list with one item. This should be a break change. But I think it is a correct move.

    Improved cyclical dependencies detection

    The cyclical dependencies detection has been improved for open generic types. Check the github issue for details.

    Conditional binding is being considered when score constructors

    When score constructors, previously, we will look for the one with most bindings matching regardless the binding condition.

    consider the below case:

     [Fact]
     public void UnsatisfiedConditionalShouldBeIngored()
     {
         kernel.Bind<Barracks>().ToSelf();
         kernel.Bind<IWeapon>().To<Sword>();
         kernel.Bind<IWarrior>().To<Samurai>().When(_ => false);
     
         var barracks = kernel.Get<Barracks>();
         barracks.Should().NotBeNull();
         barracks.Warrior.Should().BeNull();
         barracks.Weapon.Should().NotBeNull();
     }

    Barracks has 3 constructors, one with IWeapon, one with IWarrior, one with both. It should choose the one with only IWeapn. So please be advised that the condition method will be evaluated twice now.

    Singleton / circular dependency

    When request a singleton object which has property dependencies (or has OnActivation callback), during creating the dependecies (or executing the callback), the singleton object may have already created. In this case we should return the created singleton object instead of creating a new one.

    Check this commit for details.

    Other changes

    There are some other bug fixes and changes. For example some spelling correction in xml doc comments; start to use Appveyor as CI build server; Start to use CodeCov to track the code coverage; StyleCop compliance.

    For the complete change list, please refer to the ReleaseNotes.md and commits.

    Happy Injecting!

  • 相关阅读:
    通过进程ID获取基地址
    怎样获得某个进程的内存基地址?
    Delphi来实现一个IP地址输入控件
    如何在Windows服务程序中添加U盘插拔的消息
    delphi Format格式化函数
    CRC8算法DELPHI源码
    实现控件的透明背景
    定制控件背景颜色与背景位图
    实现系统滚动条换肤功能
    Delphi 获取命令行输出的函数
  • 原文地址:https://www.cnblogs.com/xushuo/p/Ninject-3_3-beta1-Released.html
Copyright © 2011-2022 走看看