コード例 #1
0
        private static void RegisterBase(this IRegisterableLake lake, string id, ComponentFactory factory)
        {
            if (lake is null)
            {
                throw new ArgumentNullException(nameof(lake));
            }

            if (id is null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (factory is null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            lake.RegisterComponent(id, factory);
        }
コード例 #2
0
        private static void RegisterSingletonBase(this IRegisterableLake lake, string id, ComponentFactory factory)
        {
            if (lake is null)
            {
                throw new ArgumentNullException(nameof(lake));
            }

            if (id is null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (factory is null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            var lazy = new Lazy <object?>(() => factory());

            lake.RegisterComponent(id, () => lazy.Value);
        }