private static IList <string> RecombineArguments(IList <string> arguments, char separator) { List <string> list = new List <string>(); string str1 = (string)null; int num = 0; foreach (string str2 in (IEnumerable <string>)arguments) { str1 = str1 != null ? str1 + (object)separator + str2 : str2; num += XmlArgumentUtility.CountParens(str2); if (num == 0) { list.Add(str1); str1 = (string)null; } } if (str1 != null) { list.Add(str1); } if (arguments.Count != list.Count) { arguments = (IList <string>)list; } return(arguments); }
internal static IList <string> SplitArguments(string argumentString) { if (argumentString.IndexOf(',') == -1) { return((IList <string>) new string[1] { argumentString }); } else { List <string> list = new List <string>(); list.AddRange((IEnumerable <string>)argumentString.Split(new char[1] { ',' })); IList <string> arguments = XmlArgumentUtility.RecombineArguments((IList <string>)list, ','); XmlArgumentUtility.TrimStrings(arguments); return(arguments); } }
private string TokenizeValue(XmlAttribute targetAttribute, XmlAttribute transformAttribute, bool fTokenizeParameter, List <Dictionary <string, string> > parameters) { this.tokenizeValueCurrentXmlAttribute = transformAttribute; string transformValue = transformAttribute.Value; string xpathToAttribute1 = this.GetXPathToAttribute(targetAttribute); string input = SetTokenizedAttributes.SubstituteKownValue(transformValue, SetTokenizedAttributes.ParentAttributeRegex, "$(", (SetTokenizedAttributes.GetValueCallback)(key => this.EscapeDirRegexSpecialCharacter(this.GetAttributeValue(key), true))); if (fTokenizeParameter && parameters != null) { StringBuilder stringBuilder = new StringBuilder(input.Length); int num1 = 0; List <System.Text.RegularExpressions.Match> list = new List <System.Text.RegularExpressions.Match>(); do { num1 = input.IndexOf("{%", num1, StringComparison.OrdinalIgnoreCase); if (num1 > -1) { System.Text.RegularExpressions.Match match = SetTokenizedAttributes.DirRegex.Match(input, num1); if (match.Success) { list.Add(match); num1 = match.Index + match.Length; } else { ++num1; } } }while (num1 > -1); if (list.Count > 0) { stringBuilder.Remove(0, stringBuilder.Length); int startIndex = 0; int num2 = 0; foreach (System.Text.RegularExpressions.Match match in list) { stringBuilder.Append(input.Substring(startIndex, match.Index - startIndex)); CaptureCollection captures1 = match.Groups["attrname"].Captures; if (captures1 != null && captures1.Count > 0) { CaptureCollection captures2 = match.Groups["attrval"].Captures; Dictionary <string, string> paramDictionary = new Dictionary <string, string>(4, (IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase); paramDictionary[SetTokenizedAttributes.XPathWithIndex] = xpathToAttribute1; paramDictionary[SetTokenizedAttributes.TokenNumber] = num2.ToString((IFormatProvider)CultureInfo.InvariantCulture); for (int index1 = 0; index1 < captures1.Count; ++index1) { string index2 = captures1[index1].Value; string str = (string)null; if (captures2 != null && index1 < captures2.Count) { str = this.EscapeDirRegexSpecialCharacter(captures2[index1].Value, false); } paramDictionary[index2] = str; } string str1 = (string)null; if (!paramDictionary.TryGetValue(SetTokenizedAttributes.Token, out str1)) { str1 = this.storageDictionary.TokenFormat; } if (!string.IsNullOrEmpty(str1)) { paramDictionary[SetTokenizedAttributes.Token] = str1; } int count = paramDictionary.Count; string[] array = new string[count]; paramDictionary.Keys.CopyTo(array, 0); for (int index1 = 0; index1 < count; ++index1) { string index2 = array[index1]; string str2 = SetTokenizedAttributes.SubstituteKownValue(paramDictionary[index2], SetTokenizedAttributes.TokenFormatRegex, "#(", (SetTokenizedAttributes.GetValueCallback)(key => { if (!paramDictionary.ContainsKey(key)) { return((string)null); } else { return(paramDictionary[key]); } })); paramDictionary[index2] = str2; } if (paramDictionary.TryGetValue(SetTokenizedAttributes.Token, out str1)) { stringBuilder.Append(str1); } string argumentString; if (paramDictionary.TryGetValue(SetTokenizedAttributes.XpathLocator, out argumentString) && !string.IsNullOrEmpty(argumentString)) { IList <string> locators = XmlArgumentUtility.SplitArguments(argumentString); string xpathToAttribute2 = this.GetXPathToAttribute(targetAttribute, locators); if (!string.IsNullOrEmpty(xpathToAttribute2)) { paramDictionary[SetTokenizedAttributes.XPathWithLocator] = xpathToAttribute2; } } parameters.Add(paramDictionary); } startIndex = match.Index + match.Length; ++num2; } stringBuilder.Append(input.Substring(startIndex)); input = ((object)stringBuilder).ToString(); } } return(input); }