示例#1
0
        public bool Register(Type svcType, ObjectCreatorCallback callback, Scope scope = Scope.Singleton)
        {
            Guard.ThrowIfNull("svcType", svcType);
            Guard.ThrowIfNull("callback", callback);

            if (FindRegistration(svcType) == null)
            {
                var svcReg = CreateServiceRegistration(svcType, null, callback, scope);

                _registrations.Add(svcType, svcReg);

                return(true);
            }

            return(false);
        }
示例#2
0
 public bool Register <T>(ObjectCreatorCallback callback, Scope scope = Scope.Singleton)
 {
     return(Register(typeof(T), callback, scope));
 }
示例#3
0
 private ServiceRegistration CreateServiceRegistration(Type svcType, object instance, ObjectCreatorCallback callback, Scope scope)
 {
     return(new ServiceRegistration()
     {
         ServiceType = svcType,
         Instance = instance,
         Callback = callback,
         Scope = scope,
     });
 }