Exemplo n.º 1
0
        public IEnumerable <AssemblyMapper> GetAssemblies()
        {
            if (_assemblies == null)
            {
                _assemblies = new Dictionary <IAssemblySymbol, AssemblyMapper>(Settings.EqualityComparer);

                if (Left != null)
                {
                    AddOrCreateMappers(Left, 0);
                }

                if (Right != null)
                {
                    AddOrCreateMappers(Right, 1);
                }

                void AddOrCreateMappers(IEnumerable <IAssemblySymbol> elements, int index)
                {
                    foreach (IAssemblySymbol assembly in elements)
                    {
                        if (!_assemblies.TryGetValue(assembly, out AssemblyMapper mapper))
                        {
                            mapper = new AssemblyMapper(Settings);
                            _assemblies.Add(assembly, mapper);
                        }
                        mapper.AddElement(assembly, index);
                    }
                }
            }

            return(_assemblies.Values);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Visits the <see cref="AssemblyMapper"/> and visits each <see cref="NamespaceMapper"/> in the mapper.
        /// </summary>
        /// <param name="mapper">The <see cref="AssemblyMapper"/> to visit.</param>
        public virtual void Visit(AssemblyMapper mapper)
        {
            if (mapper == null)
            {
                throw new ArgumentNullException(nameof(mapper));
            }

            foreach (NamespaceMapper nsMapper in mapper.GetNamespaces())
            {
                Visit(nsMapper);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the assembly mappers built from the provided lists of <see cref="IAssemblySymbol"/>.
        /// <returns>The list of <see cref="AssemblyMapper"/> representing the underlying assemblies.</returns>
        public IEnumerable <AssemblyMapper> GetAssemblies()
        {
            if (_assemblies == null)
            {
                _assemblies = new Dictionary <IAssemblySymbol, AssemblyMapper>(Settings.EqualityComparer);
                AddOrCreateMappers(Left, ElementSide.Left);

                if (Right.Length == 1)
                {
                    AddOrCreateMappers(Right[0], ElementSide.Right);
                }
                else
                {
                    for (int i = 0; i < Right.Length; i++)
                    {
                        AddOrCreateMappers(Right[i], ElementSide.Right, i);
                    }
                }

                void AddOrCreateMappers(IEnumerable <IAssemblySymbol> symbols, ElementSide side, int setIndex = 0)
                {
                    if (symbols == null)
                    {
                        return;
                    }

                    foreach (IAssemblySymbol assembly in symbols)
                    {
                        if (!_assemblies.TryGetValue(assembly, out AssemblyMapper mapper))
                        {
                            mapper = new AssemblyMapper(Settings, Right.Length);
                            _assemblies.Add(assembly, mapper);
                        }

                        mapper.AddElement(assembly, side, setIndex);
                    }
                }
            }

            return(_assemblies.Values);
        }
Exemplo n.º 4
0
 public virtual void Run(AssemblyMapper mapper, List <CompatDifference> differences)
 {
 }