Exemplo n.º 1
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value == null)
            {
                return(new SortExpressionCollection());
            }
            string str = value as string;

            if (str == null)
            {
                return(base.ConvertFrom(context, culture, value));
            }
            if (str.Length < 1)
            {
                return(new SortExpressionCollection());
            }
            string[] strArrays = str.Split(new char[] { ';' });
            if ((int)strArrays.Length < 1)
            {
                return(new SortExpressionCollection());
            }
            SortExpressionCollection sortExpressionCollection = new SortExpressionCollection();
            TypeConverter            converter = TypeDescriptor.GetConverter(typeof(SortExpression));

            string[] strArrays1 = strArrays;
            for (int i = 0; i < (int)strArrays1.Length; i++)
            {
                SortExpression sortExpression = converter.ConvertFrom(strArrays1[i]) as SortExpression;
                if (sortExpression != null)
                {
                    sortExpressionCollection.Add(sortExpression);
                }
            }
            return(sortExpressionCollection);
        }