public static StringCollection ParseStringCollection <TS>(string value) where TS : ITypeSerializer
 {
     if ((value = DeserializeListWithElements <TS> .StripList(value)) == null)
     {
         return(null);
     }
     return(value == String.Empty
                        ? new StringCollection()
                        : ToStringCollection(DeserializeListWithElements <TSerializer> .ParseStringList(value)));
 }
        public static ParseStringDelegate GetParseFn()
        {
            var enumerableInterface = typeof(T).GetTypeWithGenericInterfaceOf(typeof(IEnumerable <>));

            if (enumerableInterface == null)
            {
                throw new ArgumentException(string.Format("Type {0} is not of type IEnumerable<>", typeof(T).FullName));
            }

            //optimized access for regularly used types
            if (typeof(T) == typeof(IEnumerable <string>))
            {
                return(DeserializeListWithElements <TSerializer> .ParseStringList);
            }

            if (typeof(T) == typeof(IEnumerable <int>))
            {
                return(DeserializeListWithElements <TSerializer> .ParseIntList);
            }

            var elementType = enumerableInterface.GetGenericArguments()[0];

            var supportedTypeParseMethod = DeserializeListWithElements <TSerializer> .Serializer.GetParseFn(elementType);

            if (supportedTypeParseMethod != null)
            {
                const Type createListTypeWithNull = null;                 //Use conversions outside this class. see: Queue

                var parseFn = DeserializeListWithElements <TSerializer> .GetListTypeParseFn(
                    createListTypeWithNull, elementType, supportedTypeParseMethod);

                return(value => parseFn(value, createListTypeWithNull, supportedTypeParseMethod));
            }

            return(null);
        }
        public static ParseStringDelegate GetParseFn()
        {
            var listInterface = typeof(T).GetTypeWithGenericInterfaceOf(typeof(IList <>));

            if (listInterface == null)
            {
                throw new ArgumentException(string.Format("Type {0} is not of type IList<>", typeof(T).FullName));
            }

            //optimized access for regularly used types
            if (typeof(T) == typeof(List <string>))
            {
                return(DeserializeListWithElements <TSerializer> .ParseStringList);
            }

            if (typeof(T) == typeof(List <int>))
            {
                return(DeserializeListWithElements <TSerializer> .ParseIntList);
            }

            var elementType = listInterface.GetGenericArguments()[0];

            var supportedTypeParseMethod = DeserializeListWithElements <TSerializer> .Serializer.GetParseFn(elementType);

            if (supportedTypeParseMethod != null)
            {
                var createListType = typeof(T).HasAnyTypeDefinitionsOf(typeof(List <>), typeof(IList <>))
                                        ? null : typeof(T);

                var parseFn = DeserializeListWithElements <TSerializer> .GetListTypeParseFn(createListType, elementType, supportedTypeParseMethod);

                return(value => parseFn(value, createListType, supportedTypeParseMethod));
            }

            return(null);
        }