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!

时间: 2024-07-30 23:54:30

New Features and changes of Ninject 3.3的相关文章

Note3:大话Ninject

1.简介 Ninject(官网:http://www.ninject.org/)是一个快如闪电,超轻量级的基于的.Net平台的依赖注入框架.它能够帮助你把应用程序分离成一个个松耦合,高内聚的模块,然后用一种灵活的方式组装起来.通过使用Ninject配套你的软件架构,那么代码将会变得更加容易编写,重用性强,易于测试和修改. Ninject is a lightning-fast, ultra-lightweight dependency injector for .NET applications

Ninject之旅之五:Ninject XML配置

摘要 使用XML配置,需要添加Ninject XML扩展的引用.下一步是添加一个或多个包含类型注册的XML文件.记得这些文件应该跟应用程序一起发布.因此不要忘记将XML文件的属性设置成“Copy if newer”. XML配置文件像下面的配置一样: <module name="moduleName"> <bind service="Namespace.IService1, AssemblyName" to="Namespace.Conc

Image Retrieval Using Customized Bag of Features

This example shows how to create a Content Based Image Retrieval (CBIR) system using a customized bag-of-features workflow. Introduction Content Based Image Retrieval (CBIR) systems are used to find images that are visually similar to a query image.

Extracting and composing robust features with denosing autoencoders 论文

这是一篇发表于2008年初的论文. 文章主要讲了利用 denosing autoencoder来学习 robust的中间特征..进上步,说明,利用这个方法,可以初始化神经网络的权值..这就相当于一种非监督学习的方法来训练神经网络. 当我们在用神经网络解决各种识别任务时,如果我们想要网络的性能更好,就需要更深层或更wider的神经网络来建模,Model出更复杂的分布.  网络变深以后,如何训练是一个很重要问题,如果训练不好,深层网络的性能真的不如浅层的神经网络.. 在训练深层网络的解决方法的道路上

Ninject之旅之八:Ninject插件模型

摘要 在前面的章节中,我们看了在单一的绑定条件下Ninject能够处理依赖类型,就是说,每个服务类型只绑定到单一的实现类型.然而,有些情况下我们需要绑定一个抽象服务类型到多个实现,这叫多个绑定.多个绑定有两种情况.第一个是插件模型实现,另一个是上下文绑定.这篇文章介绍插件模型实现,下一篇文章介绍上下文绑定. 插件模型让一个应用程序获得很强的可扩展性而不用修改源代码.下面的例子,我们将实现一个音乐播放器应用程序,使用解码插件来支持不同的音乐格式.这个应用程序使用两个内置的解码器,也可以添加更多的解

论文笔记之:Speed Up Tracking by Ignoring Features

Speed Up Tracking by Ignoring Features CVPR 2014 Abstract:本文提出一种特征选择的算法,来实现用最"精简"的特征以进行目标跟踪.重点是提出一种上界 (Upper Bound)来表示一块区域包含目标物体的概率,并且忽略掉这个 bound比较小的区域.我们的实验表明,忽略掉 90%的特征,仍然取得了不错的结果(未损失精度). Ignoring Features in Tracking .  基于滑动窗口的跟踪器,计算大量的 bound

论文笔记之:Heterogeneous Image Features Integration via Multi-Modal Semi-Supervised Learning Model

Heterogeneous Image Features Integration via Multi-Modal Semi-Supervised Learning Model ICCV 2013 本文提出了一种结合多种传统手工设计 feature 的多模态方法,在 label propagation 的基础上进行标签传递,进行半监督学习,综合利用各种 feature 的优势,自适应的对各种feature 的效果进行加权,即:对于判别性较好的 feature给予较高的权重,较差的 feature

android wear开发之:增加可穿戴设备功能到通知中 - Adding Wearable Features to Notifications

注:本文内容来自:https://developer.android.com/training/wearables/notifications/index.html 翻译水平有限,如有疏漏,欢迎批评指教. 译:山人 增加可穿戴设备功能到通知中 Adding Wearable Features to Notifications When an Android handheld (phone or tablet) and Android wearable are connected, the han

论文笔记《Feedforward semantic segmentation with zoom-out features》

<Feedforward semantic segmentation with zoom-out features>,CVPR 2015 这篇文章的方法是superpixel-level的,主要是基于CNN实现,是fully supervised. 首先对输入图像以superpixel为单位提取CNN特征(使用VGG16),然后把这些特征作为CNN classifier(使用imageNet)的输入,imageNet输出是每个superpixel的class. 这篇文章的亮点应该是:1,它把C