string[] ExtractEndings(MimeTypeNode node) { var result = new List <string> (); foreach (MimeTypeFileNode file in node.ChildNodes) { foreach (string pattern in file.Pattern.Split('|')) { result.Add(pattern.StartsWith("*.", StringComparison.Ordinal) ? pattern.Substring(1) : pattern); } } return(result.ToArray()); }
internal static bool IsCompatible(MimeTypeNode node) { foreach (MimeTypeFileNode file in node.ChildNodes) { foreach (string pattern in file.Pattern.Split('|')) { var pat = pattern.StartsWith("*.", StringComparison.Ordinal) ? pattern.Substring(1) : pattern; if (pat.Any(p => p == '*' || p == '?')) { return(false); } } } return(true); }
Regex CreateRegex(MimeTypeNode node) { var globalPattern = new StringBuilder(); foreach (MimeTypeFileNode file in node.ChildNodes) { string pattern = Regex.Escape(file.Pattern); pattern = pattern.Replace("\\*", ".*"); pattern = pattern.Replace("\\?", "."); pattern = pattern.Replace("\\|", "$|^"); pattern = "^" + pattern + "$"; if (globalPattern.Length > 0) { globalPattern.Append('|'); } globalPattern.Append(pattern); } return(new Regex(globalPattern.ToString(), RegexOptions.IgnoreCase)); }
Regex CreateRegex (MimeTypeNode node) { var globalPattern = new StringBuilder (); foreach (MimeTypeFileNode file in node.ChildNodes) { string pattern = Regex.Escape (file.Pattern); pattern = pattern.Replace ("\\*",".*"); pattern = pattern.Replace ("\\?","."); pattern = pattern.Replace ("\\|","$|^"); pattern = "^" + pattern + "$"; if (globalPattern.Length > 0) globalPattern.Append ('|'); globalPattern.Append (pattern); } return new Regex (globalPattern.ToString ()); }
public RegexFileNameEvalutor (MimeTypeNode node) { regex = CreateRegex (node); }
internal static bool IsCompatible (MimeTypeNode node) { foreach (MimeTypeFileNode file in node.ChildNodes) { foreach (string pattern in file.Pattern.Split ('|')) { var pat = pattern.StartsWith ("*.") ? pattern.Substring (1) : pattern; if (pat.Any (p => p == '*' || p == '?')) return false; } } return true; }
string[] ExtractEndings (MimeTypeNode node) { var result = new List<string> (); foreach (MimeTypeFileNode file in node.ChildNodes) { foreach (string pattern in file.Pattern.Split ('|')) { result.Add (pattern.StartsWith ("*.") ? pattern.Substring (1) : pattern); } } return result.ToArray (); }
public EndsWithFileNameEvalutor (MimeTypeNode node) { endings = ExtractEndings (node); }
public RegexFileNameEvaluator(MimeTypeNode node) { regex = CreateRegex(node); }
public EndsWithFileNameEvaluator(MimeTypeNode node) { endings = ExtractEndings(node); }