@@ -111,23 +111,45 @@ public static IDictionary<string, string> Sectionize(string text, Regex delimite
111
111
public static IDictionary < string , IConvertible > ParseVcDelimiteredParameters ( string text )
112
112
{
113
113
IDictionary < string , IConvertible > delimitedValues = new Dictionary < string , IConvertible > ( StringComparer . OrdinalIgnoreCase ) ;
114
- string [ ] segments = text . Split ( '=' , StringSplitOptions . TrimEntries ) ;
115
- // Only start at second segment and end at second to last segment
116
- // Because first segment is the key for first pair, and last segment is the value for last pair.
117
- string key = segments [ 0 ] ;
118
- for ( int i = 1 ; i < segments . Length - 1 ; i ++ )
114
+
115
+ if ( text . Contains ( ",,," ) )
119
116
{
120
- // This is just to
121
- int lastCommaIndex = segments [ i ] . LastIndexOf ( ",,," ) ;
122
- int lastSemicolonIndex = segments [ i ] . LastIndexOf ( ';' ) ;
123
- int splitIndex = Math . Max ( lastCommaIndex , lastSemicolonIndex ) ;
124
-
125
- string value = segments [ i ] . Substring ( 0 , splitIndex ) ;
126
- delimitedValues . Add ( key , value ) ;
127
- key = segments [ i ] . Substring ( splitIndex ) . Trim ( ';' ) . Trim ( ',' ) ;
117
+ // If the list contains three comma",,,", use this as delimeter
118
+ string [ ] delimitedProperties = text . Split ( ",,," , StringSplitOptions . RemoveEmptyEntries ) ;
119
+
120
+ if ( delimitedProperties ? . Any ( ) == true )
121
+ {
122
+ foreach ( string property in delimitedProperties )
123
+ {
124
+ if ( property . Contains ( "=" , StringComparison . InvariantCultureIgnoreCase ) )
125
+ {
126
+ string key = property . Substring ( 0 , property . IndexOf ( "=" , StringComparison . Ordinal ) ) ;
127
+ string value = property . Substring ( property . IndexOf ( "=" , StringComparison . Ordinal ) + 1 ) ;
128
+ delimitedValues [ key . Trim ( ) ] = value . Trim ( ) ;
129
+ }
130
+ }
131
+ }
128
132
}
133
+ else
134
+ {
135
+ string [ ] segments = text . Split ( '=' , StringSplitOptions . TrimEntries ) ;
136
+ // Only start at second segment and end at second to last segment
137
+ // Because first segment is the key for first pair, and last segment is the value for last pair.
138
+ string key = segments [ 0 ] ;
139
+ for ( int i = 1 ; i < segments . Length - 1 ; i ++ )
140
+ {
141
+ // This is just to
142
+ int lastCommaIndex = segments [ i ] . LastIndexOf ( ",,," ) ;
143
+ int lastSemicolonIndex = segments [ i ] . LastIndexOf ( ';' ) ;
144
+ int splitIndex = Math . Max ( lastCommaIndex , lastSemicolonIndex ) ;
145
+
146
+ string value = segments [ i ] . Substring ( 0 , splitIndex ) ;
147
+ delimitedValues . Add ( key , value ) ;
148
+ key = segments [ i ] . Substring ( splitIndex ) . Trim ( ';' ) . Trim ( ',' ) ;
149
+ }
129
150
130
- delimitedValues . Add ( key , segments [ segments . Length - 1 ] ) ;
151
+ delimitedValues . Add ( key , segments [ segments . Length - 1 ] ) ;
152
+ }
131
153
132
154
return delimitedValues ;
133
155
}
0 commit comments