public void Run() { var factory = new SampleObjectFactory(); var manipulator = new SampleObjectManipulator(); var obj = (factory as ISampleObjectFactory).CreateEmpty(); (manipulator as ISampleObjectManipulator).WriteIntoLogs(obj); }
/// <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); }