public static string GetSqfPropertySectionArg(SqfProperty prop, string fullString, int argIndex) { var section = GetSqfPropertySection(prop, fullString); if (string.IsNullOrWhiteSpace(section)) return ""; var filterString = Regex.Replace(prop.Format, @"\{[0-9]*\}", "(.*)"); var matches = Regex.Split(section, filterString); return matches[argIndex + 1]; }
public static string GetSqfPropertySection(SqfProperty prop, string fullString) { if (prop.AllowInfinite) throw new ArgumentException("This function cannot handle infinite arguments"); var match = Regex.Match(fullString, string.Format("comment \"<{0}>\";(.*)comment \"</{0}>\";", Regex.Escape(prop.Ident))); if (match.Success) { return match.Groups[1].Value; } return ""; }
public static string GetSqfPropertySectionArg(SqfProperty prop, string fullString, int argIndex) { var section = GetSqfPropertySection(prop, fullString); if (string.IsNullOrWhiteSpace(section)) { return(""); } var filterString = Regex.Replace(prop.Format, @"\{[0-9]*\}", "(.*)"); var matches = Regex.Split(section, filterString); return(matches[argIndex + 1]); }
public static string SetSqfPropertySectionArg(SqfProperty prop, string fullString, string content, int argIndex) { if (prop.AllowInfinite) { throw new ArgumentException("This function cannot handle infinite arguments"); } if (!HasSqfPropertySection(prop, fullString)) { var stringList = new List <string>(); foreach (var it in prop.Arguments) { if (it.Property == null) { stringList.Add("(_this select 0)"); } else { stringList.Add(""); } } stringList[argIndex] = content; var builder = new StringBuilder(); builder.Append("comment \"<"); builder.Append(prop.Ident); builder.Append(">\";"); builder.Append(string.Format(prop.Format, stringList.ToArray())); builder.Append("comment \"</"); builder.Append(prop.Ident); builder.Append(">\";"); return(fullString.Insert(0, builder.ToString())); } else { var section = GetSqfPropertySection(prop, fullString); var filterString = Regex.Replace(prop.Format, @"\{[0-9]*\}", "(.*)"); var matches = Regex.Split(section, filterString); matches[argIndex + 1] = content; var builder = new StringBuilder(); builder.Append("comment \"<"); builder.Append(prop.Ident); builder.Append(">\";"); string[] sArr = new string[matches.Length - 1]; Array.Copy(matches, 1, sArr, 0, matches.Length - 1); builder.Append(string.Format(prop.Format, sArr)); builder.Append("comment \"</"); builder.Append(prop.Ident); builder.Append(">\";"); return(Regex.Replace(fullString, string.Format("comment \"<{0}>\";.*comment \"</{0}>\";", Regex.Escape(prop.Ident)), builder.ToString())); } }
public static string GetSqfPropertySection(SqfProperty prop, string fullString) { if (prop.AllowInfinite) { throw new ArgumentException("This function cannot handle infinite arguments"); } var match = Regex.Match(fullString, string.Format("comment \"<{0}>\";(.*)comment \"</{0}>\";", Regex.Escape(prop.Ident))); if (match.Success) { return(match.Groups[1].Value); } return(""); }
public static string SetSqfPropertySectionArg(SqfProperty prop, string fullString, string content, int argIndex) { if (prop.AllowInfinite) throw new ArgumentException("This function cannot handle infinite arguments"); if(!HasSqfPropertySection(prop, fullString)) { var stringList = new List<string>(); foreach (var it in prop.Arguments) { if (it.Property == null) { stringList.Add("(_this select 0)"); } else { stringList.Add(""); } } stringList[argIndex] = content; var builder = new StringBuilder(); builder.Append("comment \"<"); builder.Append(prop.Ident); builder.Append(">\";"); builder.Append(string.Format(prop.Format, stringList.ToArray())); builder.Append("comment \"</"); builder.Append(prop.Ident); builder.Append(">\";"); return fullString.Insert(0, builder.ToString()); } else { var section = GetSqfPropertySection(prop, fullString); var filterString = Regex.Replace(prop.Format, @"\{[0-9]*\}", "(.*)"); var matches = Regex.Split(section, filterString); matches[argIndex + 1] = content; var builder = new StringBuilder(); builder.Append("comment \"<"); builder.Append(prop.Ident); builder.Append(">\";"); string[] sArr = new string[matches.Length - 1]; Array.Copy(matches, 1, sArr, 0, matches.Length - 1); builder.Append(string.Format(prop.Format, sArr)); builder.Append("comment \"</"); builder.Append(prop.Ident); builder.Append(">\";"); return Regex.Replace(fullString, string.Format("comment \"<{0}>\";.*comment \"</{0}>\";", Regex.Escape(prop.Ident)), builder.ToString()); } }
public static bool HasSqfPropertySection(SqfProperty prop, string fullString) { return Regex.IsMatch(fullString, string.Format("comment \"<{0}>\";(.*)comment \"</{0}>\";", Regex.Escape(prop.Ident))); }
public static bool HasSqfPropertySection(SqfProperty prop, string fullString) { return(Regex.IsMatch(fullString, string.Format("comment \"<{0}>\";(.*)comment \"</{0}>\";", Regex.Escape(prop.Ident)))); }