示例#1
0
        public RobotsBuilder AllowWithComment(Uri uri, string comment)
        {
            var allowEntry = new AllowEntry { Url = uri, Comment = comment };
            _lastUserAgent.AddEntry(allowEntry);

            return this;
        }
示例#2
0
        public RobotsBuilder AllowWithComment(string url, string comment)
        {
            var allowEntry = new AllowEntry { Url = new Uri(_robots.BaseUri, url), Comment = comment };
            _lastUserAgent.AddEntry(allowEntry);

            return this;
        }
示例#3
0
 public void Add_allow_entry_Test()
 {
     var target = new UserAgentEntry();
     Entry entry = new AllowEntry();
     target.AddEntry(entry);
     Assert.NotEmpty(target.Entries);
     Assert.NotEmpty(target.AllowEntries);
     Assert.Empty(target.DisallowEntries);
 }
示例#4
0
        private static bool CheckAllowedEntry(AllowEntry entry, string[] uriParts, out bool allow)
        {
            allow = true;
            string[] robotInstructionUriParts = entry.Url.PathAndQuery.Split(new[] { '/', '?' }, StringSplitOptions.RemoveEmptyEntries);

            if (robotInstructionUriParts.Length > uriParts.Length)
                return false;

            bool mismatch = false;
            for (int i = 0; i < Math.Min(robotInstructionUriParts.Length, uriParts.Length); i++)
            {
                if (string.Compare(uriParts[i], robotInstructionUriParts[i], true) != 0)
                {
                    mismatch = true;
                    break;
                }
            }
            if (mismatch)
            {
                return false;
            }

            return true;
        }
示例#5
0
 public void EntryType_Test()
 {
     var target = new AllowEntry();
     Assert.AreEqual(EntryType.Allow, target.Type);
 }
示例#6
0
 internal virtual UrlEntry CreateUrlEntry()
 {
     UrlEntry target = new AllowEntry();
     return target;
 }