示例#1
0
 public Type GetImplementType(Type interfaceType)
 {
     if (IsRegisteredImplement(interfaceType))
     {
         return(interfaceTable[interfaceType]);
     }
     throw IOCException.NotRegisteredException(interfaceType);
 }
示例#2
0
 public object GetSingleton(Type interfaceType)
 {
     if (IsRegisteredSingleton(interfaceType))
     {
         return(singletonTable[interfaceType]);
     }
     throw IOCException.NotRegisteredException(interfaceType);
 }
示例#3
0
 public void RegisterSingleton <TInterface>(object value)
 {
     IOCException.CheckImplementedInterface <TInterface>(value.GetType());
     if (IsRegisteredSingleton <TInterface>())
     {
         singletonTable[typeof(TInterface)] = value;
         return;
     }
     singletonTable.Add(typeof(TInterface), value);
 }
示例#4
0
 public void Register <TInterface, TImplement>()
 {
     IOCException.CheckImplementedInterface <TInterface, TImplement>();
     if (IsRegisteredImplement <TInterface>())
     {
         interfaceTable[typeof(TInterface)] = typeof(TImplement);
         return;
     }
     interfaceTable.Add(typeof(TInterface), typeof(TImplement));
 }