Skip to content

ricardotealdi/SimplInject

Repository files navigation

SimplInject

A simple dependency injection for .NET that uses Ninject on background

Usage

Registering by Hand

SimplInjectRepository.RegisterType(typeof(IInterface), typeof(Concretelass));

or

SimplInjectRepository.RegisterType<IInterface, Concretelass>();

Registering all SimplInjectAttribute types from an assembly

Adding SimplInjectAttribute into your injectable class

[SimplInject]
public class ConcreteClass : IAmAnInterface {}

That attribute will make the class to be resolved by its interface.

Loading assembly and registering types

SimplInjectRepository.InjectTypesFrom("Your.Assembly.Name.To.Be.Loaded");

Resolving a type

var myInstance = SimplInjectRepository.Get<ClassWithDependeciesResolved>();

Using with a newer Ninject version

You can try using assembly binding redirection on your app.config

<runtime>
	<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
		<dependentAssembly>
		<assemblyIdentity name="Ninject"
							publicKeyToken="c7192dc5380945e7"
							culture="neutral" />
		<bindingRedirect oldVersion="2.2.0.0"
							newVersion="{newer-version}"/>
		</dependentAssembly>
	</assemblyBinding>
</runtime>

About

A simple and useful dependency injection framework for .NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages