Skip to content

casualjim/ninject-dynamic

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository contains the ruby branch of Ninject.
The aim is to integrate the DLR as nicely as possible in a DI container.

If you're using Resharper for running unit tests you'll have to uncheck the box next to
Shadow-copies being tested in the unit testing section of the resharper options.

example:
to_configure_ninject do |ninject|
  ninject.bind IServiceA, :to => ServiceA, :as => :singleton, :meta => { :type => "superservice" }, :name => "aaaaa"
end

The typical use case would probably look like this:
to_configure_ninject do |ninject|
  ninject.bind IServiceA, :to => ServiceA, :as => :transient
  ninject.bind ISingletonService, :to => SingletonServiceImpl
end

All the configuration options:

to_configure_ninject do |ninject|
  ninject.bind IServiceA, :to => ServiceA, :as => :singleton,
    :meta => { :type => "superservice" },
    :name => "aaaaa",
    :parameter => { :my_param => lambda { |context| "param_value" } },
    :constructor_arguments => {:const_arg => 56 },
    :property_values => {:property_name => 94 },
    :on_activation => lambda { |obj| obj.do_some_work },
    :on_deativated => lambda { |obj| obj.do_some_cleanup },
    :when => {
      :provider => lambda { |context| "a value" },
      :injected_into => ServiceB,
      :target_has => AnAttribute,
      :member_has => AnAttribute,
      :class_has => AnAttribute
    }
end

Happy playing :)

About

A DLR integration for Ninject

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published