Esempio n. 1
0
        /// <summary>
        /// Parse - returns an instance converted from the provided string using 
        /// the culture "en-US" 
        /// <param name="source"> string with Point4D data </param>
        /// </summary> 
        public static Point4D Parse(string source)
        {
            IFormatProvider formatProvider = System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS;
 
            TokenizerHelper th = new TokenizerHelper(source, formatProvider);
 
            Point4D value; 

            String firstToken = th.NextTokenRequired(); 

            value = new Point4D(
                Convert.ToDouble(firstToken, formatProvider),
                Convert.ToDouble(th.NextTokenRequired(), formatProvider), 
                Convert.ToDouble(th.NextTokenRequired(), formatProvider),
                Convert.ToDouble(th.NextTokenRequired(), formatProvider)); 
 
            // There should be no more tokens in this string.
            th.LastTokenRequired(); 

            return value;
        }
Esempio n. 2
0
        /// <summary>
        /// Parse - returns an instance converted from the provided string using 
        /// the culture "en-US"
        /// <param name="source"> string with Int32Rect data </param>
        /// </summary>
        public static Int32Rect Parse(string source) 
        {
            IFormatProvider formatProvider = System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS; 
 
            TokenizerHelper th = new TokenizerHelper(source, formatProvider);
 
            Int32Rect value;

            String firstToken = th.NextTokenRequired();
 
            // The token will already have had whitespace trimmed so we can do a
            // simple string compare. 
            if (firstToken == "Empty") 
            {
                value = Empty; 
            }
            else
            {
                value = new Int32Rect( 
                    Convert.ToInt32(firstToken, formatProvider),
                    Convert.ToInt32(th.NextTokenRequired(), formatProvider), 
                    Convert.ToInt32(th.NextTokenRequired(), formatProvider), 
                    Convert.ToInt32(th.NextTokenRequired(), formatProvider));
            } 

            // There should be no more tokens in this string.
            th.LastTokenRequired();
 
            return value;
        }