コード例 #1
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);
            }