예제 #1
0
            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());
            }
예제 #2
0
 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);
 }
예제 #3
0
            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);
			}
예제 #9
0
 public RegexFileNameEvaluator(MimeTypeNode node)
 {
     regex = CreateRegex(node);
 }
예제 #10
0
 public EndsWithFileNameEvaluator(MimeTypeNode node)
 {
     endings = ExtractEndings(node);
 }