Example #1
0
        private static void Define <T>(Factory factory, Func <T> buildCallback, string key)
        {
            if (namedBuilders.ContainsKey(key))
            {
                Console.WriteLine($"WARNING: [Application] {key} is already registered. You can only register one factory per type/name.");
                return;
            }

            namedBuilders[key] = new FactoryBuilder
            {
                Factory       = factory,
                BuildCallback = () => buildCallback()
            };
        }
Example #2
0
        private static void Define <T>(Factory factory, Func <T> buildCallback, string key)
        {
            if (namedBuilders.ContainsKey(key))
            {
                OutputWarning($"{key} is already registered. You can only register one factory per type/name.");
                return;
            }

            namedBuilders[key] = new FactoryBuilder
            {
                Factory       = factory,
                BuildCallback = () => buildCallback()
            };
        }
Example #3
0
        private static void Define <T>(Factory factory, Func <List <string>, T> buildCallback, List <string> names)
        {
            var key = string.Join(NAME_DELIMITER, names.OrderBy(e => e));

            if (namedBuilders.ContainsKey(key))
            {
                Console.WriteLine($"WARNING: [Application] {key} is already registered. You can only register one factory per type/name.");
                return;
            }

            namedBuilders[key] = new FactoryBuilder
            {
                Factory       = factory,
                BuildCallback = () => buildCallback(names)
            };
        }