Sync most changes from May 9, 2020 libremetaverse into -core
This commit is contained in:
parent
c3ff59a2b5
commit
a3cb5c595c
18 changed files with 919 additions and 830 deletions
|
|
@ -73,8 +73,10 @@ namespace LitJson
|
|||
|
||||
bool IDictionary.IsReadOnly => EnsureDictionary().IsReadOnly;
|
||||
|
||||
ICollection IDictionary.Keys {
|
||||
get {
|
||||
ICollection IDictionary.Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureDictionary();
|
||||
IList<string> keys = object_list.Select(entry => entry.Key).ToList();
|
||||
|
||||
|
|
@ -82,8 +84,10 @@ namespace LitJson
|
|||
}
|
||||
}
|
||||
|
||||
ICollection IDictionary.Values {
|
||||
get {
|
||||
ICollection IDictionary.Values
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureDictionary();
|
||||
IList<JsonData> values = object_list.Select(entry => entry.Value).ToList();
|
||||
|
||||
|
|
@ -121,12 +125,15 @@ namespace LitJson
|
|||
|
||||
|
||||
#region IDictionary Indexer
|
||||
object IDictionary.this[object key] {
|
||||
get {
|
||||
object IDictionary.this[object key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return EnsureDictionary()[key];
|
||||
}
|
||||
|
||||
set {
|
||||
set
|
||||
{
|
||||
if (!(key is String))
|
||||
throw new ArgumentException(
|
||||
"The key has to be a string");
|
||||
|
|
@ -140,13 +147,16 @@ namespace LitJson
|
|||
|
||||
|
||||
#region IOrderedDictionary Indexer
|
||||
object IOrderedDictionary.this[int idx] {
|
||||
get {
|
||||
object IOrderedDictionary.this[int idx]
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureDictionary();
|
||||
return object_list[idx].Value;
|
||||
}
|
||||
|
||||
set {
|
||||
set
|
||||
{
|
||||
EnsureDictionary();
|
||||
JsonData data = ToJsonData(value);
|
||||
var old_entry = object_list[idx];
|
||||
|
|
@ -159,12 +169,15 @@ namespace LitJson
|
|||
|
||||
|
||||
#region IList Indexer
|
||||
object IList.this[int index] {
|
||||
get {
|
||||
object IList.this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return EnsureList()[index];
|
||||
}
|
||||
|
||||
set {
|
||||
set
|
||||
{
|
||||
EnsureList();
|
||||
JsonData data = ToJsonData(value);
|
||||
|
||||
|
|
@ -175,13 +188,16 @@ namespace LitJson
|
|||
|
||||
|
||||
#region Public Indexers
|
||||
public JsonData this[string prop_name] {
|
||||
get {
|
||||
public JsonData this[string prop_name]
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureDictionary();
|
||||
return inst_object[prop_name];
|
||||
}
|
||||
|
||||
set {
|
||||
set
|
||||
{
|
||||
EnsureDictionary();
|
||||
var entry = new KeyValuePair<string, JsonData>(prop_name, value);
|
||||
if (inst_object.ContainsKey(prop_name))
|
||||
|
|
@ -206,18 +222,22 @@ namespace LitJson
|
|||
}
|
||||
}
|
||||
|
||||
public JsonData this[int index] {
|
||||
get {
|
||||
public JsonData this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureCollection();
|
||||
return type == JsonType.Array ? inst_array[index] : object_list[index].Value;
|
||||
}
|
||||
|
||||
set {
|
||||
set
|
||||
{
|
||||
EnsureCollection();
|
||||
|
||||
if (type == JsonType.Array)
|
||||
inst_array[index] = value;
|
||||
else {
|
||||
else
|
||||
{
|
||||
var entry = object_list[index];
|
||||
var new_entry = new KeyValuePair<string, JsonData>(entry.Key, value);
|
||||
|
||||
|
|
@ -262,33 +282,38 @@ namespace LitJson
|
|||
|
||||
public JsonData(object obj)
|
||||
{
|
||||
if (obj is Boolean) {
|
||||
if (obj is bool b)
|
||||
{
|
||||
type = JsonType.Boolean;
|
||||
inst_boolean = (bool) obj;
|
||||
inst_boolean = b;
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is Double) {
|
||||
if (obj is double d)
|
||||
{
|
||||
type = JsonType.Double;
|
||||
inst_double = (double) obj;
|
||||
inst_double = d;
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is Int32) {
|
||||
if (obj is int i)
|
||||
{
|
||||
type = JsonType.Int;
|
||||
inst_int = (int) obj;
|
||||
inst_int = i;
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is Int64) {
|
||||
if (obj is long l)
|
||||
{
|
||||
type = JsonType.Long;
|
||||
inst_long = (long) obj;
|
||||
inst_long = l;
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is String) {
|
||||
if (obj is string s)
|
||||
{
|
||||
type = JsonType.String;
|
||||
inst_string = (string) obj;
|
||||
inst_string = s;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -422,8 +447,10 @@ namespace LitJson
|
|||
{
|
||||
EnsureDictionary().Remove(key);
|
||||
|
||||
for (int i = 0; i < object_list.Count; i++) {
|
||||
if (object_list[i].Key == (string) key) {
|
||||
for (int i = 0; i < object_list.Count; i++)
|
||||
{
|
||||
if (object_list[i].Key == (string)key)
|
||||
{
|
||||
object_list.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
|
|
@ -658,40 +685,46 @@ namespace LitJson
|
|||
if (obj == null)
|
||||
return null;
|
||||
|
||||
if (obj is JsonData)
|
||||
return (JsonData) obj;
|
||||
if (obj is JsonData data)
|
||||
return data;
|
||||
|
||||
return new JsonData(obj);
|
||||
}
|
||||
|
||||
private static void WriteJson(IJsonWrapper obj, JsonWriter writer)
|
||||
{
|
||||
if (obj.IsString) {
|
||||
if (obj.IsString)
|
||||
{
|
||||
writer.Write(obj.GetString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.IsBoolean) {
|
||||
if (obj.IsBoolean)
|
||||
{
|
||||
writer.Write(obj.GetBoolean());
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.IsDouble) {
|
||||
if (obj.IsDouble)
|
||||
{
|
||||
writer.Write(obj.GetDouble());
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.IsInt) {
|
||||
if (obj.IsInt)
|
||||
{
|
||||
writer.Write(obj.GetInt());
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.IsLong) {
|
||||
if (obj.IsLong)
|
||||
{
|
||||
writer.Write(obj.GetLong());
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.IsArray) {
|
||||
if (obj.IsArray)
|
||||
{
|
||||
writer.WriteArrayStart();
|
||||
foreach (object elem in (IList)obj)
|
||||
WriteJson((JsonData)elem, writer);
|
||||
|
|
@ -700,10 +733,12 @@ namespace LitJson
|
|||
return;
|
||||
}
|
||||
|
||||
if (obj.IsObject) {
|
||||
if (obj.IsObject)
|
||||
{
|
||||
writer.WriteObjectStart();
|
||||
|
||||
foreach (DictionaryEntry entry in ((IDictionary) obj)) {
|
||||
foreach (DictionaryEntry entry in ((IDictionary)obj))
|
||||
{
|
||||
writer.WritePropertyName((string)entry.Key);
|
||||
WriteJson((JsonData)entry.Value, writer);
|
||||
}
|
||||
|
|
@ -724,7 +759,8 @@ namespace LitJson
|
|||
|
||||
public void Clear()
|
||||
{
|
||||
if (IsObject) {
|
||||
if (IsObject)
|
||||
{
|
||||
((IDictionary)this).Clear();
|
||||
}
|
||||
else if (IsArray)
|
||||
|
|
@ -738,7 +774,8 @@ namespace LitJson
|
|||
if (x?.type != type)
|
||||
return false;
|
||||
|
||||
switch (this.type) {
|
||||
switch (this.type)
|
||||
{
|
||||
case JsonType.None:
|
||||
return true;
|
||||
|
||||
|
|
@ -777,7 +814,8 @@ namespace LitJson
|
|||
if (this.type == type)
|
||||
return;
|
||||
|
||||
switch (type) {
|
||||
switch (type)
|
||||
{
|
||||
case JsonType.None:
|
||||
break;
|
||||
|
||||
|
|
@ -841,7 +879,8 @@ namespace LitJson
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
switch (type) {
|
||||
switch (type)
|
||||
{
|
||||
case JsonType.Array:
|
||||
return "JsonData array";
|
||||
|
||||
|
|
@ -876,8 +915,10 @@ namespace LitJson
|
|||
|
||||
public object Current => Entry;
|
||||
|
||||
public DictionaryEntry Entry {
|
||||
get {
|
||||
public DictionaryEntry Entry
|
||||
{
|
||||
get
|
||||
{
|
||||
var curr = list_enumerator.Current;
|
||||
return new DictionaryEntry(curr.Key, curr.Value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,10 @@ namespace LitJson
|
|||
private bool is_list;
|
||||
|
||||
|
||||
public Type ElementType {
|
||||
get {
|
||||
public Type ElementType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (element_type == null)
|
||||
return typeof(JsonData);
|
||||
|
||||
|
|
@ -45,12 +47,14 @@ namespace LitJson
|
|||
set { element_type = value; }
|
||||
}
|
||||
|
||||
public bool IsArray {
|
||||
public bool IsArray
|
||||
{
|
||||
get { return is_array; }
|
||||
set { is_array = value; }
|
||||
}
|
||||
|
||||
public bool IsList {
|
||||
public bool IsList
|
||||
{
|
||||
get { return is_list; }
|
||||
set { is_list = value; }
|
||||
}
|
||||
|
|
@ -65,8 +69,10 @@ namespace LitJson
|
|||
private IDictionary<string, PropertyMetadata> properties;
|
||||
|
||||
|
||||
public Type ElementType {
|
||||
get {
|
||||
public Type ElementType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (element_type == null)
|
||||
return typeof(JsonData);
|
||||
|
||||
|
|
@ -76,12 +82,14 @@ namespace LitJson
|
|||
set { element_type = value; }
|
||||
}
|
||||
|
||||
public bool IsDictionary {
|
||||
public bool IsDictionary
|
||||
{
|
||||
get { return is_dictionary; }
|
||||
set { is_dictionary = value; }
|
||||
}
|
||||
|
||||
public IDictionary<string, PropertyMetadata> Properties {
|
||||
public IDictionary<string, PropertyMetadata> Properties
|
||||
{
|
||||
get { return properties; }
|
||||
set { properties = value; }
|
||||
}
|
||||
|
|
@ -173,7 +181,8 @@ namespace LitJson
|
|||
if (type.GetInterface("System.Collections.IList") != null)
|
||||
data.IsList = true;
|
||||
|
||||
foreach (PropertyInfo p_info in type.GetProperties ()) {
|
||||
foreach (PropertyInfo p_info in type.GetProperties())
|
||||
{
|
||||
if (p_info.Name != "Item")
|
||||
continue;
|
||||
|
||||
|
|
@ -186,10 +195,14 @@ namespace LitJson
|
|||
data.ElementType = p_info.PropertyType;
|
||||
}
|
||||
|
||||
lock (array_metadata_lock) {
|
||||
try {
|
||||
lock (array_metadata_lock)
|
||||
{
|
||||
try
|
||||
{
|
||||
array_metadata.Add(type, data);
|
||||
} catch (ArgumentException) {
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -207,8 +220,10 @@ namespace LitJson
|
|||
|
||||
data.Properties = new Dictionary<string, PropertyMetadata>();
|
||||
|
||||
foreach (PropertyInfo p_info in type.GetProperties ()) {
|
||||
if (p_info.Name == "Item") {
|
||||
foreach (PropertyInfo p_info in type.GetProperties())
|
||||
{
|
||||
if (p_info.Name == "Item")
|
||||
{
|
||||
ParameterInfo[] parameters = p_info.GetIndexParameters();
|
||||
|
||||
if (parameters.Length != 1)
|
||||
|
|
@ -227,7 +242,8 @@ namespace LitJson
|
|||
data.Properties.Add(p_info.Name, p_data);
|
||||
}
|
||||
|
||||
foreach (FieldInfo f_info in type.GetFields ()) {
|
||||
foreach (FieldInfo f_info in type.GetFields())
|
||||
{
|
||||
PropertyMetadata p_data = new PropertyMetadata();
|
||||
p_data.Info = f_info;
|
||||
p_data.IsField = true;
|
||||
|
|
@ -236,10 +252,14 @@ namespace LitJson
|
|||
data.Properties.Add(f_info.Name, p_data);
|
||||
}
|
||||
|
||||
lock (object_metadata_lock) {
|
||||
try {
|
||||
lock (object_metadata_lock)
|
||||
{
|
||||
try
|
||||
{
|
||||
object_metadata.Add(type, data);
|
||||
} catch (ArgumentException) {
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -252,7 +272,8 @@ namespace LitJson
|
|||
|
||||
IList<PropertyMetadata> props = new List<PropertyMetadata>();
|
||||
|
||||
foreach (PropertyInfo p_info in type.GetProperties ()) {
|
||||
foreach (PropertyInfo p_info in type.GetProperties())
|
||||
{
|
||||
if (p_info.Name == "Item")
|
||||
continue;
|
||||
|
||||
|
|
@ -262,7 +283,8 @@ namespace LitJson
|
|||
props.Add(p_data);
|
||||
}
|
||||
|
||||
foreach (FieldInfo f_info in type.GetFields ()) {
|
||||
foreach (FieldInfo f_info in type.GetFields())
|
||||
{
|
||||
PropertyMetadata p_data = new PropertyMetadata();
|
||||
p_data.Info = f_info;
|
||||
p_data.IsField = true;
|
||||
|
|
@ -270,10 +292,14 @@ namespace LitJson
|
|||
props.Add(p_data);
|
||||
}
|
||||
|
||||
lock (type_properties_lock) {
|
||||
try {
|
||||
lock (type_properties_lock)
|
||||
{
|
||||
try
|
||||
{
|
||||
type_properties.Add(type, props);
|
||||
} catch (ArgumentException) {
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -292,10 +318,14 @@ namespace LitJson
|
|||
|
||||
var op = t1.GetMethod("op_Implicit", new[] { t2 });
|
||||
|
||||
lock (conv_ops_lock) {
|
||||
try {
|
||||
lock (conv_ops_lock)
|
||||
{
|
||||
try
|
||||
{
|
||||
conv_ops[t1].Add(t2, op);
|
||||
} catch (ArgumentException) {
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return conv_ops[t1][t2];
|
||||
}
|
||||
}
|
||||
|
|
@ -310,7 +340,8 @@ namespace LitJson
|
|||
if (reader.Token == JsonToken.ArrayEnd)
|
||||
return null;
|
||||
|
||||
if (reader.Token == JsonToken.Null) {
|
||||
if (reader.Token == JsonToken.Null)
|
||||
{
|
||||
|
||||
if (!inst_type.IsClass)
|
||||
throw new JsonException(String.Format(
|
||||
|
|
@ -324,7 +355,8 @@ namespace LitJson
|
|||
reader.Token == JsonToken.Int ||
|
||||
reader.Token == JsonToken.Long ||
|
||||
reader.Token == JsonToken.String ||
|
||||
reader.Token == JsonToken.Boolean) {
|
||||
reader.Token == JsonToken.Boolean)
|
||||
{
|
||||
|
||||
Type json_type = reader.Value.GetType();
|
||||
|
||||
|
|
@ -334,7 +366,8 @@ namespace LitJson
|
|||
// If there's a custom importer that fits, use it
|
||||
if (custom_importers_table.ContainsKey(json_type) &&
|
||||
custom_importers_table[json_type].ContainsKey(
|
||||
inst_type)) {
|
||||
inst_type))
|
||||
{
|
||||
|
||||
ImporterFunc importer =
|
||||
custom_importers_table[json_type][inst_type];
|
||||
|
|
@ -345,7 +378,8 @@ namespace LitJson
|
|||
// Maybe there's a base importer that works
|
||||
if (base_importers_table.ContainsKey(json_type) &&
|
||||
base_importers_table[json_type].ContainsKey(
|
||||
inst_type)) {
|
||||
inst_type))
|
||||
{
|
||||
|
||||
ImporterFunc importer =
|
||||
base_importers_table[json_type][inst_type];
|
||||
|
|
@ -372,7 +406,8 @@ namespace LitJson
|
|||
|
||||
object instance = null;
|
||||
|
||||
if (reader.Token == JsonToken.ArrayStart) {
|
||||
if (reader.Token == JsonToken.ArrayStart)
|
||||
{
|
||||
|
||||
AddArrayMetadata(inst_type);
|
||||
ArrayMetadata t_data = array_metadata[inst_type];
|
||||
|
|
@ -385,15 +420,19 @@ namespace LitJson
|
|||
IList list;
|
||||
Type elem_type;
|
||||
|
||||
if (! t_data.IsArray) {
|
||||
if (!t_data.IsArray)
|
||||
{
|
||||
list = (IList)Activator.CreateInstance(inst_type);
|
||||
elem_type = t_data.ElementType;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
list = new ArrayList();
|
||||
elem_type = inst_type.GetElementType();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
while (true)
|
||||
{
|
||||
object item = ReadValue(elem_type, reader);
|
||||
if (reader.Token == JsonToken.ArrayEnd)
|
||||
break;
|
||||
|
|
@ -401,23 +440,28 @@ namespace LitJson
|
|||
list.Add(item);
|
||||
}
|
||||
|
||||
if (t_data.IsArray) {
|
||||
if (t_data.IsArray)
|
||||
{
|
||||
int n = list.Count;
|
||||
instance = Array.CreateInstance(elem_type, n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
((Array)instance).SetValue(list[i], i);
|
||||
} else
|
||||
}
|
||||
else
|
||||
instance = list;
|
||||
|
||||
} else if (reader.Token == JsonToken.ObjectStart) {
|
||||
}
|
||||
else if (reader.Token == JsonToken.ObjectStart)
|
||||
{
|
||||
|
||||
AddObjectMetadata(inst_type);
|
||||
ObjectMetadata t_data = object_metadata[inst_type];
|
||||
|
||||
instance = Activator.CreateInstance(inst_type);
|
||||
|
||||
while (true) {
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
|
||||
if (reader.Token == JsonToken.ObjectEnd)
|
||||
|
|
@ -425,14 +469,18 @@ namespace LitJson
|
|||
|
||||
string property = (string)reader.Value;
|
||||
|
||||
if (t_data.Properties.ContainsKey (property)) {
|
||||
if (t_data.Properties.ContainsKey(property))
|
||||
{
|
||||
PropertyMetadata prop_data =
|
||||
t_data.Properties[property];
|
||||
|
||||
if (prop_data.IsField) {
|
||||
if (prop_data.IsField)
|
||||
{
|
||||
((FieldInfo)prop_data.Info).SetValue(
|
||||
instance, ReadValue(prop_data.Type, reader));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
PropertyInfo p_info =
|
||||
(PropertyInfo)prop_data.Info;
|
||||
|
||||
|
|
@ -445,7 +493,9 @@ namespace LitJson
|
|||
ReadValue(prop_data.Type, reader);
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!t_data.IsDictionary)
|
||||
throw new JsonException(String.Format(
|
||||
"The type {0} doesn't have the " +
|
||||
|
|
@ -494,7 +544,8 @@ namespace LitJson
|
|||
case JsonToken.ArrayStart:
|
||||
instance.SetJsonType(JsonType.Array);
|
||||
|
||||
while (true) {
|
||||
while (true)
|
||||
{
|
||||
IJsonWrapper item = ReadValue(factory, reader);
|
||||
if (item == null && reader.Token == JsonToken.ArrayEnd)
|
||||
break;
|
||||
|
|
@ -505,7 +556,8 @@ namespace LitJson
|
|||
case JsonToken.ObjectStart:
|
||||
instance.SetJsonType(JsonType.Object);
|
||||
|
||||
while (true) {
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.Token == JsonToken.ObjectEnd)
|
||||
break;
|
||||
|
|
@ -571,78 +623,52 @@ namespace LitJson
|
|||
|
||||
private static void RegisterBaseImporters()
|
||||
{
|
||||
ImporterFunc importer;
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToByte ((int) input);
|
||||
};
|
||||
ImporterFunc importer = input => Convert.ToByte((int)input);
|
||||
RegisterImporter(base_importers_table, typeof(int),
|
||||
typeof(byte), importer);
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToUInt64 ((int) input);
|
||||
};
|
||||
importer = input => Convert.ToUInt64((int)input);
|
||||
RegisterImporter(base_importers_table, typeof(int),
|
||||
typeof(ulong), importer);
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToSByte ((int) input);
|
||||
};
|
||||
importer = input => Convert.ToSByte((int)input);
|
||||
RegisterImporter(base_importers_table, typeof(int),
|
||||
typeof(sbyte), importer);
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToInt16 ((int) input);
|
||||
};
|
||||
importer = input => Convert.ToInt16((int)input);
|
||||
RegisterImporter(base_importers_table, typeof(int),
|
||||
typeof(short), importer);
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToUInt16 ((int) input);
|
||||
};
|
||||
importer = input => Convert.ToUInt16((int)input);
|
||||
RegisterImporter(base_importers_table, typeof(int),
|
||||
typeof(ushort), importer);
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToUInt32 ((int) input);
|
||||
};
|
||||
importer = input => Convert.ToUInt32((int)input);
|
||||
RegisterImporter(base_importers_table, typeof(int),
|
||||
typeof(uint), importer);
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToSingle ((int) input);
|
||||
};
|
||||
importer = input => Convert.ToSingle((int)input);
|
||||
RegisterImporter(base_importers_table, typeof(int),
|
||||
typeof(float), importer);
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToDouble ((int) input);
|
||||
};
|
||||
importer = input => Convert.ToDouble((int)input);
|
||||
RegisterImporter(base_importers_table, typeof(int),
|
||||
typeof(double), importer);
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToDecimal ((double) input);
|
||||
};
|
||||
importer = input => Convert.ToDecimal((double)input);
|
||||
RegisterImporter(base_importers_table, typeof(double),
|
||||
typeof(decimal), importer);
|
||||
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToUInt32 ((long) input);
|
||||
};
|
||||
importer = input => Convert.ToUInt32((long)input);
|
||||
RegisterImporter(base_importers_table, typeof(long),
|
||||
typeof(uint), importer);
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToChar ((string) input);
|
||||
};
|
||||
importer = input => Convert.ToChar((string)input);
|
||||
RegisterImporter(base_importers_table, typeof(string),
|
||||
typeof(char), importer);
|
||||
|
||||
importer = delegate (object input) {
|
||||
return Convert.ToDateTime ((string) input, datetime_format);
|
||||
};
|
||||
importer = input => Convert.ToDateTime((string)input, datetime_format);
|
||||
RegisterImporter(base_importers_table, typeof(string),
|
||||
typeof(DateTime), importer);
|
||||
}
|
||||
|
|
@ -667,49 +693,57 @@ namespace LitJson
|
|||
"trying to export from type {0}",
|
||||
obj.GetType()));
|
||||
|
||||
if (obj == null) {
|
||||
if (obj == null)
|
||||
{
|
||||
writer.Write(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is IJsonWrapper) {
|
||||
if (obj is IJsonWrapper wrapper)
|
||||
{
|
||||
if (writer_is_private)
|
||||
writer.TextWriter.Write (((IJsonWrapper) obj).ToJson ());
|
||||
writer.TextWriter.Write(wrapper.ToJson());
|
||||
else
|
||||
((IJsonWrapper) obj).ToJson (writer);
|
||||
wrapper.ToJson(writer);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is String) {
|
||||
writer.Write ((string) obj);
|
||||
if (obj is string s)
|
||||
{
|
||||
writer.Write(s);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is Double) {
|
||||
writer.Write ((double) obj);
|
||||
if (obj is double d)
|
||||
{
|
||||
writer.Write(d);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is Int32) {
|
||||
writer.Write ((int) obj);
|
||||
if (obj is int i)
|
||||
{
|
||||
writer.Write(i);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is Boolean) {
|
||||
writer.Write ((bool) obj);
|
||||
if (obj is bool b)
|
||||
{
|
||||
writer.Write(b);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is Int64) {
|
||||
writer.Write ((long) obj);
|
||||
if (obj is long l)
|
||||
{
|
||||
writer.Write(l);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is Array) {
|
||||
if (obj is Array array)
|
||||
{
|
||||
writer.WriteArrayStart();
|
||||
|
||||
foreach (object elem in (Array) obj)
|
||||
foreach (object elem in array)
|
||||
WriteValue(elem, writer, writer_is_private, depth + 1);
|
||||
|
||||
writer.WriteArrayEnd();
|
||||
|
|
@ -717,18 +751,21 @@ namespace LitJson
|
|||
return;
|
||||
}
|
||||
|
||||
if (obj is IList) {
|
||||
if (obj is IList list)
|
||||
{
|
||||
writer.WriteArrayStart();
|
||||
foreach (object elem in (IList) obj)
|
||||
foreach (object elem in list)
|
||||
WriteValue(elem, writer, writer_is_private, depth + 1);
|
||||
writer.WriteArrayEnd();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is IDictionary) {
|
||||
if (obj is IDictionary dictionary)
|
||||
{
|
||||
writer.WriteObjectStart();
|
||||
foreach (DictionaryEntry entry in (IDictionary) obj) {
|
||||
foreach (DictionaryEntry entry in dictionary)
|
||||
{
|
||||
writer.WritePropertyName((string)entry.Key);
|
||||
WriteValue(entry.Value, writer, writer_is_private,
|
||||
depth + 1);
|
||||
|
|
@ -741,7 +778,8 @@ namespace LitJson
|
|||
Type obj_type = obj.GetType();
|
||||
|
||||
// See if there's a custom exporter for the object
|
||||
if (custom_exporters_table.ContainsKey (obj_type)) {
|
||||
if (custom_exporters_table.ContainsKey(obj_type))
|
||||
{
|
||||
ExporterFunc exporter = custom_exporters_table[obj_type];
|
||||
exporter(obj, writer);
|
||||
|
||||
|
|
@ -749,7 +787,8 @@ namespace LitJson
|
|||
}
|
||||
|
||||
// If not, maybe there's a base exporter
|
||||
if (base_exporters_table.ContainsKey (obj_type)) {
|
||||
if (base_exporters_table.ContainsKey(obj_type))
|
||||
{
|
||||
ExporterFunc exporter = base_exporters_table[obj_type];
|
||||
exporter(obj, writer);
|
||||
|
||||
|
|
@ -757,7 +796,8 @@ namespace LitJson
|
|||
}
|
||||
|
||||
// Last option, let's see if it's an enum
|
||||
if (obj is Enum) {
|
||||
if (obj is Enum)
|
||||
{
|
||||
Type e_type = Enum.GetUnderlyingType(obj_type);
|
||||
|
||||
if (e_type == typeof(long)
|
||||
|
|
@ -776,16 +816,20 @@ namespace LitJson
|
|||
IList<PropertyMetadata> props = type_properties[obj_type];
|
||||
|
||||
writer.WriteObjectStart();
|
||||
foreach (PropertyMetadata p_data in props) {
|
||||
if (p_data.IsField) {
|
||||
foreach (PropertyMetadata p_data in props)
|
||||
{
|
||||
if (p_data.IsField)
|
||||
{
|
||||
writer.WritePropertyName(p_data.Info.Name);
|
||||
WriteValue(((FieldInfo)p_data.Info).GetValue(obj),
|
||||
writer, writer_is_private, depth + 1);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
PropertyInfo p_info = (PropertyInfo)p_data.Info;
|
||||
|
||||
if (p_info.CanRead) {
|
||||
if (p_info.CanRead)
|
||||
{
|
||||
writer.WritePropertyName(p_data.Info.Name);
|
||||
WriteValue(p_info.GetValue(obj, null),
|
||||
writer, writer_is_private, depth + 1);
|
||||
|
|
@ -799,7 +843,8 @@ namespace LitJson
|
|||
|
||||
public static string ToJson(object obj)
|
||||
{
|
||||
lock (static_writer_lock) {
|
||||
lock (static_writer_lock)
|
||||
{
|
||||
static_writer.Reset();
|
||||
|
||||
WriteValue(obj, static_writer, true, 0);
|
||||
|
|
@ -816,7 +861,7 @@ namespace LitJson
|
|||
public static JsonData ToObject(JsonReader reader)
|
||||
{
|
||||
return (JsonData)ToWrapper(
|
||||
delegate { return new JsonData (); }, reader);
|
||||
() => new JsonData(), reader);
|
||||
}
|
||||
|
||||
public static JsonData ToObject(TextReader reader)
|
||||
|
|
@ -824,13 +869,13 @@ namespace LitJson
|
|||
JsonReader json_reader = new JsonReader(reader);
|
||||
|
||||
return (JsonData)ToWrapper(
|
||||
delegate { return new JsonData (); }, json_reader);
|
||||
() => new JsonData(), json_reader);
|
||||
}
|
||||
|
||||
public static JsonData ToObject(string json)
|
||||
{
|
||||
return (JsonData)ToWrapper(
|
||||
delegate { return new JsonData (); }, json);
|
||||
() => new JsonData(), json);
|
||||
}
|
||||
|
||||
public static T ToObject<T>(JsonReader reader)
|
||||
|
|
@ -880,9 +925,7 @@ namespace LitJson
|
|||
ImporterFunc<TJson, TValue> importer)
|
||||
{
|
||||
ImporterFunc importer_wrapper =
|
||||
delegate (object input) {
|
||||
return importer ((TJson) input);
|
||||
};
|
||||
input => importer((TJson)input);
|
||||
|
||||
RegisterImporter(custom_importers_table, typeof(TJson),
|
||||
typeof(TValue), importer_wrapper);
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ namespace OpenMetaverse
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Color4) && this == (Color4)obj;
|
||||
return (obj is Color4 color4) && this == color4;
|
||||
}
|
||||
|
||||
public bool Equals(Color4 other)
|
||||
|
|
|
|||
|
|
@ -986,7 +986,7 @@ namespace OpenMetaverse
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Matrix4) ? this.Equals((Matrix4)obj) : false;
|
||||
return (obj is Matrix4 matrix4) && this.Equals(matrix4);
|
||||
}
|
||||
|
||||
public bool Equals(Matrix4 other)
|
||||
|
|
|
|||
|
|
@ -675,7 +675,7 @@ namespace OpenMetaverse
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Quaternion) ? this == (Quaternion)obj : false;
|
||||
return (obj is Quaternion quaternion) && this == quaternion;
|
||||
}
|
||||
|
||||
public bool Equals(Quaternion other)
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ namespace OpenMetaverse
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Vector2) ? this == ((Vector2)obj) : false;
|
||||
return (obj is Vector2 vector2) && this == vector2;
|
||||
}
|
||||
|
||||
public bool Equals(Vector2 other)
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ namespace OpenMetaverse
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Vector3d) ? this == (Vector3d)obj : false;
|
||||
return (obj is Vector3d v3d) && this == v3d;
|
||||
}
|
||||
|
||||
public bool Equals(Vector3d other)
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ namespace OpenMetaverse
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Vector4) ? this == (Vector4)obj : false;
|
||||
return (obj is Vector4 vector4) && this == vector4;
|
||||
}
|
||||
|
||||
public bool Equals(Vector4 other)
|
||||
|
|
|
|||
|
|
@ -110,13 +110,13 @@ namespace OpenMetaverse.Assets
|
|||
{
|
||||
// Right now we're nastily obtaining the UUID from the filename
|
||||
string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
|
||||
int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR);
|
||||
int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR, StringComparison.Ordinal);
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
Logger.Log(String.Format(
|
||||
"[OarFile]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping",
|
||||
assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR), Helpers.LogLevel.Warning);
|
||||
Logger.Log(
|
||||
$"[OarFile]: Could not find extension information in asset path {assetPath} since it's missing the separator " +
|
||||
$"{ArchiveConstants.ASSET_EXTENSION_SEPARATOR}. Skipping", Helpers.LogLevel.Warning);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace OpenMetaverse.Assets
|
|||
String text = Utils.BytesToString(AssetData);
|
||||
if (text.ToLower().Contains("callingcard version 2"))
|
||||
{
|
||||
AvatarID = new UUID(text.Substring(text.IndexOf("avatar_id") + 10, 36));
|
||||
AvatarID = new UUID(text.Substring(text.IndexOf("avatar_id", StringComparison.Ordinal) + 10, 36));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -75,9 +75,9 @@ namespace OpenMetaverse.Assets
|
|||
String text = Utils.BytesToString(AssetData);
|
||||
if (text.ToLower().Contains("landmark version 2"))
|
||||
{
|
||||
RegionID = new UUID(text.Substring(text.IndexOf("region_id") + 10, 36));
|
||||
RegionID = new UUID(text.Substring(text.IndexOf("region_id", StringComparison.Ordinal) + 10, 36));
|
||||
String vecDelim = " ";
|
||||
String[] vecStrings = text.Substring(text.IndexOf("local_pos") + 10).Split(vecDelim.ToCharArray());
|
||||
String[] vecStrings = text.Substring(text.IndexOf("local_pos", StringComparison.Ordinal) + 10).Split(vecDelim.ToCharArray());
|
||||
if (vecStrings.Length == 3)
|
||||
{
|
||||
Position = new Vector3(float.Parse(vecStrings[0], System.Globalization.CultureInfo.InvariantCulture), float.Parse(vecStrings[1], System.Globalization.CultureInfo.InvariantCulture), float.Parse(vecStrings[2], System.Globalization.CultureInfo.InvariantCulture));
|
||||
|
|
|
|||
|
|
@ -342,11 +342,11 @@ namespace OpenMetaverse.Assets
|
|||
}
|
||||
else if (key == "name")
|
||||
{
|
||||
name = val.Remove(val.LastIndexOf("|"));
|
||||
name = val.Remove(val.LastIndexOf("|", StringComparison.Ordinal));
|
||||
}
|
||||
else if (key == "desc")
|
||||
{
|
||||
description = val.Remove(val.LastIndexOf("|"));
|
||||
description = val.Remove(val.LastIndexOf("|", StringComparison.Ordinal));
|
||||
}
|
||||
else if (key == "creation_date")
|
||||
{
|
||||
|
|
@ -388,7 +388,7 @@ namespace OpenMetaverse.Assets
|
|||
{
|
||||
BodyText += lines[i++] + "\n";
|
||||
}
|
||||
BodyText = BodyText.Remove(BodyText.LastIndexOf("}"));
|
||||
BodyText = BodyText.Remove(BodyText.LastIndexOf("}", StringComparison.Ordinal));
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -129,8 +129,8 @@ namespace OpenMetaverse
|
|||
/// <returns></returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is GridRegion)
|
||||
return Equals((GridRegion)obj);
|
||||
if (obj is GridRegion region)
|
||||
return Equals(region);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
|
@ -811,7 +811,8 @@ namespace OpenMetaverse
|
|||
}
|
||||
|
||||
// find stale entries (people who left the sim)
|
||||
List<UUID> removedEntries = e.Simulator.avatarPositions.FindAll(delegate(UUID findID) { return !coarseEntries.ContainsKey(findID); });
|
||||
List<UUID> removedEntries = e.Simulator.avatarPositions.FindAll(
|
||||
findID => !coarseEntries.ContainsKey(findID));
|
||||
|
||||
// anyone who was not listed in the previous update
|
||||
List<UUID> newEntries = new List<UUID>();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace OpenMetaverse.Messages
|
|||
|
||||
public static OSD FromIP(IPAddress address)
|
||||
{
|
||||
if (address != null && address != IPAddress.Any)
|
||||
if (address != null && !Equals(address, IPAddress.Any))
|
||||
return OSD.FromBinary(address.GetAddressBytes());
|
||||
else
|
||||
return new OSD();
|
||||
|
|
|
|||
|
|
@ -284,7 +284,8 @@ namespace OpenMetaverse
|
|||
/// </summary>
|
||||
/// <param name="e">A ParticleUpdateEventArgs object containing
|
||||
/// the data sent from the simulator</param>
|
||||
protected virtual void OnParticleUpdate(ParticleUpdateEventArgs e) {
|
||||
protected virtual void OnParticleUpdate(ParticleUpdateEventArgs e)
|
||||
{
|
||||
EventHandler<ParticleUpdateEventArgs> handler = m_ParticleUpdate;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
|
|
@ -305,7 +306,8 @@ namespace OpenMetaverse
|
|||
#endregion AvatarUpdate event
|
||||
|
||||
#region TerseObjectUpdate event
|
||||
public event EventHandler<ParticleUpdateEventArgs> ParticleUpdate {
|
||||
public event EventHandler<ParticleUpdateEventArgs> ParticleUpdate
|
||||
{
|
||||
add { lock (m_ParticleUpdateLock) { m_ParticleUpdate += value; } }
|
||||
remove { lock (m_ParticleUpdateLock) { m_ParticleUpdate -= value; } }
|
||||
}
|
||||
|
|
@ -1685,7 +1687,9 @@ namespace OpenMetaverse
|
|||
{
|
||||
ObjectMediaNavigateMessage req = new ObjectMediaNavigateMessage
|
||||
{
|
||||
PrimID = primID, URL = newURL, Face = face
|
||||
PrimID = primID,
|
||||
URL = newURL,
|
||||
Face = face
|
||||
};
|
||||
|
||||
request.OnComplete += (client, result, error) =>
|
||||
|
|
@ -1759,13 +1763,11 @@ namespace OpenMetaverse
|
|||
ObjectMediaMessage msg = new ObjectMediaMessage();
|
||||
msg.Deserialize((OSDMap)result);
|
||||
|
||||
if (msg.Request is ObjectMediaResponse)
|
||||
if (msg.Request is ObjectMediaResponse response)
|
||||
{
|
||||
ObjectMediaResponse response = (ObjectMediaResponse)msg.Request;
|
||||
|
||||
if (Client.Settings.OBJECT_TRACKING)
|
||||
{
|
||||
Primitive prim = sim.ObjectsPrimitives.Find((Primitive p) => { return p.ID == primID; });
|
||||
Primitive prim = sim.ObjectsPrimitives.Find((Primitive p) => p.ID == primID);
|
||||
if (prim != null)
|
||||
{
|
||||
prim.MediaVersion = response.Version;
|
||||
|
|
@ -2117,7 +2119,8 @@ namespace OpenMetaverse
|
|||
{ handler(this, new PrimEventArgs(simulator, prim, update.RegionData.TimeDilation, isNewObject, attachment)); });
|
||||
}
|
||||
//OnParticleUpdate handler replacing decode particles, PCode.Particle system appears to be deprecated this is a fix
|
||||
if (prim.ParticleSys.PartMaxAge != 0) {
|
||||
if (prim.ParticleSys.PartMaxAge != 0)
|
||||
{
|
||||
OnParticleUpdate(new ParticleUpdateEventArgs(simulator, prim.ParticleSys, prim));
|
||||
}
|
||||
|
||||
|
|
@ -2626,7 +2629,7 @@ namespace OpenMetaverse
|
|||
catch (IndexOutOfRangeException ex)
|
||||
{
|
||||
Logger.Log("Error decoding an ObjectUpdateCompressed packet", Helpers.LogLevel.Warning, Client, ex);
|
||||
Logger.Log(block.ToString(), Helpers.LogLevel.Warning); // ? Might want to look into what .ToString here returns
|
||||
Logger.Log(block.ToString(), Helpers.LogLevel.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2808,7 +2811,7 @@ namespace OpenMetaverse
|
|||
if (Client.Settings.OBJECT_TRACKING)
|
||||
{
|
||||
Primitive findPrim = simulator.ObjectsPrimitives.Find(
|
||||
delegate(Primitive prim) { return prim.ID == props.ObjectID; });
|
||||
prim => prim.ID == props.ObjectID);
|
||||
|
||||
if (findPrim != null)
|
||||
{
|
||||
|
|
@ -2858,7 +2861,7 @@ namespace OpenMetaverse
|
|||
if (Client.Settings.OBJECT_TRACKING)
|
||||
{
|
||||
Primitive findPrim = simulator.ObjectsPrimitives.Find(
|
||||
delegate(Primitive prim) { return prim.ID == op.ObjectData.ObjectID; });
|
||||
prim => prim.ID == op.ObjectData.ObjectID);
|
||||
|
||||
if (findPrim != null)
|
||||
{
|
||||
|
|
@ -3472,7 +3475,8 @@ namespace OpenMetaverse
|
|||
}
|
||||
}
|
||||
|
||||
public class ParticleUpdateEventArgs : EventArgs {
|
||||
public class ParticleUpdateEventArgs : EventArgs
|
||||
{
|
||||
private readonly Simulator m_Simulator;
|
||||
private readonly Primitive.ParticleSystem m_ParticleSystem;
|
||||
private readonly Primitive m_Source;
|
||||
|
|
@ -3490,7 +3494,8 @@ namespace OpenMetaverse
|
|||
/// <param name="simulator">The simulator the packet originated from</param>
|
||||
/// <param name="particlesystem">The ParticleSystem data</param>
|
||||
/// <param name="source">The Primitive source</param>
|
||||
public ParticleUpdateEventArgs(Simulator simulator, Primitive.ParticleSystem particlesystem, Primitive source) {
|
||||
public ParticleUpdateEventArgs(Simulator simulator, Primitive.ParticleSystem particlesystem, Primitive source)
|
||||
{
|
||||
this.m_Simulator = simulator;
|
||||
this.m_ParticleSystem = particlesystem;
|
||||
this.m_Source = source;
|
||||
|
|
|
|||
|
|
@ -771,8 +771,8 @@ namespace OpenMetaverse.Packets
|
|||
private static string DecodeNameValue(string fieldName, object fieldData)
|
||||
{
|
||||
NameValue[] nameValues = null;
|
||||
if (fieldData is NameValue[])
|
||||
nameValues = fieldData as NameValue[];
|
||||
if (fieldData is NameValue[] data)
|
||||
nameValues = data;
|
||||
else
|
||||
{
|
||||
string nameValue = Utils.BytesToString((byte[])fieldData);
|
||||
|
|
@ -1024,12 +1024,12 @@ namespace OpenMetaverse.Packets
|
|||
|
||||
private static string DecodeTimeStamp(string fieldName, object fieldData)
|
||||
{
|
||||
if (fieldData is Int32 && (int) fieldData > 0)
|
||||
if (fieldData is int data && data > 0)
|
||||
return
|
||||
$"{fieldName,30}: {fieldData,-10} {"(" + Utils.UnixTimeToDateTime((int) fieldData) + ")",-29} [{fieldData.GetType().Name}]";
|
||||
else if (fieldData is uint && (uint) fieldData > 0)
|
||||
$"{fieldName,30}: {data,-10} {"(" + Utils.UnixTimeToDateTime(data) + ")",-29} [{data.GetType().Name}]";
|
||||
else if (fieldData is uint u && u > 0)
|
||||
return
|
||||
$"{fieldName,30}: {fieldData,-10} {"(" + Utils.UnixTimeToDateTime((uint) fieldData) + ")",-29} [{fieldData.GetType().Name}]";
|
||||
$"{fieldName,30}: {u,-10} {"(" + Utils.UnixTimeToDateTime(u) + ")",-29} [{u.GetType().Name}]";
|
||||
else
|
||||
return $"{fieldName,30}: {fieldData,-40} [{fieldData.GetType().Name}]";
|
||||
}
|
||||
|
|
@ -1272,8 +1272,8 @@ namespace OpenMetaverse.Packets
|
|||
private static string DecodeTextureEntry(string fieldName, object fieldData)
|
||||
{
|
||||
Primitive.TextureEntry te;
|
||||
if (fieldData is Primitive.TextureEntry)
|
||||
te = (Primitive.TextureEntry) fieldData;
|
||||
if (fieldData is Primitive.TextureEntry data)
|
||||
te = data;
|
||||
else
|
||||
{
|
||||
byte[] tebytes = (byte[])fieldData;
|
||||
|
|
@ -1622,9 +1622,8 @@ namespace OpenMetaverse.Packets
|
|||
string[] keyList = { decoderKey, decoderKey.Replace("Packet", ""), keys[1] + "." + keys[2], keys[2] };
|
||||
foreach (string key in keyList)
|
||||
{
|
||||
if (fieldData is byte[])
|
||||
if (fieldData is byte[] fd)
|
||||
{
|
||||
byte[] fd = (byte[]) fieldData;
|
||||
if (!(fd.Length > 0))
|
||||
{
|
||||
// bypass the decoder since we were passed an empty byte array
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ namespace OpenMetaverse
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Permissions) && this == (Permissions)obj;
|
||||
return (obj is Permissions permissions) && this == permissions;
|
||||
}
|
||||
|
||||
public bool Equals(Permissions other)
|
||||
|
|
|
|||
|
|
@ -548,12 +548,12 @@ namespace OpenMetaverse.Rendering
|
|||
/// <returns>A standard .Net string</returns>
|
||||
public static string TrimAt0(string s)
|
||||
{
|
||||
int pos = s.IndexOf("\0");
|
||||
int pos = s.IndexOf("\0", StringComparison.Ordinal);
|
||||
|
||||
if (pos >= 0)
|
||||
return s.Substring(0, pos);
|
||||
|
||||
return s;
|
||||
return pos >= 0 ? s.Substring(0, pos) : s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue