public object Convert(IConversionRequest request)
            {
                var stringValue = request.Text;
                if (stringValue.ToUpper() == StringConverterStrategy.EMPTY)
                {
                    return Array.CreateInstance(_innerType, 0);
                }

                var strings = stringValue.ToDelimitedArray();
                var array = Array.CreateInstance(_innerType, strings.Length);

                for (var i = 0; i < strings.Length; i++)
                {
                    var value = _inner.Convert(request.AnotherRequest(strings[i]));
                    array.SetValue(value, i);
                }

                return array;
            }
Esempio n. 2
0
            public object Convert(IConversionRequest request)
            {
                var stringValue = request.Text;

                if (stringValue.ToUpper() == StringConverterStrategy.EMPTY || stringValue.Trim().IsEmpty())
                {
                    return(Array.CreateInstance(_innerType, 0));
                }

                var strings = stringValue.ToDelimitedArray();
                var array   = Array.CreateInstance(_innerType, strings.Length);

                for (var i = 0; i < strings.Length; i++)
                {
                    var value = _inner.Convert(request.AnotherRequest(strings[i]));
                    array.SetValue(value, i);
                }

                return(array);
            }
            public object Convert(IConversionRequest request)
            {
                var stringValue = request.Text;
                if (stringValue.ToUpper() == StringConverterStrategy.EMPTY || stringValue.Trim().IsEmpty())
                {
                    return Array.CreateInstance(_innerType, 0);
                }

                var csvTokenizer = new CsvTokenizer();
                csvTokenizer.Read(stringValue);
                var tokens = csvTokenizer.Tokens.Select(t=>t.Trim()).ToList();

                var array = Array.CreateInstance(_innerType, tokens.Count);

                for (var i = 0; i < tokens.Count; i++)
                {
                    var value = _inner.Convert(request.AnotherRequest(tokens[i]));
                    array.SetValue(value, i);
                }

                return array;
            }
Esempio n. 4
0
            public object Convert(IConversionRequest request)
            {
                var stringValue = request.Text;

                if (stringValue.ToUpper() == StringConverterStrategy.EMPTY || stringValue.Trim().IsEmpty())
                {
                    return(Array.CreateInstance(_innerType, 0));
                }

                var csvTokenizer = new CsvTokenizer();

                csvTokenizer.Read(stringValue);
                var tokens = csvTokenizer.Tokens.Select(t => t.Trim()).ToList();

                var array = Array.CreateInstance(_innerType, tokens.Count);

                for (var i = 0; i < tokens.Count; i++)
                {
                    var value = _inner.Convert(request.AnotherRequest(tokens[i]));
                    array.SetValue(value, i);
                }

                return(array);
            }