예제 #1
0
        public static String FromListKeyed(
            IList <String> keys, IList <Object> values, Boolean ignoreNull = false, IFormatProvider formatProvider = null,
            String listFormat = "{0}", String itemFormat = "{0} = {1}", String separator = ", ",
            String nullString = StringGenerator.DefaultNullString
            )
        {
            if (keys.Count != values.Count)
            {
                throw new ArgumentException();
            }

            var list = new Dictionary <String, Object>(keys.Count);

            for (Int32 i = 0; i < keys.Count; i++)
            {
                list.Add(keys[i], values[i]);
            }

            return(StringGenerator.FromListKeyed(
                       list, ignoreNull, formatProvider, listFormat, itemFormat, separator, nullString));
        }
예제 #2
0
        public static String FromList(
            IList list, Boolean ignoreNull = false, IFormatProvider formatProvider = null,
            String listFormat = "{0}", String itemFormat = "{0}", String separator = ", ",
            String nullString = StringGenerator.DefaultNullString
            )
        {
            if (list == null)
            {
                throw new ArgumentNullException();
            }
            if (listFormat == null)
            {
                throw new ArgumentNullException();
            }
            if (itemFormat == null)
            {
                throw new ArgumentNullException();
            }
            if (separator == null)
            {
                throw new ArgumentNullException();
            }
            if (nullString == null)
            {
                throw new ArgumentNullException();
            }

            IList <Object> genList = new List <Object>(list.Count);

            foreach (Object item in list)
            {
                genList.Add(item);
            }

            return(StringGenerator.FromList(genList, ignoreNull, formatProvider, listFormat, itemFormat, separator, nullString));
        }