private ProductHeaderValue(ProductHeaderValue source) { Contract.Requires(source != null); _name = source._name; _version = source._version; }
private ProductInfoHeaderValue(ProductInfoHeaderValue source) { Contract.Requires(source != null); _product = source._product; _comment = source._comment; }
public ProductInfoHeaderValue (ProductHeaderValue product) { if (product == null) throw new ArgumentNullException (); Product = product; }
private ProductHeaderValue(ProductHeaderValue source) { Contract.Requires(source != null); this.name = source.name; this.version = source.version; }
private ProductInfoHeaderValue(ProductInfoHeaderValue source) { Contract.Requires(source != null); this.product = source.product; this.comment = source.comment; }
private ProductHeaderValue(ProductHeaderValue source) { Debug.Assert(source != null); _name = source._name; _version = source._version; }
private ProductInfoHeaderValue(ProductInfoHeaderValue source) { Debug.Assert(source != null); _product = source._product; _comment = source._comment; }
public void ToString_UseDifferentRanges_AllSerializedCorrectly() { ProductHeaderValue product = new ProductHeaderValue("IRC", "6.9"); Assert.Equal("IRC/6.9", product.ToString()); product = new ProductHeaderValue("product"); Assert.Equal("product", product.ToString()); }
public ProductInfoHeaderValue(ProductHeaderValue product) { if (product == null) { throw new ArgumentNullException(nameof(product)); } _product = product; }
public ProductInfoHeaderValue(ProductHeaderValue product) { if (product == null) { throw new ArgumentNullException("product"); } this.product = product; }
private void CheckValidParsedValue(string input, int startIndex, ProductHeaderValue expectedResult, int expectedIndex) { HttpHeaderParser parser = GenericHeaderParser.MultipleValueProductParser; object result = null; Assert.True(parser.TryParseValue(input, null, ref startIndex, out result), string.Format("TryParse returned false. Input: '{0}'", input)); Assert.Equal(expectedIndex, startIndex); Assert.Equal(result, expectedResult); }
public void Equals() { var value = new ProductHeaderValue ("ab"); Assert.AreEqual (value, new ProductHeaderValue ("ab"), "#1"); Assert.AreEqual (value, new ProductHeaderValue ("AB"), "#2"); Assert.AreNotEqual (value, new ProductHeaderValue ("AA"), "#3"); value = new ProductHeaderValue ("ab", "DD"); Assert.AreEqual (value, new ProductHeaderValue ("Ab", "DD"), "#4"); Assert.AreNotEqual (value, new ProductHeaderValue ("AB"), "#5"); Assert.AreEqual (value, new ProductHeaderValue ("Ab", "dd"), "#6"); }
public void GetHashCode_UseSameAndDifferentRanges_SameOrDifferentHashCodes() { ProductHeaderValue product1 = new ProductHeaderValue("custom", "1.0"); ProductHeaderValue product2 = new ProductHeaderValue("custom"); ProductHeaderValue product3 = new ProductHeaderValue("CUSTOM", "1.0"); ProductHeaderValue product4 = new ProductHeaderValue("RTA", "x11"); ProductHeaderValue product5 = new ProductHeaderValue("rta", "X11"); Assert.NotEqual(product1.GetHashCode(), product2.GetHashCode()); Assert.Equal(product1.GetHashCode(), product3.GetHashCode()); Assert.NotEqual(product1.GetHashCode(), product4.GetHashCode()); Assert.Equal(product4.GetHashCode(), product5.GetHashCode()); }
public void Ctor_SetValidHeaderValues_InstanceCreatedCorrectly() { ProductHeaderValue product = new ProductHeaderValue("HTTP", "2.0"); Assert.Equal("HTTP", product.Name); Assert.Equal("2.0", product.Version); product = new ProductHeaderValue("HTTP"); Assert.Equal("HTTP", product.Name); Assert.Null(product.Version); product = new ProductHeaderValue("HTTP", ""); // null and string.Empty are equivalent Assert.Equal("HTTP", product.Name); Assert.Null(product.Version); }
public void Equals_UseSameAndDifferentRanges_EqualOrNotEqualNoExceptions() { ProductHeaderValue product1 = new ProductHeaderValue("custom", "1.0"); ProductHeaderValue product2 = new ProductHeaderValue("custom"); ProductHeaderValue product3 = new ProductHeaderValue("CUSTOM", "1.0"); ProductHeaderValue product4 = new ProductHeaderValue("RTA", "x11"); ProductHeaderValue product5 = new ProductHeaderValue("rta", "X11"); Assert.False(product1.Equals(null), "custom/1.0 vs. <null>"); Assert.False(product1.Equals(product2), "custom/1.0 vs. custom"); Assert.False(product2.Equals(product1), "custom/1.0 vs. custom"); Assert.True(product1.Equals(product3), "custom/1.0 vs. CUSTOM/1.0"); Assert.False(product1.Equals(product4), "custom/1.0 vs. rta/X11"); Assert.True(product4.Equals(product5), "RTA/x11 vs. rta/X11"); }
static bool TryParseElement (Lexer lexer, out ProductHeaderValue parsedValue, out Token t) { parsedValue = null; t = lexer.Scan (); if (t != Token.Type.Token) return false; parsedValue = new ProductHeaderValue (); parsedValue.Name = lexer.GetStringValue (t); t = lexer.Scan (); if (t == Token.Type.SeparatorSlash) { t = lexer.Scan (); if (t != Token.Type.Token) return false; parsedValue.Version = lexer.GetStringValue (t); t = lexer.Scan (); } return true; }
public static bool TryParse (string input, out ProductHeaderValue parsedValue) { var lexer = new Lexer (input); Token token; if (TryParseElement (lexer, out parsedValue, out token) && token == Token.Type.End) return true; parsedValue = null; return false; }
public ProductInfoHeaderValue(ProductHeaderValue product) { ArgumentNullException.ThrowIfNull(product); _product = product; }
public ProductInfoHeaderValue(string productName, string productVersion) { Product = new ProductHeaderValue(productName, productVersion); }
public ObservableGitHubClient(ProductHeaderValue productInformation, ICredentialStore credentialStore, Uri baseAddress) : this(new GitHubClient(productInformation, credentialStore, baseAddress)) { }
private void CheckValidParse(string input, ProductHeaderValue expectedResult) { ProductHeaderValue result = ProductHeaderValue.Parse(input); Assert.Equal(expectedResult, result); }
public ObservableGitHubClient(ProductHeaderValue productInformation) : this(new GitHubClient(productInformation)) { }
public ObservableGitHubClient(ProductHeaderValue productInformation, Uri baseAddress) : this(new GitHubClient(productInformation, baseAddress)) { }
public ProductInfoHeaderValue (string productName, string productVersion) { Product = new ProductHeaderValue (productName, productVersion); }
private void CheckValidTryParse(string input, ProductHeaderValue expectedResult) { ProductHeaderValue result = null; Assert.True(ProductHeaderValue.TryParse(input, out result)); Assert.Equal(expectedResult, result); }
private static void CallGetProductLength(string input, int startIndex, int expectedLength, out ProductHeaderValue result) { Assert.Equal(expectedLength, ProductHeaderValue.GetProductLength(input, startIndex, out result)); }
internal static int GetProductLength(string input, int startIndex, out ProductHeaderValue parsedValue) { Contract.Requires(startIndex >= 0); parsedValue = null; if (string.IsNullOrEmpty(input) || (startIndex >= input.Length)) { return 0; } // Parse the name string: <name> in '<name>/<version>'. int nameLength = HttpRuleParser.GetTokenLength(input, startIndex); if (nameLength == 0) { return 0; } ProductHeaderValue result = new ProductHeaderValue(); result._name = input.Substring(startIndex, nameLength); int current = startIndex + nameLength; current = current + HttpRuleParser.GetWhitespaceLength(input, current); if ((current == input.Length) || (input[current] != '/')) { parsedValue = result; return current - startIndex; } current++; // Skip '/' delimiter. current = current + HttpRuleParser.GetWhitespaceLength(input, current); // Parse the name string: <version> in '<name>/<version>'. int versionLength = HttpRuleParser.GetTokenLength(input, current); if (versionLength == 0) { return 0; // If there is a '/' separator it must be followed by a valid token. } result._version = input.Substring(current, versionLength); current = current + versionLength; current = current + HttpRuleParser.GetWhitespaceLength(input, current); parsedValue = result; return current - startIndex; }
public void Properties() { var value = new ProductHeaderValue ("s", "p"); Assert.AreEqual ("s", value.Name, "#1"); Assert.AreEqual ("p", value.Version, "#2"); value = new ProductHeaderValue ("s"); Assert.AreEqual ("s", value.Name, "#3"); Assert.IsNull (value.Version, "#4"); }
public static bool TryParse(string input, out ProductHeaderValue parsedValue) { int index = 0; object output; parsedValue = null; if (GenericHeaderParser.SingleValueProductParser.TryParseValue(input, null, ref index, out output)) { parsedValue = (ProductHeaderValue)output; return true; } return false; }
public static bool TryParse(string input, out ProductHeaderValue parsedValue) { }
public void Clone_Call_CloneFieldsMatchSourceFields() { ProductHeaderValue source = new ProductHeaderValue("SHTTP", "1.3"); ProductHeaderValue clone = (ProductHeaderValue)((ICloneable)source).Clone(); Assert.Equal(source.Name, clone.Name); Assert.Equal(source.Version, clone.Version); source = new ProductHeaderValue("SHTTP", null); clone = (ProductHeaderValue)((ICloneable)source).Clone(); Assert.Equal(source.Name, clone.Name); Assert.Null(clone.Version); }
public static void AddProductToUserAgent(this RestAgent restAgent, ProductHeaderValue product) { ((HttpRequestHeaders)restAgent.DefaultRequestHeaders).UserAgent.Add(new ProductInfoHeaderValue(product)); }
static bool TryParseElement (Lexer lexer, out ProductInfoHeaderValue parsedValue) { string comment; parsedValue = null; Token t; if (lexer.ScanCommentOptional (out comment, out t)) { if (comment == null) return false; parsedValue = new ProductInfoHeaderValue (); parsedValue.Comment = comment; return true; } if (t == Token.Type.End) return true; if (t != Token.Type.Token) return false; var value = new ProductHeaderValue (); value.Name = lexer.GetStringValue (t); var pos = lexer.Position; t = lexer.Scan (); if (t == Token.Type.SeparatorSlash) { t = lexer.Scan (); if (t != Token.Type.Token) return false; value.Version = lexer.GetStringValue (t); } else { lexer.Position = pos; } parsedValue = new ProductInfoHeaderValue (value); return true; }
internal static int GetProductLength(string input, int startIndex, out ProductHeaderValue parsedValue) { }