private bool IsUnwrappingNeeded(ITypeSymbol targetType, MappingElement element) { return(targetType != element.ExpressionType && ObjectHelper.IsSimpleType(targetType)); }
protected virtual bool ShouldCreateConversionBetweenTypes(ITypeSymbol targetType, ITypeSymbol sourceType) { return((sourceType.Equals(targetType) == false) && ObjectHelper.IsSimpleType(targetType) == false && ObjectHelper.IsSimpleType(sourceType) == false); }
private bool IsUnwrappingNeeded(ITypeSymbol targetType, MappingElement element) { return(targetType.Equals(element.ExpressionType) == false && (ObjectHelper.IsSimpleType(targetType) || SymbolHelper.IsNullable(targetType, out _))); }
public static bool IsCollection(ITypeSymbol typeSymbol) { return(ObjectHelper.HasInterface(typeSymbol, "System.Collections.ICollection") || ObjectHelper.HasInterface(typeSymbol, "System.Collections.IEnumerable") || typeSymbol.Kind == SymbolKind.ArrayType); }
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); }