namespace Octokit { /// /// Represents a product header value. This is used to generate the User Agent string sent with each request. The /// name used should represent the product, the GitHub Organization, or the GitHub username that's using Octokit.net (in that order of preference). /// /// /// This class is a wrapper around /// so that consumers of Octokit.net would not have to add a reference to the System.Net.Http.Headers namespace. /// See more information regarding User-Agent requirements here: https://developer.github.com/v3/#user-agent-required /// public class ProductHeaderValue { readonly System.Net.Http.Headers.ProductHeaderValue _productHeaderValue; /// /// Initializes a new instance of the class. /// /// /// See more information regarding User-Agent requirements here: https://developer.github.com/v3/#user-agent-required /// /// The name of the product, the GitHub Organization, or the GitHub Username (in that order of preference) that's using Octokit public ProductHeaderValue(string name) : this(new System.Net.Http.Headers.ProductHeaderValue(name)) { } /// /// Initializes a new instance of the class. /// /// /// See more information regarding User-Agent requirements here: https://developer.github.com/v3/#user-agent-required /// /// The name of the product, the GitHub Organization, or the GitHub Username (in that order of preference) that's using Octokit /// The version of the product that's using Octokit public ProductHeaderValue(string name, string version) : this(new System.Net.Http.Headers.ProductHeaderValue(name, version)) { } ProductHeaderValue(System.Net.Http.Headers.ProductHeaderValue productHeader) { _productHeaderValue = productHeader; } /// /// The name of the product, the GitHub Organization, or the GitHub Username that's using Octokit (in that order of preference) /// /// /// See more information regarding User-Agent requirements here: https://developer.github.com/v3/#user-agent-required /// public string Name { get { return _productHeaderValue.Name; } } /// /// The version of the product. /// public string Version { get { return _productHeaderValue.Version; } } public override bool Equals(object obj) { return _productHeaderValue.Equals(obj); } public override int GetHashCode() { return _productHeaderValue.GetHashCode(); } public override string ToString() { return _productHeaderValue.ToString(); } /// /// Parses a string in the format "foo" or "foo/1.0" and returns the corresponding /// instance. /// /// The input. public static ProductHeaderValue Parse(string input) { return new ProductHeaderValue(System.Net.Http.Headers.ProductHeaderValue.Parse(input)); } /// /// Parses a string in the format "foo" or "foo/1.0" and returns the corresponding /// instance via an out parameter. /// /// The input. /// The parsed value. public static bool TryParse(string input, out ProductHeaderValue parsedValue) { System.Net.Http.Headers.ProductHeaderValue value; var result = System.Net.Http.Headers.ProductHeaderValue.TryParse(input, out value); parsedValue = result ? Parse(input) : null; return result; } } }