Ejemplo n.º 1
0
        private void AddOrCreateMappers(INamespaceSymbol symbol, ElementSide side, int setIndex = 0)
        {
            if (symbol == null)
            {
                return;
            }

            AddOrCreateMappers(symbol.GetTypeMembers(), side, setIndex);
        }
Ejemplo n.º 2
0
        internal T GetElement(ElementSide side, int setIndex)
        {
            if (side == ElementSide.Left)
            {
                return(Left);
            }

            return(Right[setIndex]);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds an element to the mapping given the <paramref name="side"/> and the <paramref name="setIndex"/>.
        /// </summary>
        /// <param name="element">The element to add to the mapping.</param>
        /// <param name="side">Value representing the side of the mapping.</param>
        /// <param name="setIndex">Value representing the index the element is added. Only used when adding to <see cref="ElementSide.Right"/>.</param>
        public virtual void AddElement(T element, ElementSide side, int setIndex)
        {
            if (side == ElementSide.Left)
            {
                Left = element;
            }
            else
            {
                if ((uint)setIndex >= Right.Length)
                {
                    throw new ArgumentOutOfRangeException(nameof(setIndex), Resources.IndexShouldBeWithinSetSizeRange);
                }

                Right[setIndex] = element;
            }
        }
Ejemplo n.º 4
0
        private void AddOrCreateMappers(IEnumerable <ITypeSymbol> types, ElementSide side, int setIndex)
        {
            if (types == null)
            {
                return;
            }

            foreach (ITypeSymbol type in types)
            {
                if (Settings.Filter.Include(type))
                {
                    if (!_types.TryGetValue(type, out TypeMapper mapper))
                    {
                        mapper = new TypeMapper(Settings, null, Right.Length);
                        _types.Add(type, mapper);
                    }

                    mapper.AddElement(type, side, setIndex);
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds forwarded types to the mapper to the index specified in the mapper.
 /// </summary>
 /// <param name="forwardedTypes">List containing the <see cref="INamedTypeSymbol"/> that represents the forwarded types.</param>
 /// <param name="side">Side to add the forwarded types into, 0 (Left) or 1 (Right).</param>
 /// <param name="setIndex">Value representing the index on the set of elements corresponding to the compared side.</param>
 public void AddForwardedTypes(IEnumerable <INamedTypeSymbol> forwardedTypes, ElementSide side, int setIndex)
 {
     EnsureTypesInitialized();
     AddOrCreateMappers(forwardedTypes, side, setIndex);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds an element to the given <paramref name="side"/> using the index 0 for <see cref="ElementSide.Right"/>.
 /// </summary>
 /// <param name="element">The element to add.</param>
 /// <param name="side">Value representing the side of the mapping. </param>
 public virtual void AddElement(T element, ElementSide side) => AddElement(element, side, 0);