Exemplo n.º 1
0
        public static IVCFileWrapper create(object wrapped)
        {
            if (modules == null)
            {
                modules = new Queue <IFactoryModule>();

                // One of these modules will be working for each version of Visual Studio.
                modules.Enqueue(new FactoryModule2017());
                modules.Enqueue(new FactoryModule2015());
                modules.Enqueue(new FactoryModule2013());
                modules.Enqueue(new FactoryModule2012());
            }

            IVCFileWrapper wrapper           = null;
            int            testedModuleCount = 0;

            while (wrapper == null && testedModuleCount < modules.Count)
            {
                try
                {
                    wrapper = modules.Peek().Create(wrapped);
                }
                catch (Exception)
                {
                    wrapper = null;
                }

                testedModuleCount++;

                if (wrapper == null || !wrapper.isValid())
                {
                    // Moving the failing module to the end of the queue.
                    // This causes the working module to finall end up in front.
                    IFactoryModule failedModule = modules.Dequeue();
                    Logging.LogInfo("Discarcing " + failedModule.GetType().Name + " while creating file wrapper.");
                    modules.Enqueue(failedModule);
                    wrapper = null;
                }
            }

            return(wrapper);
        }
Exemplo n.º 2
0
 public DataModule(UMSContext context, IFactoryModule factory)
 {
     _context = context;
     _factory = factory;
 }