/// <summary> /// Parse - returns an instance converted from the provided string using /// the culture "en-US" /// <param name="source"> string with Matrix data </param> /// </summary> public static Matrix Parse(string source) { IFormatProvider formatProvider = System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS; TokenizerHelper th = new TokenizerHelper(source, formatProvider); Matrix value; String firstToken = th.NextTokenRequired(); // The token will already have had whitespace trimmed so we can do a // simple string compare. if (firstToken == "Identity") { value = Identity; } else { value = new Matrix( Convert.ToDouble(firstToken, formatProvider), Convert.ToDouble(th.NextTokenRequired(), formatProvider), Convert.ToDouble(th.NextTokenRequired(), 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); }
public static XVector Parse(string source) { TokenizerHelper helper = new TokenizerHelper(source, CultureInfo.InvariantCulture); string str = helper.NextTokenRequired(); XVector vector = new XVector(Convert.ToDouble(str, CultureInfo.InvariantCulture), Convert.ToDouble(helper.NextTokenRequired(), CultureInfo.InvariantCulture)); helper.LastTokenRequired(); return(vector); }
public static Vector3D Parse(string source) { IFormatProvider cultureInfo = CultureInfo.InvariantCulture; TokenizerHelper helper = new TokenizerHelper(source, cultureInfo); string str = helper.NextTokenRequired(); Vector3D vectord = new Vector3D(Convert.ToSingle(str, cultureInfo), Convert.ToSingle(helper.NextTokenRequired(), cultureInfo), Convert.ToSingle(helper.NextTokenRequired(), cultureInfo)); helper.LastTokenRequired(); return(vectord); }
/// <summary> /// Parses the point from a string. /// </summary> public static XPoint Parse(string source) { CultureInfo cultureInfo = CultureInfo.InvariantCulture; TokenizerHelper helper = new TokenizerHelper(source, cultureInfo); string str = helper.NextTokenRequired(); XPoint point = new XPoint(Convert.ToDouble(str, cultureInfo), Convert.ToDouble(helper.NextTokenRequired(), cultureInfo)); helper.LastTokenRequired(); return(point); }
/// <summary>Creates an <see cref="T:System.Windows.Int32Rect" /> structure from the specified <see cref="T:System.String" /> representation.</summary> /// <returns>The equivalent <see cref="T:System.Windows.Int32Rect" /> structure.</returns> /// <param name="source">A string representation of an <see cref="T:System.Windows.Int32Rect" />.</param> public static Int32Rect Parse(string source) { IFormatProvider invariantEnglishUS = TypeConverterHelper.InvariantEnglishUS; TokenizerHelper tokenizerHelper = new TokenizerHelper(source, invariantEnglishUS); string text = tokenizerHelper.NextTokenRequired(); Int32Rect result = (text == "Empty") ? Empty : new Int32Rect(Convert.ToInt32(text, invariantEnglishUS), Convert.ToInt32(tokenizerHelper.NextTokenRequired(), invariantEnglishUS), Convert.ToInt32(tokenizerHelper.NextTokenRequired(), invariantEnglishUS), Convert.ToInt32(tokenizerHelper.NextTokenRequired(), invariantEnglishUS)); tokenizerHelper.LastTokenRequired(); return(result); }
public static Point4D Parse(string source) { IFormatProvider cultureInfo = CultureInfo.InvariantCulture; TokenizerHelper helper = new TokenizerHelper(source, cultureInfo); string str = helper.NextTokenRequired(); Point4D pointd = new Point4D(Convert.ToSingle(str, cultureInfo), Convert.ToSingle(helper.NextTokenRequired(), cultureInfo), Convert.ToSingle(helper.NextTokenRequired(), cultureInfo), Convert.ToSingle(helper.NextTokenRequired(), cultureInfo)); helper.LastTokenRequired(); return(pointd); }
/// <summary> /// Parses the rectangle from a string. /// </summary> public static XRect Parse(string source) { XRect empty; CultureInfo cultureInfo = CultureInfo.InvariantCulture; TokenizerHelper helper = new TokenizerHelper(source, cultureInfo); string str = helper.NextTokenRequired(); empty = str == "Empty" ? Empty : new XRect(Convert.ToDouble(str, cultureInfo), Convert.ToDouble(helper.NextTokenRequired(), cultureInfo), Convert.ToDouble(helper.NextTokenRequired(), cultureInfo), Convert.ToDouble(helper.NextTokenRequired(), cultureInfo)); helper.LastTokenRequired(); return(empty); }
/// <summary> /// Parses the size from a string. /// </summary> public static XSize Parse(string source) { XSize empty; CultureInfo cultureInfo = CultureInfo.InvariantCulture; TokenizerHelper helper = new TokenizerHelper(source, cultureInfo); string str = helper.NextTokenRequired(); if (str == "Empty") { empty = Empty; } else { empty = new XSize(Convert.ToDouble(str, cultureInfo), Convert.ToDouble(helper.NextTokenRequired(), cultureInfo)); } helper.LastTokenRequired(); return(empty); }
/// <summary> /// Parse - returns an instance converted from the provided string using /// the culture "en-US" /// <param name="source"> string with Vector data </param> /// </summary> public static Vector Parse(string source) { IFormatProvider formatProvider = System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS; TokenizerHelper th = new TokenizerHelper(source, formatProvider); Vector value; String firstToken = th.NextTokenRequired(); value = new Vector( Convert.ToDouble(firstToken, formatProvider), Convert.ToDouble(th.NextTokenRequired(), formatProvider)); // There should be no more tokens in this string. th.LastTokenRequired(); return(value); }