public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value == null) { return(new SortExpressionCollection()); } if (!(value is string str)) { return(base.ConvertFrom(context, culture, value)); } if (str.Length < 1) { return(new SortExpressionCollection()); } string[] strArrays = str.Split(';'); if (strArrays.Length < 1) { return(new SortExpressionCollection()); } SortExpressionCollection sortExpressionCollection = new SortExpressionCollection(); TypeConverter converter = TypeDescriptor.GetConverter(typeof(SortExpression)); string[] strArrays1 = strArrays; for (int i = 0; i < strArrays1.Length; i++) { if (converter.ConvertFrom(strArrays1[i]) is SortExpression sortExpression) { sortExpressionCollection.Add(sortExpression); } } return(sortExpressionCollection); }
public static string Serialize(SortExpressionCollection collection) { return((string)TypeDescriptor.GetConverter(typeof(SortExpressionCollection)).ConvertTo(collection, typeof(string))); }