Ejemplo n.º 1
0
        public ISynchronizer FindSynchronizerByType(Type type)
        {
            if (_factoriesByType.TryGetValue(type, out ISynchronizer factory) == false)
            {
                // Factories are looped in reverse because the last added Factory should be prioritized.
                for (var i = _syncSourceObjectFactories.Count - 1; i >= 0; i--)
                {
                    ISynchronizer syncSourceObjectFactory = _syncSourceObjectFactories[i];
                    if (syncSourceObjectFactory.CanSynchronize(type))
                    {
                        factory = syncSourceObjectFactory;
                        _factoriesByType.Add(type, syncSourceObjectFactory);
                        return(factory);
                    }
                }

                throw new SynchronizerNotFoundException(type);
            }
            return(factory);
        }