On the heels of the Ninject 2.0 release, I am happy to announce the release of the Ninject Interception Extension 2.0. This release provides API backward compatibility for the 1.5 version as well as new method interception, enhanced binding syntax, automatic property changed notification, as well as support for Castle DynamicProxy 2.2 and LinFu DynamicProxy. I will be writing a follow up post about the new features and usage patterns.

I want to thank Krzysztof Koźmic for his help with the Castle DynamicProxy 2.2 integration and Michael Hart for letting me merge his Ninject 1.5 method interception code into the new extension.

You will find downloads on the GitHub dowload page for .NET 3.5, Silverlight 3, and Mono 2.0. For those using automatic module loading or only want to use one DynamicProxy dependency without worrying about delay loading, there are three .NET 3.5 downloads: Castle+LinFu, Castle, and LinFu. Go get it!

{ 2 comments }

I have been playing with the Ninject conventions binding extension syntax and usage model. It was originally based on the StructureMap assembly scanner, but I want to use the API in a different fashion.

I have been working on making the API more like LINQ in the way you think and use it. Here is a sampling of the new API that I am testing. Remember, you would never bind like this, ideally you would set up a few different scans to bind everything the way you want it.

IKernel kernel = new StandardKernel();
kernel.Scan(
	x =>
	{
		// set up the source collection of types to process
		x.FromCallingAssembly();
		x.From( from assembly in AppDomain.CurrentDomain.GetAssemblies()
				from type in assembly.GetExportedTypes()
				select type );
		x.FromAssemblyContaining<IGenericView>();
		x.FromAssembliesInPath( "." );
		x.FomAssembliesMatching( "*.Model.dll" );
		x.FromAssemblyContaining(new[] {typeof (IGenericView), typeof (StringView)});

		// Filter out what you want
		x.Where( type => !type.IsAbstract );
		x.WhereTypeIsInNamespace( "Base.Model" );
		x.WhereTypeIsInNamespaceOf<StringView>();
		x.WhereTypeIsNotInNamespace( "Base.Test" );
		x.WhereTypeIsNotInNamespaceOf<StandardKernel>();
		x.WhereTypeInheritsFrom<IGenericView>();

		// Exclude items even if they match your Where criteria
		x.Excluding<INinjectSettings>();
		x.Excluding( new[] {typeof (IServiceProvider), typeof (IInitializable)} );

		// Include items whether or not they match your Where criteria
		x.Including<DefaultView>();

		// Tell the scanner how to determine bindings
		x.BindWithDefaultConventions();

		// Declare the binding scope for scanned members
		x.InTransientScope();
	} );

Some API calls will not be available on all platforms due to security restrictions of course.

{ 0 comments }

Ninject 1.5 and 2.0 Released!

February 25, 2010

That’s right! We have officially released Ninject 1.5 and 2.0! Ninject 2.0 has been in beta for exactly one year and we are very happy to announce its release. You can download the binaries from the Ninject.org web site. Expect more posts here and on Nate’s blog with more information.
Over the next couple weeks we [...]

Read the full article →

TFS Shell Extension

January 29, 2010

If you are using the TFS Shell Extension and you get an error dialog when choosing Team Foundation Server -> Reconnect
—————————
Unable to Reconnect
—————————
Unable to connect to Team Foundation Server
—————————
OK
—————————
There is a workaround. TFS extension only supports windows credentials at the moment, so if the server is using domain authentication, you can try to open your [...]

Read the full article →

Ninject.Extensions.Interception and IAutoNotifyPropertyChanged (IANPC)

January 23, 2010

After having conversation on twitter with Jonas Folleso about an automatic INotifyPropertyChanged implementation, I couldn’t resist digging in and seeing what I can do. He also has a blog post that is definitely worth reading on this subject. He solved the same problem through the IProvider functionality in Ninject. The code is based on his initial implementation. [...]

Read the full article →

Ninject.Extensions.Interception now supports DynamicProxy2

January 23, 2010

Seeing that people wanted to use Castle DynamicProxy2 with Ninject for interception, I ported the support from Ninject 1.5 and we now have support for using DynamicProxy2 built-in for the Ninject 2.0 extension.
DynamicProxy2:
IKernel kernel = new StandardKernel(new DynamicProxy2Module());
LinFu:
IKernel kernel = new StandardKernel(new LinFuModule());
Note: Breaking Change!!!
InterceptionModule is now abstract. The proxy specific modules need to be [...]

Read the full article →

Long time of Silence

January 18, 2010

