41 return SpritString(s,
',',
new char[] {
' ',
'(',
'[',
'<',
')',
']',
'>' });
43 private static string[]
SpritString(
string s,
char divider,
char[] toremove)
45 StringBuilder builder =
new StringBuilder(s);
46 foreach (
char r
in toremove)
48 builder.Replace(r,
' ');
50#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT
51 return builder.ToString().Split(
new char[] { divider,
' ' }, StringSplitOptions.RemoveEmptyEntries);
53 string[] temp = s.Split(
new char[] { divider,
' ' });
55 for (
int index1 = 0; index1 < temp.Length; ++index1)
57 if (temp[index1].Length > 0)
59 temp[index2++] = temp[index1];
62 string[] vals =
new string[index2];
63 Array.Copy(temp, vals, vals.Length);
67 private static string[]
SpritString(
string s,
char divider,
string[] toremove)
69 StringBuilder builder =
new StringBuilder(s);
70 foreach (
string r
in toremove)
72 builder.Replace(r,
" ");
74#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT
75 return builder.ToString().Split(
new char[] { divider,
' ' }, StringSplitOptions.RemoveEmptyEntries);
77 string[] temp = s.Split(
new char[] { divider,
' ' });
79 for (
int index1 = 0; index1 < temp.Length; ++index1)
81 if (temp[index1].Length > 0)
83 temp[index2++] = temp[index1];
86 string[] vals =
new string[index2];
87 Array.Copy(temp, vals, vals.Length);
96 Parse(s, ref valueType,
"|\n",
"|",
' ');
98 public static void Parse<T>(
string s, ref T valueType,
string leftParenth,
string rightParenth,
char divider)
103 throw new ArgumentNullException(
"s");
105 string[] parts =
SpritString(s, divider,
new string[] { leftParenth, rightParenth });
106 if (parts.Length != valueType.Count)
108 throw new FormatException(
109 string.Format(
"Cannot parse the text '{0}' because it does not have {1} parts.",
110 s, valueType.Count));
113 for (
int index = 0; index < valueType.Count; ++index)
115 result[index] =
Scalar.Parse(parts[index]);
117 valueType.CopyFrom(result, 0);
119#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT
123 return TryParse(s, ref valueType,
"|",
"|\n",
' ');
125 public static bool TryParse<T>(
string s, ref T valueType,
string leftParenth,
string rightParenth,
char divider)
132 string[] parts =
SpritString(s, divider,
new string[] { leftParenth, rightParenth });
133 if (parts.Length != valueType.Count)
138 for (
int index = 0; index < valueType.Count; ++index)
140 if (!
Scalar.TryParse(parts[index], out result[index]))
145 valueType.CopyFrom(result, 0);
static void Parse< T >(string s, ref T valueType, string leftParenth, string rightParenth, char divider)
static bool TryParseMatrix< T >(string s, ref T valueType)
static string[] SplitStringVector(string s)
static void ParseMatrix< T >(string s, ref T valueType)
static string[] SpritString(string s, char divider, char[] toremove)
static string[] SpritString(string s, char divider, string[] toremove)
static bool TryParse< T >(string s, ref T valueType, string leftParenth, string rightParenth, char divider)