Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ProductInfoHeaderValue.cs
Go to the documentation of this file.
3
5
7{
9
10 private string _comment;
11
13
14 public string? Comment => _comment;
15
16 public ProductInfoHeaderValue(string productName, string? productVersion)
17 : this(new ProductHeaderValue(productName, productVersion))
18 {
19 }
20
22 {
23 if (product == null)
24 {
25 throw new ArgumentNullException("product");
26 }
27 _product = product;
28 }
29
30 public ProductInfoHeaderValue(string comment)
31 {
32 HeaderUtilities.CheckValidComment(comment, "comment");
33 _comment = comment;
34 }
35
37 {
38 _product = source._product;
39 _comment = source._comment;
40 }
41
42 public override string ToString()
43 {
44 if (_product == null)
45 {
46 return _comment;
47 }
48 return _product.ToString();
49 }
50
51 public override bool Equals([NotNullWhen(true)] object? obj)
52 {
53 if (!(obj is ProductInfoHeaderValue productInfoHeaderValue))
54 {
55 return false;
56 }
57 if (_product == null)
58 {
59 return string.Equals(_comment, productInfoHeaderValue._comment, StringComparison.Ordinal);
60 }
61 return _product.Equals(productInfoHeaderValue._product);
62 }
63
64 public override int GetHashCode()
65 {
66 if (_product == null)
67 {
68 return _comment.GetHashCode();
69 }
70 return _product.GetHashCode();
71 }
72
73 public static ProductInfoHeaderValue Parse(string input)
74 {
75 int index = 0;
76 object obj = ProductInfoHeaderParser.SingleValueParser.ParseValue(input, null, ref index);
77 if (index < input.Length)
78 {
80 }
82 }
83
84 public static bool TryParse([NotNullWhen(true)] string input, [NotNullWhen(true)] out ProductInfoHeaderValue? parsedValue)
85 {
86 int index = 0;
87 parsedValue = null;
88 if (ProductInfoHeaderParser.SingleValueParser.TryParseValue(input, null, ref index, out var parsedValue2))
89 {
90 if (index < input.Length)
91 {
92 return false;
93 }
94 parsedValue = (ProductInfoHeaderValue)parsedValue2;
95 return true;
96 }
97 return false;
98 }
99
100 internal static int GetProductInfoLength(string input, int startIndex, out ProductInfoHeaderValue parsedValue)
101 {
102 parsedValue = null;
103 if (string.IsNullOrEmpty(input) || startIndex >= input.Length)
104 {
105 return 0;
106 }
107 int num = startIndex;
108 string text = null;
109 ProductHeaderValue parsedValue2 = null;
110 if (input[num] == '(')
111 {
112 int length = 0;
113 if (HttpRuleParser.GetCommentLength(input, num, out length) != 0)
114 {
115 return 0;
116 }
117 text = input.Substring(num, length);
118 num += length;
120 parsedValue = new ProductInfoHeaderValue(text);
121 }
122 else
123 {
124 int productLength = ProductHeaderValue.GetProductLength(input, num, out parsedValue2);
125 if (productLength == 0)
126 {
127 return 0;
128 }
129 num += productLength;
130 parsedValue = new ProductInfoHeaderValue(parsedValue2);
131 }
132 return num - startIndex;
133 }
134
136 {
137 return new ProductInfoHeaderValue(this);
138 }
139}
static CultureInfo InvariantCulture
static void CheckValidComment(string value, string parameterName)
override bool Equals([NotNullWhen(true)] object? obj)
static int GetProductLength(string input, int startIndex, out ProductHeaderValue parsedValue)
static readonly ProductInfoHeaderParser SingleValueParser
ProductInfoHeaderValue(string productName, string? productVersion)
static ProductInfoHeaderValue Parse(string input)
override bool Equals([NotNullWhen(true)] object? obj)
static int GetProductInfoLength(string input, int startIndex, out ProductInfoHeaderValue parsedValue)
static bool TryParse([NotNullWhen(true)] string input, [NotNullWhen(true)] out ProductInfoHeaderValue? parsedValue)
static HttpParseResult GetCommentLength(string input, int startIndex, out int length)
static int GetWhitespaceLength(string input, int startIndex)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_http_headers_invalid_value
Definition SR.cs:26
Definition SR.cs:7