It has been quite a while since I last blogged. In usual style, it has been for a reason seen over and over. I changed jobs.
I have started my own software company doing contract .NET development as well as partnering with IntelliTechture. It has been very hectic switching from employee to business owner and great [...]

Read the full article →

Ninject available via Horn

September 27, 2009

You can now build Ninject for both the 1.X and 2.0 code bases with Horn now. I would like to thank the Horn developers and mailing list for answering my questions and lending a hand.
If you haven’t heard of Horn, you should definitely check it out. Taking Horn for a test drive is a great [...]

Read the full article →

Mono Tools for Visual Studio

September 26, 2009

I have been waiting for this for a long time. There is a private preview for tools that will allow you to write .NET apps and port your code at the same time. It looks like they integrated the compatibility analyzer, remote Linux debugger, packaging system and local mono debugging into Visual Studio. It is [...]

Read the full article →

Conventions based binding with Ninject 2.0

September 24, 2009

Conventions binding is implemented through extension methods on the IKernel interface. In order to use these extensions, first download or compile a release of the Ninject.Extensions.Conventions project. Once the library is referenced, type:
using Ninject.Extensions.Conventions;
into the source file you are using to configure your Ninject kernel. This will add two additional methods to the IKernel interface:
void [...]

Read the full article →

Why are there so many extensions in Ninject 2.0?

September 24, 2009

We really wanted to Ninject 2.0 as small as possible. Ninject 1.X was a huge (to us); a monolithic kernel that could do anything. While it was nice to be able to do anything, it came at the cost of file size, memory footprint, complexity, and more. It also presented challenges for extension authors as [...]

Read the full article →

Ninject 1.X has a new home

September 24, 2009

The Ninject 1.X repository has been migrated to GitHub; However, this version is only receiving critical bug fixes, all new development is being done on the Ninject 2.0 codebase. We will be releasing 1.5 pretty soon, so if you need to use Ninject 1.X for compatibility, keep an ear open.

Read the full article →

Extensions for Ninject 2.0

September 24, 2009

We have been hard at work trying to get Ninject 2.0 released. Integral to the release is a set of extensions to help you build your application. Here is a list of of current extensions for Ninject 2.0 that we have hosted on GitHub:
Ninject.Extensions.Conventions: Assembly scanning and convention based binding system. Ninject.Dynamic: Support for module [...]

Read the full article →

Weak Proxy Factory

August 17, 2009

In the previous article I showed how one could construct a weak proxy object using LinFu. This idea very slick, but it doesn’t do us much good unless there is something built around it.
DISCLAIMER: Blocks of this code are taken directly from the Ninject 2.0 source base and re-purposed. All code in this article is [...]

Read the full article →

Weak Proxies

July 27, 2009

I wanted my proxy factory to hand out instances, but clean up the instance as soon as the caller no longer needs the service. I also didn’t want the caller running the cleanup code. This allows me to pool proxy instances and clean them up as I see fit.
There is an inherent issue with this [...]

Read the full article →

Dependency Injection & Inversion of Control Presentation

July 2, 2009

Wednesday, July 15, 2009 at 6:00 PM
This session will cover Dependency Injection (DI) and Inversion of Control (IoC) and their relationship to SOLID design principles, techniques, and side effects in statically typed languages. In addition, IoC containers, how they work, their usages, patterns, and role as building blocks for loosely coupled applications will be explored.

Read the full article →

Running an elevated child process

June 30, 2009

If you ever need to run a child process in an elevated state, you can easily set the Verbs property on the ProcessStartInformation to “runas” and the child process will ask for permission when started. You need to watch out the the user denying access however as a Win32Exception will be thrown with its NativeErrorCode [...]

Read the full article →

More on delay loading .Net assemblies

June 27, 2009

You can build off of the previous article and make dealing with the dual libraries much easier using an IoC container. Instead of building an interface that constantly has to check which code path to execute based on the current platform, you can load the services into an IoC container. Once you know what platform [...]

Read the full article →

Delay loading .Net assemblies

June 27, 2009

I had to figure out how to make an application run as its native type while loading only the proper dlls for that platform – when the application runs on x64, load only x64 assemblies so that the application will run fully as x64 and the same for x86. The answer is counterintuitive and not [...]

Read the full article →

Ruby First Impressions

December 28, 2008

I decided to try out Ruby today. I have wanted to try it out for quite a while. Some of my impressions may be inaccurate, but I have done what I can. I have Zero interest in DB and web ‘programming’ so I am going to skip rails and related material.
Edit
I intially tried to use [...]

Read the full article →