Esempio n. 1
0
        public void Run()
        {
            var factory     = new SampleObjectFactory();
            var manipulator = new SampleObjectManipulator();

            var obj = (factory as ISampleObjectFactory).CreateEmpty();

            (manipulator as ISampleObjectManipulator).WriteIntoLogs(obj);
        }
Esempio n. 2
0
        /// <summary>
        /// Создает новый или возвращает существующий экземпляр фабрики объектов <see cref="SampleObject"/>.
        /// </summary>
        public ISampleObjectFactory CreateFactory()
        {
            var factory = _instances.OfType <ISampleObjectFactory>().FirstOrDefault();

            if (factory != null)
            {
                return(factory);
            }

            factory = new SampleObjectFactory();
            _instances.Add(factory);
            return(factory);
        }