/// <summary>
        /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// typeconverter.ConvertTo&lt;int&gt;(value);
        /// </example>
        /// </summary>
        public static T ConvertTo <T>(this SelectionRangeConverter typeconverter, Object value)
        {
            if (typeconverter == null)
            {
                throw new ArgumentNullException("typeconverter");
            }

            return((T)typeconverter.ConvertTo(value, typeof(T)));
        }
        /// <summary>
        /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// selectionrangeconverter.ConvertTo&lt;int&gt;(context, culture, value);
        /// </example>
        /// </summary>
        public static T ConvertTo <T>(this SelectionRangeConverter selectionrangeconverter, System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, Object value)
        {
            if (selectionrangeconverter == null)
            {
                throw new ArgumentNullException("selectionrangeconverter");
            }

            return((T)selectionrangeconverter.ConvertTo(context, culture, value, typeof(T)));
        }
Ejemplo n.º 3
0
        public void TestSelectionRangeConverter()
        {
            SelectionRangeConverter conv;
            SelectionRange          sel;
            DateTime start;
            DateTime end;

            start = new DateTime(1969, 2, 1, 18, 0, 0, 0);
            end   = new DateTime(1977, 5, 27, 0, 0, 0, 0);

            conv = new SelectionRangeConverter();
            sel  = new SelectionRange(start, end);

            CheckConvert(1, 1, conv, typeof(SelectionRange));
            CheckConversion(sel, "1969-02-01, 1977-05-27", conv, typeof(string), CultureInfo.InvariantCulture);
            CheckConversion(sel, "01.02.1969; 27.05.1977", conv, typeof(string), CultureInfo.CreateSpecificCulture("de-de"));
        }