diff --git a/LibreMetaverse.GUI/FriendList.cs b/LibreMetaverse.GUI/FriendList.cs index 7403383d..aea99956 100644 --- a/LibreMetaverse.GUI/FriendList.cs +++ b/LibreMetaverse.GUI/FriendList.cs @@ -116,7 +116,7 @@ namespace OpenMetaverse.GUI { string key = friend.UUID.ToString(); string onlineText; - string name = friend.Name == null ? "(loading...)" : friend.Name; + string name = friend.Name ?? "(loading...)"; int image; Color color; diff --git a/LibreMetaverse.GUI/MiniMap.cs b/LibreMetaverse.GUI/MiniMap.cs index e3dd8bac..3d36924f 100644 --- a/LibreMetaverse.GUI/MiniMap.cs +++ b/LibreMetaverse.GUI/MiniMap.cs @@ -147,7 +147,7 @@ namespace OpenMetaverse.GUI Pen penColor; Brush brushColor; - if (Client.Network.CurrentSim.ObjectsAvatars.Find(delegate(Avatar av) { return av.ID == coarse.Key; }) != null) + if (Client.Network.CurrentSim.ObjectsAvatars.Find(av => av.ID == coarse.Key) != null) { brushColor = Brushes.PaleGreen; penColor = Pens.Green; diff --git a/LibreMetaverse.StructuredData/JSON/JsonMapper.cs b/LibreMetaverse.StructuredData/JSON/JsonMapper.cs index bd1e0076..975fcf3d 100644 --- a/LibreMetaverse.StructuredData/JSON/JsonMapper.cs +++ b/LibreMetaverse.StructuredData/JSON/JsonMapper.cs @@ -571,78 +571,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); } @@ -816,7 +790,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 +798,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 (JsonReader reader) @@ -880,9 +854,7 @@ namespace LitJson ImporterFunc 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); diff --git a/LibreMetaverse/GridManager.cs b/LibreMetaverse/GridManager.cs index b6d61e69..78e313a3 100644 --- a/LibreMetaverse/GridManager.cs +++ b/LibreMetaverse/GridManager.cs @@ -811,7 +811,8 @@ namespace OpenMetaverse } // find stale entries (people who left the sim) - List removedEntries = e.Simulator.avatarPositions.FindAll(delegate(UUID findID) { return !coarseEntries.ContainsKey(findID); }); + List removedEntries = e.Simulator.avatarPositions.FindAll( + findID => !coarseEntries.ContainsKey(findID)); // anyone who was not listed in the previous update List newEntries = new List(); diff --git a/LibreMetaverse/ObjectManager.cs b/LibreMetaverse/ObjectManager.cs index e611cdc4..f6829f4e 100644 --- a/LibreMetaverse/ObjectManager.cs +++ b/LibreMetaverse/ObjectManager.cs @@ -1763,7 +1763,7 @@ namespace OpenMetaverse { 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; @@ -2806,7 +2806,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) { @@ -2856,7 +2856,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) { diff --git a/Programs/examples/TestClient/Commands/Agent/TouchCommand.cs b/Programs/examples/TestClient/Commands/Agent/TouchCommand.cs index 9b3fad3d..eb767cdd 100644 --- a/Programs/examples/TestClient/Commands/Agent/TouchCommand.cs +++ b/Programs/examples/TestClient/Commands/Agent/TouchCommand.cs @@ -25,10 +25,7 @@ namespace OpenMetaverse.TestClient if (UUID.TryParse(args[0], out target)) { Primitive targetPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find( - delegate(Primitive prim) - { - return prim.ID == target; - } + prim => prim.ID == target ); if (targetPrim != null) diff --git a/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs b/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs index e3f08d7d..c7fdf5dd 100644 --- a/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs +++ b/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs @@ -22,7 +22,7 @@ namespace OpenMetaverse.TestClient.Commands.Appearance string targetName = String.Format("{0} {1}", args[0], args[1]); Avatar foundAv = Client.Network.CurrentSim.ObjectsAvatars.Find( - delegate(Avatar avatar) { return (avatar.Name == targetName); } + avatar => (avatar.Name == targetName) ); if (foundAv != null) diff --git a/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs b/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs index 68165e7a..54cefb0e 100644 --- a/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs @@ -305,10 +305,7 @@ namespace OpenMetaverse.TestClient lock (CurrentDownloads) { // see if we have this in our transfer list - QueuedDownloadInfo r = CurrentDownloads.Find(delegate(QueuedDownloadInfo q) - { - return q.AssetID == asset.AssetID; - }); + QueuedDownloadInfo r = CurrentDownloads.Find(q => q.AssetID == asset.AssetID); if (r != null && r.AssetID == asset.AssetID) { diff --git a/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs b/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs index 3853b778..26bcf6f3 100644 --- a/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs @@ -35,10 +35,7 @@ namespace OpenMetaverse.TestClient for (int i = 0; i < Client.Network.Simulators.Count; i++) { Avatar targetAv = Client.Network.Simulators[i].ObjectsAvatars.Find( - delegate(Avatar avatar) - { - return avatar.ID == target; - } + avatar => avatar.ID == target ); if (targetAv != null) diff --git a/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs b/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs index 8df7543a..5eda450a 100644 --- a/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs @@ -23,7 +23,7 @@ namespace OpenMetaverse.TestClient if (!UUID.TryParse(args[0], out objectID)) return "Usage: objectinventory [objectID]"; - Primitive found = Client.Network.CurrentSim.ObjectsPrimitives.Find(delegate(Primitive prim) { return prim.ID == objectID; }); + Primitive found = Client.Network.CurrentSim.ObjectsPrimitives.Find(prim => prim.ID == objectID); if (found != null) objectLocalID = found.LocalID; else diff --git a/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs b/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs index 82e7e51c..5181e8b1 100644 --- a/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs @@ -25,11 +25,11 @@ namespace OpenMetaverse.TestClient if (!UUID.TryParse(args[0], out objectID)) return "Usage: taskrunning objectID [[scriptName] true|false]"; - Primitive found = Client.Network.CurrentSim.ObjectsPrimitives.Find(delegate(Primitive prim) { return prim.ID == objectID; }); + Primitive found = Client.Network.CurrentSim.ObjectsPrimitives.Find(prim => prim.ID == objectID); if (found != null) objectLocalID = found.LocalID; else - return String.Format("Couldn't find prim {0}", objectID); + return $"Couldn't find prim {objectID}"; List items = Client.Inventory.GetTaskInventory(objectID, objectLocalID, 1000 * 30); diff --git a/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs b/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs index da4f6c4e..1fb279eb 100644 --- a/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs @@ -51,10 +51,7 @@ namespace OpenMetaverse.TestClient for (int i = 0; i < Client.Network.Simulators.Count; i++) { Avatar target = Client.Network.Simulators[i].ObjectsAvatars.Find( - delegate(Avatar avatar) - { - return avatar.Name == name; - } + avatar => avatar.Name == name ); if (target != null) diff --git a/Programs/examples/TestClient/Commands/Movement/SitOnCommand.cs b/Programs/examples/TestClient/Commands/Movement/SitOnCommand.cs index 452e21ce..72d2fdd5 100644 --- a/Programs/examples/TestClient/Commands/Movement/SitOnCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/SitOnCommand.cs @@ -25,10 +25,7 @@ namespace OpenMetaverse.TestClient if (UUID.TryParse(args[0], out target)) { Primitive targetPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find( - delegate(Primitive prim) - { - return prim.ID == target; - } + prim => prim.ID == target ); if (targetPrim != null) diff --git a/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs b/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs index 490e0248..e93ac9fc 100644 --- a/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs @@ -61,7 +61,7 @@ namespace OpenMetaverse.TestClient Logger.DebugLog("Using PermissionMask: " + Perms.ToString(), Client); // Find the requested prim - rootPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(delegate(Primitive prim) { return prim.ID == rootID; }); + rootPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(prim => prim.ID == rootID); if (rootPrim == null) return "Cannot find requested prim " + rootID.ToString(); else @@ -77,7 +77,7 @@ namespace OpenMetaverse.TestClient } // Find all of the child objects linked to this root - childPrims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(delegate(Primitive prim) { return prim.ParentID == rootPrim.LocalID; }); + childPrims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(prim => prim.ParentID == rootPrim.LocalID); // Build a dictionary of primitives for referencing later Objects[rootPrim.ID] = rootPrim; diff --git a/Programs/examples/TestClient/Commands/Prims/DeRezObjectCommand.cs b/Programs/examples/TestClient/Commands/Prims/DeRezObjectCommand.cs index 6258cf25..ab733eb8 100644 --- a/Programs/examples/TestClient/Commands/Prims/DeRezObjectCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/DeRezObjectCommand.cs @@ -22,7 +22,7 @@ namespace OpenMetaverse.TestClient if (UUID.TryParse(args[0], out primID)) { Primitive target = Client.Network.CurrentSim.ObjectsPrimitives.Find( - delegate(Primitive prim) { return prim.ID == primID; } + prim => prim.ID == primID ); if (target != null) diff --git a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs index 30586501..cc2a2cfd 100644 --- a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs @@ -64,15 +64,12 @@ namespace OpenMetaverse.TestClient Primitive exportPrim; exportPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find( - delegate(Primitive prim) { return prim.ID == id; } + prim => prim.ID == id ); if (exportPrim != null) { - if (exportPrim.ParentID != 0) - localid = exportPrim.ParentID; - else - localid = exportPrim.LocalID; + localid = exportPrim.ParentID != 0 ? exportPrim.ParentID : exportPrim.LocalID; // Check for export permission first Client.Objects.RequestObjectPropertiesFamily(Client.Network.CurrentSim, id); diff --git a/Programs/examples/TestClient/Commands/Prims/ExportParticlesCommand.cs b/Programs/examples/TestClient/Commands/Prims/ExportParticlesCommand.cs index 68ea0ed1..32dca5d5 100644 --- a/Programs/examples/TestClient/Commands/Prims/ExportParticlesCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ExportParticlesCommand.cs @@ -26,13 +26,10 @@ namespace OpenMetaverse.TestClient lock (Client.Network.Simulators) { - for (int i = 0; i < Client.Network.Simulators.Count; i++) + foreach (var sim in Client.Network.Simulators) { - Primitive exportPrim = Client.Network.Simulators[i].ObjectsPrimitives.Find( - delegate(Primitive prim) - { - return prim.ID == id; - } + Primitive exportPrim = sim.ObjectsPrimitives.Find( + prim => prim.ID == id ); if (exportPrim != null) diff --git a/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs b/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs index 6a50961c..d02a3797 100644 --- a/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs @@ -47,8 +47,8 @@ namespace OpenMetaverse.TestClient foreach (Primitive p in prims) { - string name = p.Properties != null ? p.Properties.Name : null; - if (String.IsNullOrEmpty(searchString) || ((name != null) && (name.Contains(searchString)))) + string name = p.Properties?.Name; + if (string.IsNullOrEmpty(searchString) || ((name != null) && (name.Contains(searchString)))) Console.WriteLine("Object '{0}': {1}", name, p.ID.ToString()); } diff --git a/Programs/examples/TestClient/Commands/Prims/FindTextureCommand.cs b/Programs/examples/TestClient/Commands/Prims/FindTextureCommand.cs index e843f0cb..a295c821 100644 --- a/Programs/examples/TestClient/Commands/Prims/FindTextureCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/FindTextureCommand.cs @@ -27,7 +27,7 @@ namespace OpenMetaverse.TestClient Client.Network.CurrentSim.ObjectsPrimitives.ForEach( delegate(Primitive prim) { - if (prim.Textures != null && prim.Textures.FaceTextures[faceIndex] != null) + if (prim.Textures?.FaceTextures[faceIndex] != null) { if (prim.Textures.FaceTextures[faceIndex].TextureID == textureID) { diff --git a/Programs/examples/TestClient/Commands/Prims/PrimInfoCommand.cs b/Programs/examples/TestClient/Commands/Prims/PrimInfoCommand.cs index 675933de..bfb0d7a6 100644 --- a/Programs/examples/TestClient/Commands/Prims/PrimInfoCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/PrimInfoCommand.cs @@ -23,7 +23,7 @@ namespace OpenMetaverse.TestClient if (UUID.TryParse(args[0], out primID)) { Primitive target = Client.Network.CurrentSim.ObjectsPrimitives.Find( - delegate(Primitive prim) { return prim.ID == primID; } + prim => prim.ID == primID ); if (target != null) diff --git a/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs b/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs index 38064a21..9eda35de 100644 --- a/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs +++ b/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs @@ -26,10 +26,7 @@ namespace OpenMetaverse.TestClient for (int i = 0; i < Client.Network.Simulators.Count; i++) { Avatar master = Client.Network.Simulators[i].ObjectsAvatars.Find( - delegate(Avatar avatar) - { - return avatar.ID == Client.MasterKey; - } + avatar => avatar.ID == Client.MasterKey ); if (master != null)