Пример #1
0
        private bool CanMappingSubObjectProperty(ITypeSymbol sourceType, ITypeSymbol targetType, ConvertContext convertContext)
        {
            if (sourceType.IsPrimitive() || targetType.IsPrimitive())
            {
                return(false);
            }
            if (convertContext.HasWalked(targetType))
            {
                return(false);
            }
            if (targetType is INamedTypeSymbol namedTargetType)
            {
                if (sourceType.TypeKind == TypeKind.Class || sourceType.TypeKind == TypeKind.Struct)
                {
                    if (targetType.TypeKind == TypeKind.Struct)
                    {
                        return(true);
                    }
                    return(targetType.TypeKind == TypeKind.Class && !targetType.IsAbstract && namedTargetType.HasEmptyCtor());
                }
            }

            return(false);
        }