Beispiel #1
0
        public static void Validate <T>(this IChoLiteParser parser)
        {
            var recType = typeof(T);

            if (recType.IsNullableType())
            {
                throw new NotSupportedException($"{recType} is not supported.");
            }
            if (recType.IsSimple())
            {
                throw new NotSupportedException($"{recType} is not supported.");
            }
            if (recType != typeof(ChoDynamicObject) && recType != typeof(ExpandoObject) && (typeof(IEnumerable).IsAssignableFrom(recType) || typeof(IList).IsAssignableFrom(recType)))
            {
                throw new NotSupportedException($"{recType} is not supported.");
            }
        }
Beispiel #2
0
        public static bool IsPositionalMapping <T>(this IChoLiteParser parser)
        {
            bool flag = false;

            if (!_positionalMappingTypeCache.TryGetValue(typeof(T), out flag))
            {
                var recType = typeof(T);
                if (recType == typeof(ChoDynamicObject) || recType == typeof(ExpandoObject))
                {
                    flag = false;
                }
                else
                {
                    var pis = GetPropertyInfos <T>();
                    flag = !pis.Where(pi => ChoType.GetAttribute <DisplayNameAttribute>(pi) != null || ChoType.GetAttribute <DisplayAttribute>(pi) != null).Any();
                    _positionalMappingTypeCache.AddOrUpdate(typeof(T), flag);
                }
            }

            return(flag);
        }
Beispiel #3
0
        public static void Validate(this IChoLiteParser parser, char delimiter, string EOLDelimiter, char quoteChar)
        {
            if (delimiter == ChoCharEx.NUL)
            {
                throw new ArgumentException("Invalid delimiter passed.");
            }
            if (EOLDelimiter != null && EOLDelimiter.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Invalid EOLDelimiter passed.");
            }
            if (quoteChar == ChoCharEx.NUL)
            {
                throw new ArgumentException("Invalid Quote character passed.");
            }

            if (EOLDelimiter != null && (EOLDelimiter.Contains(delimiter) || EOLDelimiter.Contains(quoteChar)))
            {
                throw new ArgumentException("Invalid EOLDelimiter passed.");
            }
            if (delimiter == quoteChar)
            {
                throw new ArgumentException("Invalid Quote character passed.");
            }
        }