Ejemplo n.º 1
0
 private bool IsUnwrappingNeeded(ITypeSymbol targetType, MappingElement element)
 {
     return(targetType != element.ExpressionType && ObjectHelper.IsSimpleType(targetType));
 }
Ejemplo n.º 2
0
 protected virtual bool ShouldCreateConversionBetweenTypes(ITypeSymbol targetType, ITypeSymbol sourceType)
 {
     return((sourceType.Equals(targetType) == false) && ObjectHelper.IsSimpleType(targetType) == false && ObjectHelper.IsSimpleType(sourceType) == false);
 }
Ejemplo n.º 3
0
 private bool IsUnwrappingNeeded(ITypeSymbol targetType, MappingElement element)
 {
     return(targetType.Equals(element.ExpressionType) == false && (ObjectHelper.IsSimpleType(targetType) || SymbolHelper.IsNullable(targetType, out _)));
 }
Ejemplo n.º 4
0
 public static bool IsCollection(ITypeSymbol typeSymbol)
 {
     return(ObjectHelper.HasInterface(typeSymbol, "System.Collections.ICollection") ||
            ObjectHelper.HasInterface(typeSymbol, "System.Collections.IEnumerable") ||
            typeSymbol.Kind == SymbolKind.ArrayType);
 }
Ejemplo n.º 5
0
        public MappingElement MapExpression(MappingElement element, ITypeSymbol targetType, MappingPath mappingPath = null)
        {
            if (element == null)
            {
                return(null);
            }

            if (mappingPath == null)
            {
                mappingPath = new MappingPath();
            }

            if (mappingPath.AddToMapped(element.ExpressionType) == false)
            {
                return(new MappingElement()
                {
                    ExpressionType = element.ExpressionType,
                    Expression = element.Expression.WithTrailingTrivia(SyntaxFactory.Comment(" /* Stop recursive mapping */"))
                });
            }

            if (IsUnrappingNeeded(targetType, element))
            {
                return(TryToUnwrapp(targetType, element));
            }


            if (element.ExpressionType.Equals(targetType) == false && ObjectHelper.IsSimpleType(targetType) == false && ObjectHelper.IsSimpleType(element.ExpressionType) == false)
            {
                return(TryToCreateMappingExpression(element, targetType, mappingPath));
            }

            return(element);
        }