mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 22:26:09 +08:00
... cosmetics
This commit is contained in:
@@ -11,8 +11,8 @@ namespace OSHttpServer
|
||||
public class HttpInput : IHttpInput
|
||||
{
|
||||
/// <summary> Representation of a non-initialized class instance </summary>
|
||||
public static readonly HttpInput Empty = new HttpInput("Empty", true);
|
||||
private readonly IDictionary<string, HttpInputItem> _items = new Dictionary<string, HttpInputItem>();
|
||||
public static readonly HttpInput Empty = new("Empty", true);
|
||||
private readonly Dictionary<string, HttpInputItem> _items = new();
|
||||
private string _name;
|
||||
|
||||
/// <summary> Variable telling the class that it is non-initialized <see cref="Empty"/> </summary>
|
||||
@@ -70,7 +70,7 @@ namespace OSHttpServer
|
||||
/// <exception cref="InvalidOperationException">Cannot add stuff to <see cref="HttpInput.Empty"/>.</exception>
|
||||
public void Add(string name, string value)
|
||||
{
|
||||
if (name == null)
|
||||
if (name is null)
|
||||
throw new ArgumentNullException("name");
|
||||
if (_ignoreChanges)
|
||||
throw new InvalidOperationException("Cannot add stuff to HttpInput.Empty.");
|
||||
@@ -80,16 +80,19 @@ namespace OSHttpServer
|
||||
int pos = name.IndexOf('[');
|
||||
if (pos != -1)
|
||||
{
|
||||
string name1 = name.Substring(0, pos);
|
||||
string name1 = name[..pos];
|
||||
string name2 = ExtractOne(name);
|
||||
if (!_items.ContainsKey(name1))
|
||||
_items.Add(name1, new HttpInputItem(name1, null));
|
||||
_items[name1].Add(name2, value);
|
||||
if (!_items.TryGetValue(name1, out HttpInputItem it))
|
||||
{
|
||||
it = new HttpInputItem(name1, null);
|
||||
_items.Add(name1, it);
|
||||
}
|
||||
it.Add(name2, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_items.ContainsKey(name))
|
||||
_items[name].Add(value);
|
||||
if (_items.TryGetValue(name, out HttpInputItem it))
|
||||
it.Add(value);
|
||||
else
|
||||
_items.Add(name, new HttpInputItem(name, value));
|
||||
}
|
||||
@@ -115,7 +118,7 @@ namespace OSHttpServer
|
||||
/// <returns>True if the value exists</returns>
|
||||
public bool Contains(string name)
|
||||
{
|
||||
return _items.ContainsKey(name) && _items[name].Value != null;
|
||||
return _items.TryGetValue(name, out HttpInputItem it) && it.Value is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -134,10 +137,12 @@ namespace OSHttpServer
|
||||
int pos = name.IndexOf('[');
|
||||
if (pos != -1)
|
||||
{
|
||||
string name1 = name.Substring(0, pos);
|
||||
string name1 = name[..pos];
|
||||
string name2 = ExtractOne(name);
|
||||
item = new HttpInputItem(name1, null);
|
||||
item.Add(name2, value);
|
||||
item = new HttpInputItem(name1, null)
|
||||
{
|
||||
{ name2, value }
|
||||
};
|
||||
}
|
||||
else
|
||||
item = new HttpInputItem(name, value);
|
||||
@@ -166,7 +171,7 @@ namespace OSHttpServer
|
||||
foreach (KeyValuePair<string, HttpInputItem> item in _items)
|
||||
temp += item.Value.ToString(null, true) + '&';
|
||||
|
||||
return temp.Length > 0 ? temp.Substring(0, temp.Length - 1) : string.Empty;
|
||||
return temp.Length > 0 ? temp[..^1] : string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -190,7 +195,7 @@ namespace OSHttpServer
|
||||
++pos;
|
||||
int gotMore = value.IndexOf('[', pos + 1);
|
||||
if (gotMore != -1)
|
||||
value = value.Substring(pos, gotMore - pos - 1) + value.Substring(gotMore);
|
||||
value = string.Concat(value.AsSpan(pos, gotMore - pos - 1), value.AsSpan(gotMore));
|
||||
else
|
||||
value = value.Substring(pos, value.Length - pos - 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user