コード例 #1
0
        public static void RegisterSingleton <TFrom, TTo>(this ISingletonTypeResolverContainer container,
                                                          params object[] options)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            container.RegisterType(typeof(TFrom), new TypeResolverLazy <TTo>(), options);
        }
コード例 #2
0
        public static SingletonBuilder RegisterSingleton(this ISingletonTypeResolverContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }
            var singleton = new SingletonBuilder(container);

            return(singleton);
        }
コード例 #3
0
        public static void RegisterSingleton <T>(this ISingletonTypeResolverContainer container,
                                                 T instance, params object[] options)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }
            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }

            container.RegisterType(typeof(T), instance, options);
        }
コード例 #4
0
        public static void RegisterSingleton(this ISingletonTypeResolverContainer container,
                                             Type from, Type to, params object[] options)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }
            if (from == null)
            {
                throw new ArgumentNullException(nameof(from));
            }
            if (to == null)
            {
                throw new ArgumentNullException(nameof(to));
            }

            container.RegisterType(from, new TypeResolverLazy(to), options);
        }
コード例 #5
0
 public SingletonBuilder(ISingletonTypeResolverContainer container)
 {
     Container = container;
 }