public void Install(Container container) { container.Register(typeof(IAnnunciator), typeof(LedStripAnnunciator)).AsSingleton(); container.Register(typeof(IDisplay), typeof(DisplayTE35)).AsSingleton(); container.Register(typeof(IWirelessNetworking), typeof(WifiRS21)).AsSingleton(); //container.Register(typeof(IPeerChannel), typeof(PeerChannel)).AsSingleton(); //container.Register(typeof(IFileSystem), typeof(FlashFileSystem)).AsSingleton(); }
public void Install(Container container) { //container.Register(typeof(IDisplay), typeof(Sharp128)).AsSingleton(); //container.Register(typeof(IFileSystem), typeof(FlashFileSystem)).AsSingleton(); }
static DiContainer() { _instance = new Container(); }
public void Install(Container container) { //container.Register(typeof(IPeerChannel), typeof(PeerChannel)).AsSingleton(); //container.Register(typeof(IFileSystem), typeof(FlashFileSystem)).AsSingleton(); }
internal Component(Container container, string name, Type type) { resolvers = new ArrayList(); this.container = container; this.name = name; Func func = () => { var parameters = new ArrayList(); var parameterTypes = new ArrayList(); foreach (Func resolver in resolvers) { var value = resolver(); parameters.Add(value); parameterTypes.Add(value.GetType()); } var constructor = type.GetConstructor((Type[])parameterTypes.ToArray(typeof(Type))); if (constructor == null) { throw new InvalidOperationException("Constructor matching the dependency chain for component '" + name + "' with type '" + type.FullName + "' could not be found."); } return constructor.Invoke(parameters.ToArray()); }; container.services[name] = func; }