Class RobotsTxtBuilder
- Namespace
- SunamoRobotsTxt
- Assembly
- SunamoRobotsTxt.dll
Builds and parses robots.txt files.
public class RobotsTxtBuilder
- Inheritance
-
RobotsTxtBuilder
- Inherited Members
- Extension Methods
Constructors
RobotsTxtBuilder(IEnumerable<string>)
Parses the given lines of a robots.txt file.
public RobotsTxtBuilder(IEnumerable<string> enumerable)
Parameters
enumerableIEnumerable<string>Lines from a robots.txt file to parse.
Properties
Allows
Gets or sets the allowed paths per user agent.
public Dictionary<string, List<string>> Allows { get; set; }
Property Value
Disallows
Gets or sets the disallowed paths per user agent.
public Dictionary<string, List<string>> Disallows { get; set; }
Property Value
NotRecognizedLines
Gets or sets lines that could not be parsed.
public List<string> NotRecognizedLines { get; set; }
Property Value
Sitemaps
Gets or sets the sitemap URLs.
public List<string> Sitemaps { get; set; }
Property Value
Methods
AddOrCreateIfDontExists(IDictionary<string, List<string>>, string, string)
Adds a value to the list for the given key, creating the list if it does not exist.
public static void AddOrCreateIfDontExists(IDictionary<string, List<string>> dictionary, string key, string value)
Parameters
dictionaryIDictionary<string, List<string>>The dictionary to add to.
keystringThe key to add the value under.
valuestringThe value to add.
AddOrCreateIfDontExists<TKey, TValue>(IDictionary<TKey, List<TValue>>, TKey, TValue)
Adds a value to the list for the given key, creating the list if it does not exist.
public static void AddOrCreateIfDontExists<TKey, TValue>(IDictionary<TKey, List<TValue>> dictionary, TKey key, TValue value)
Parameters
dictionaryIDictionary<TKey, List<TValue>>The dictionary to add to.
keyTKeyThe key to add the value under.
valueTValueThe value to add.
Type Parameters
TKeyThe type of the dictionary key.
TValueThe type of the list elements.
Allow(string, string)
Adds an allow rule for a user agent.
public void Allow(string userAgent, string path)
Parameters
Disallow(string, string)
Adds a disallow rule for a user agent.
public void Disallow(string userAgent, string path)
Parameters
GetValuesOrEmpty<TKey, TValue>(IDictionary<TKey, List<TValue>>, TKey)
Returns the list of values for the given key, or an empty list if the key does not exist.
public static List<TValue> GetValuesOrEmpty<TKey, TValue>(IDictionary<TKey, List<TValue>> dictionary, TKey key)
Parameters
dictionaryIDictionary<TKey, List<TValue>>The dictionary to look up.
keyTKeyThe key to look up.
Returns
- List<TValue>
The list of values, or an empty list.
Type Parameters
TKeyThe type of the dictionary key.
TValueThe type of the list elements.
Save(string)
Saves the robots.txt content to a file.
public void Save(string path)
Parameters
pathstringThe file path to save to.
Sitemap(string)
Adds a sitemap URL.
public void Sitemap(string path)
Parameters
pathstringURL of the sitemap.