diff --git a/Programs/examples/TestClient/ClientManager.cs b/Programs/examples/TestClient/ClientManager.cs index f431eb73..a3a0daff 100644 --- a/Programs/examples/TestClient/ClientManager.cs +++ b/Programs/examples/TestClient/ClientManager.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading; namespace OpenMetaverse.TestClient @@ -128,8 +129,7 @@ namespace OpenMetaverse.TestClient } // Otherwise, use the center of the named region - if (account.StartLocation == null) - account.StartLocation = NetworkManager.StartLocation(args[3], 128, 128, 40); + account.StartLocation ??= NetworkManager.StartLocation(args[3], 128, 128, 40); } } @@ -256,10 +256,9 @@ namespace OpenMetaverse.TestClient } } - foreach (GridClient client in Clients.Values) + foreach (var client in Clients.Values.Cast().Where(client => client.Network.Connected)) { - if (client.Network.Connected) - client.Network.Logout(); + client.Network.Logout(); } } @@ -268,12 +267,7 @@ namespace OpenMetaverse.TestClient /// private void PrintPrompt() { - int online = 0; - - foreach (GridClient client in Clients.Values) - { - if (client.Network.Connected) online++; - } + int online = Clients.Values.Cast().Count(client => client.Network.Connected); Console.Write($"{online} avatars online> "); } @@ -288,7 +282,7 @@ namespace OpenMetaverse.TestClient { if (cmd == null) return; - string[] tokens = cmd.Trim().Split(new char[] { ' ', '\t' }); + string[] tokens = cmd.Trim().Split(' ', '\t'); if (tokens.Length == 0) return; @@ -301,21 +295,15 @@ namespace OpenMetaverse.TestClient return; if ('@' == firstToken[0]) { - onlyAvatar = String.Empty; + onlyAvatar = string.Empty; if (tokens.Length == 3) { - bool found = false; onlyAvatar = tokens[1]+" "+tokens[2]; - foreach (TestClient client in Clients.Values) { - if ((client.ToString() == onlyAvatar) && (client.Network.Connected)) { - found = true; - break; - } - } - if (found) { - Logger.Log($"Commanding only {onlyAvatar} now", Helpers.LogLevel.Info); - } else { - Logger.Log($"Commanding nobody now. Avatar {onlyAvatar} is offline", Helpers.LogLevel.Info); - } + bool found = Clients.Values.Any(client => (client.ToString() == onlyAvatar) && (client.Network.Connected)); + + Logger.Log( + found + ? $"Commanding only {onlyAvatar} now" + : $"Commanding nobody now. Avatar {onlyAvatar} is offline", Helpers.LogLevel.Info); } else { Logger.Log("Commanding all avatars now", Helpers.LogLevel.Info); } diff --git a/Programs/examples/TestClient/Command.cs b/Programs/examples/TestClient/Command.cs index 38fd266b..8ac3f5be 100644 --- a/Programs/examples/TestClient/Command.cs +++ b/Programs/examples/TestClient/Command.cs @@ -2,7 +2,7 @@ using System; namespace OpenMetaverse.TestClient { - public enum CommandCategory : int + public enum CommandCategory { Parcel, Appearance, diff --git a/Programs/examples/TestClient/Commands/Agent/BotsCommand.cs b/Programs/examples/TestClient/Commands/Agent/BotsCommand.cs index eb9061f6..f06005aa 100644 --- a/Programs/examples/TestClient/Commands/Agent/BotsCommand.cs +++ b/Programs/examples/TestClient/Commands/Agent/BotsCommand.cs @@ -13,9 +13,9 @@ namespace OpenMetaverse.TestClient Name = "bots"; Description = "detects avatars that appear to be bots."; Category = CommandCategory.Other; - testClient.Avatars.ViewerEffect += new EventHandler(Avatars_ViewerEffect); - testClient.Avatars.ViewerEffectLookAt += new EventHandler(Avatars_ViewerEffectLookAt); - testClient.Avatars.ViewerEffectPointAt += new EventHandler(Avatars_ViewerEffectPointAt); + testClient.Avatars.ViewerEffect += Avatars_ViewerEffect; + testClient.Avatars.ViewerEffectLookAt += Avatars_ViewerEffectLookAt; + testClient.Avatars.ViewerEffectPointAt += Avatars_ViewerEffectPointAt; } private void Avatars_ViewerEffectPointAt(object sender, ViewerEffectPointAtEventArgs e) diff --git a/Programs/examples/TestClient/Commands/Agent/CloneProfileCommand.cs b/Programs/examples/TestClient/Commands/Agent/CloneProfileCommand.cs index 60e63ef1..c20a2925 100644 --- a/Programs/examples/TestClient/Commands/Agent/CloneProfileCommand.cs +++ b/Programs/examples/TestClient/Commands/Agent/CloneProfileCommand.cs @@ -16,12 +16,12 @@ namespace OpenMetaverse.TestClient public CloneProfileCommand(TestClient testClient) { - testClient.Avatars.AvatarInterestsReply += new EventHandler(Avatars_AvatarInterestsReply); - testClient.Avatars.AvatarPropertiesReply += new EventHandler(Avatars_AvatarPropertiesReply); - testClient.Avatars.AvatarGroupsReply += new EventHandler(Avatars_AvatarGroupsReply); - testClient.Groups.GroupJoinedReply += new EventHandler(Groups_OnGroupJoined); - testClient.Avatars.AvatarPicksReply += new EventHandler(Avatars_AvatarPicksReply); - testClient.Avatars.PickInfoReply += new EventHandler(Avatars_PickInfoReply); + testClient.Avatars.AvatarInterestsReply += Avatars_AvatarInterestsReply; + testClient.Avatars.AvatarPropertiesReply += Avatars_AvatarPropertiesReply; + testClient.Avatars.AvatarGroupsReply += Avatars_AvatarGroupsReply; + testClient.Groups.GroupJoinedReply += Groups_OnGroupJoined; + testClient.Avatars.AvatarPicksReply += Avatars_AvatarPicksReply; + testClient.Avatars.PickInfoReply += Avatars_PickInfoReply; Name = "cloneprofile"; Description = "Clones another avatars profile as closely as possible. WARNING: This command will " + @@ -76,17 +76,17 @@ namespace OpenMetaverse.TestClient Client.Groups.RequestJoinGroup(groupID); } - return "Synchronized our profile to the profile of " + targetID.ToString(); + return "Synchronized our profile to the profile of " + targetID; } void Groups_OnGroupJoined(object sender, GroupOperationEventArgs e) { - Console.WriteLine(Client.ToString() + (e.Success ? " joined " : " failed to join ") + - e.GroupID.ToString()); + Console.WriteLine(Client + (e.Success ? " joined " : " failed to join ") + + e.GroupID); if (e.Success) { - Console.WriteLine(Client.ToString() + " setting " + e.GroupID.ToString() + + Console.WriteLine(Client + " setting " + e.GroupID + " as the active group"); Client.Groups.ActivateGroup(e.GroupID); } diff --git a/Programs/examples/TestClient/Commands/Agent/GenericMessageCommand.cs b/Programs/examples/TestClient/Commands/Agent/GenericMessageCommand.cs index 7e855786..708fcece 100644 --- a/Programs/examples/TestClient/Commands/Agent/GenericMessageCommand.cs +++ b/Programs/examples/TestClient/Commands/Agent/GenericMessageCommand.cs @@ -22,30 +22,37 @@ namespace OpenMetaverse.TestClient string methodName = args[0]; - GenericMessagePacket gmp = new GenericMessagePacket(); - - gmp.AgentData.AgentID = Client.Self.AgentID; - gmp.AgentData.SessionID = Client.Self.SessionID; - gmp.AgentData.TransactionID = UUID.Zero; - - gmp.MethodData.Method = Utils.StringToBytes(methodName); - gmp.MethodData.Invoice = UUID.Zero; - - gmp.ParamList = new GenericMessagePacket.ParamListBlock[args.Length - 1]; + GenericMessagePacket gmp = new GenericMessagePacket + { + AgentData = + { + AgentID = Client.Self.AgentID, + SessionID = Client.Self.SessionID, + TransactionID = UUID.Zero + }, + MethodData = + { + Method = Utils.StringToBytes(methodName), + Invoice = UUID.Zero + }, + ParamList = new GenericMessagePacket.ParamListBlock[args.Length - 1] + }; StringBuilder sb = new StringBuilder(); for (int i = 1; i < args.Length; i++) { - GenericMessagePacket.ParamListBlock paramBlock = new GenericMessagePacket.ParamListBlock(); - paramBlock.Parameter = Utils.StringToBytes(args[i]); + GenericMessagePacket.ParamListBlock paramBlock = new GenericMessagePacket.ParamListBlock + { + Parameter = Utils.StringToBytes(args[i]) + }; gmp.ParamList[i - 1] = paramBlock; sb.AppendFormat(" {0}", args[i]); } Client.Network.SendPacket(gmp); - return string.Format("Sent generic message with method {0}, params{1}", methodName, sb); + return $"Sent generic message with method {methodName}, params{sb}"; } } } \ No newline at end of file diff --git a/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs b/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs index b33c7045..7aa40686 100644 --- a/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs +++ b/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs @@ -16,7 +16,7 @@ namespace OpenMetaverse.TestClient private string Usage() { - String usage = "Usage:\n" + + string usage = "Usage:\n" + "\tplay list - list the built in animations\n" + "\tplay show - show any currently playing animations\n" + "\tplay UUID - play an animation asset\n" + diff --git a/Programs/examples/TestClient/Commands/Appearance/AttachmentsCommand.cs b/Programs/examples/TestClient/Commands/Appearance/AttachmentsCommand.cs index 87e251a4..b87a4a70 100644 --- a/Programs/examples/TestClient/Commands/Appearance/AttachmentsCommand.cs +++ b/Programs/examples/TestClient/Commands/Appearance/AttachmentsCommand.cs @@ -19,14 +19,13 @@ namespace OpenMetaverse.TestClient prim => prim.ParentID == Client.Self.LocalID ); - for (int i = 0; i < attachments.Count; i++) + foreach (var prim in attachments) { - Primitive prim = attachments[i]; AttachmentPoint point = StateToAttachmentPoint(prim.PrimData.State); // TODO: Fetch properties for the objects with missing property sets so we can show names - Logger.Log(String.Format("[Attachment @ {0}] LocalID: {1} UUID: {2} Offset: {3}", - point, prim.LocalID, prim.ID, prim.Position), Helpers.LogLevel.Info, Client); + Logger.Log($"[Attachment @ {point}] LocalID: {prim.LocalID} UUID: {prim.ID} Offset: {prim.Position}", + Helpers.LogLevel.Info, Client); } return "Found " + attachments.Count + " attachments"; diff --git a/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs b/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs index d09f441a..2dbf1852 100644 --- a/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs +++ b/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs @@ -17,7 +17,7 @@ namespace OpenMetaverse.TestClient.Commands.Appearance if (args.Length != 2) return "Usage: avatarinfo [firstname] [lastname]"; - string targetName = String.Format("{0} {1}", args[0], args[1]); + string targetName = $"{args[0]} {args[1]}"; Avatar foundAv = Client.Network.CurrentSim.ObjectsAvatars.Find( avatar => (avatar.Name == targetName) diff --git a/Programs/examples/TestClient/Commands/Appearance/CloneCommand.cs b/Programs/examples/TestClient/Commands/Appearance/CloneCommand.cs index dbb3b451..cfe4c3cc 100644 --- a/Programs/examples/TestClient/Commands/Appearance/CloneCommand.cs +++ b/Programs/examples/TestClient/Commands/Appearance/CloneCommand.cs @@ -18,7 +18,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { - string targetName = String.Empty; + string targetName = string.Empty; List matches; targetName = args.Aggregate(targetName, (current, t) => current + t + " "); @@ -33,7 +33,7 @@ namespace OpenMetaverse.TestClient #pragma warning restore CS0618 // Type or member is obsolete { UUID target = matches[0].AgentID; - targetName += String.Format(" ({0})", target); + targetName += $" ({target})"; if (Client.Appearances.ContainsKey(target)) { @@ -41,19 +41,25 @@ namespace OpenMetaverse.TestClient AvatarAppearancePacket appearance = Client.Appearances[target]; - AgentSetAppearancePacket set = new AgentSetAppearancePacket(); - set.AgentData.AgentID = Client.Self.AgentID; - set.AgentData.SessionID = Client.Self.SessionID; - set.AgentData.SerialNum = SerialNum++; - set.AgentData.Size = new Vector3(2f, 2f, 2f); // HACK - - set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0]; - set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length]; + AgentSetAppearancePacket set = new AgentSetAppearancePacket + { + AgentData = + { + AgentID = Client.Self.AgentID, + SessionID = Client.Self.SessionID, + SerialNum = SerialNum++, + Size = new Vector3(2f, 2f, 2f) // HACK + }, + WearableData = Array.Empty(), + VisualParam = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length] + }; for (int i = 0; i < appearance.VisualParam.Length; i++) { - set.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock(); - set.VisualParam[i].ParamValue = appearance.VisualParam[i].ParamValue; + set.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock + { + ParamValue = appearance.VisualParam[i].ParamValue + }; } set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry; diff --git a/Programs/examples/TestClient/Commands/Appearance/WearCommand.cs b/Programs/examples/TestClient/Commands/Appearance/WearCommand.cs index ab487db2..97744c23 100644 --- a/Programs/examples/TestClient/Commands/Appearance/WearCommand.cs +++ b/Programs/examples/TestClient/Commands/Appearance/WearCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; namespace OpenMetaverse.TestClient { @@ -18,12 +19,7 @@ namespace OpenMetaverse.TestClient if (args.Length < 1) return "Usage: wear [outfit name] eg: 'wear Clothing/My Outfit"; - string target = String.Empty; - - for (int ct = 0; ct < args.Length; ct++) - { - target += args[ct] + " "; - } + string target = args.Aggregate(string.Empty, (current, t) => current + (t + " ")); target = target.TrimEnd(); diff --git a/Programs/examples/TestClient/Commands/Communication/IMCommand.cs b/Programs/examples/TestClient/Commands/Communication/IMCommand.cs index d6cc294f..ee338bfd 100644 --- a/Programs/examples/TestClient/Commands/Communication/IMCommand.cs +++ b/Programs/examples/TestClient/Commands/Communication/IMCommand.cs @@ -6,7 +6,7 @@ namespace OpenMetaverse.TestClient { public class ImCommand : Command { - string ToAvatarName = String.Empty; + string ToAvatarName = string.Empty; ManualResetEvent NameSearchEvent = new ManualResetEvent(false); Dictionary Name2Key = new Dictionary(); @@ -27,7 +27,7 @@ namespace OpenMetaverse.TestClient ToAvatarName = args[0] + " " + args[1]; // Build the message - string message = String.Empty; + string message = string.Empty; for (int ct = 2; ct < args.Length; ct++) message += args[ct] + " "; message = message.TrimEnd(); @@ -46,7 +46,7 @@ namespace OpenMetaverse.TestClient UUID id = Name2Key[ToAvatarName.ToLower()]; Client.Self.InstantMessage(id, message); - return "Instant Messaged " + id.ToString() + " with message: " + message; + return "Instant Messaged " + id + " with message: " + message; } else { diff --git a/Programs/examples/TestClient/Commands/Communication/IMGroupCommand.cs b/Programs/examples/TestClient/Commands/Communication/IMGroupCommand.cs index d353108d..b8b2566a 100644 --- a/Programs/examples/TestClient/Commands/Communication/IMGroupCommand.cs +++ b/Programs/examples/TestClient/Commands/Communication/IMGroupCommand.cs @@ -24,7 +24,7 @@ namespace OpenMetaverse.TestClient if (UUID.TryParse(args[0], out ToGroupID)) { - string message = String.Empty; + string message = string.Empty; for (int ct = 1; ct < args.Length; ct++) message += args[ct] + " "; @@ -57,7 +57,7 @@ namespace OpenMetaverse.TestClient } Client.Self.GroupChatJoined -= Self_GroupChatJoined; - return "Instant Messaged group " + ToGroupID.ToString() + " with message: " + message; + return "Instant Messaged group " + ToGroupID + " with message: " + message; } else { diff --git a/Programs/examples/TestClient/Commands/Communication/SayCommand.cs b/Programs/examples/TestClient/Commands/Communication/SayCommand.cs index 599aef2d..470ec356 100644 --- a/Programs/examples/TestClient/Commands/Communication/SayCommand.cs +++ b/Programs/examples/TestClient/Commands/Communication/SayCommand.cs @@ -22,11 +22,11 @@ namespace OpenMetaverse.TestClient } else if (args.Length > 1) { - if (Int32.TryParse(args[0], out channel)) + if (int.TryParse(args[0], out channel)) startIndex = 1; } - String message = String.Empty; + string message = string.Empty; for (int i = startIndex; i < args.Length; i++) { @@ -38,7 +38,7 @@ namespace OpenMetaverse.TestClient Client.Self.Chat(message, channel, ChatType.Normal); - return "Said " + message.ToString(); + return "Said " + message; } } } diff --git a/Programs/examples/TestClient/Commands/Communication/ShoutCommand.cs b/Programs/examples/TestClient/Commands/Communication/ShoutCommand.cs index bf14f772..0772004a 100644 --- a/Programs/examples/TestClient/Commands/Communication/ShoutCommand.cs +++ b/Programs/examples/TestClient/Commands/Communication/ShoutCommand.cs @@ -15,7 +15,7 @@ namespace OpenMetaverse.TestClient { int channel = 0; int startIndex = 0; - string message = String.Empty; + string message = string.Empty; if (args.Length < 1) { return "usage: shout (optional channel) whatever"; diff --git a/Programs/examples/TestClient/Commands/Communication/WhisperCommand.cs b/Programs/examples/TestClient/Commands/Communication/WhisperCommand.cs index 215876d1..bbe063fe 100644 --- a/Programs/examples/TestClient/Commands/Communication/WhisperCommand.cs +++ b/Programs/examples/TestClient/Commands/Communication/WhisperCommand.cs @@ -15,7 +15,7 @@ namespace OpenMetaverse.TestClient { int channel = 0; int startIndex = 0; - string message = String.Empty; + string message = string.Empty; if (args.Length < 1) { return "usage: whisper (optional channel) whatever"; diff --git a/Programs/examples/TestClient/Commands/Directory/SearchGroupsCommand.cs b/Programs/examples/TestClient/Commands/Directory/SearchGroupsCommand.cs index 2555a432..25fc3176 100644 --- a/Programs/examples/TestClient/Commands/Directory/SearchGroupsCommand.cs +++ b/Programs/examples/TestClient/Commands/Directory/SearchGroupsCommand.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; namespace OpenMetaverse.TestClient.Commands { @@ -20,9 +21,7 @@ namespace OpenMetaverse.TestClient.Commands if (args.Length < 1) return "Usage: searchgroups [search text]"; - string searchText = string.Empty; - for (int i = 0; i < args.Length; i++) - searchText += args[i] + " "; + string searchText = args.Aggregate(string.Empty, (current, t) => current + (t + " ")); searchText = searchText.TrimEnd(); waitQuery.Reset(); diff --git a/Programs/examples/TestClient/Commands/Directory/ShowEventDetailsCommand.cs b/Programs/examples/TestClient/Commands/Directory/ShowEventDetailsCommand.cs index 4011cc03..1f898ca3 100644 --- a/Programs/examples/TestClient/Commands/Directory/ShowEventDetailsCommand.cs +++ b/Programs/examples/TestClient/Commands/Directory/ShowEventDetailsCommand.cs @@ -20,7 +20,7 @@ namespace OpenMetaverse.TestClient.Commands Client.Directory.EventInfoReply += Directory_EventDetails; uint eventID; - if (UInt32.TryParse(args[0], out eventID)) + if (uint.TryParse(args[0], out eventID)) { Client.Directory.EventInfoRequest(eventID); return "Sent query for Event " + eventID; diff --git a/Programs/examples/TestClient/Commands/Estate/DownloadTerrainCommand.cs b/Programs/examples/TestClient/Commands/Estate/DownloadTerrainCommand.cs index 137d2fec..debacc60 100644 --- a/Programs/examples/TestClient/Commands/Estate/DownloadTerrainCommand.cs +++ b/Programs/examples/TestClient/Commands/Estate/DownloadTerrainCommand.cs @@ -56,7 +56,7 @@ namespace OpenMetaverse.TestClient }; // Subscribe to the event that will tell us the status of the download - Client.Assets.XferReceived += new EventHandler(Assets_XferReceived); + Client.Assets.XferReceived += Assets_XferReceived; // subscribe to the event which tells us when the simulator has received our request Client.Assets.InitiateDownload += initiateDownloadDelegate; @@ -75,7 +75,7 @@ namespace OpenMetaverse.TestClient // unsubscribe from events Client.Assets.InitiateDownload -= initiateDownloadDelegate; - Client.Assets.XferReceived -= new EventHandler(Assets_XferReceived); + Client.Assets.XferReceived -= Assets_XferReceived; // return the result return result.ToString(); diff --git a/Programs/examples/TestClient/Commands/Estate/UploadRawTerrainCommand.cs b/Programs/examples/TestClient/Commands/Estate/UploadRawTerrainCommand.cs index dbe4c30f..5879bb79 100644 --- a/Programs/examples/TestClient/Commands/Estate/UploadRawTerrainCommand.cs +++ b/Programs/examples/TestClient/Commands/Estate/UploadRawTerrainCommand.cs @@ -15,7 +15,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { - string fileName = String.Empty; + string fileName = string.Empty; if (args.Length != 1) return "Usage: uploadterrain filename"; @@ -25,12 +25,12 @@ namespace OpenMetaverse.TestClient if (!System.IO.File.Exists(fileName)) { - return String.Format("File {0} Does not exist", fileName); + return $"File {fileName} Does not exist"; } // Setup callbacks for upload request reply and progress indicator // so we can detect when the upload is complete - Client.Assets.UploadProgress += new EventHandler(Assets_UploadProgress); + Client.Assets.UploadProgress += Assets_UploadProgress; byte[] fileData = File.ReadAllBytes(fileName); Client.Estate.UploadTerrain(fileData, fileName); @@ -53,7 +53,7 @@ namespace OpenMetaverse.TestClient /// private void Cleanup() { - Client.Assets.UploadProgress -= new EventHandler(Assets_UploadProgress); + Client.Assets.UploadProgress -= Assets_UploadProgress; } diff --git a/Programs/examples/TestClient/Commands/Groups/ActivateGroupCommand.cs b/Programs/examples/TestClient/Commands/Groups/ActivateGroupCommand.cs index 59650fe7..1f1f69d6 100644 --- a/Programs/examples/TestClient/Commands/Groups/ActivateGroupCommand.cs +++ b/Programs/examples/TestClient/Commands/Groups/ActivateGroupCommand.cs @@ -26,7 +26,7 @@ namespace OpenMetaverse.TestClient activeGroup = string.Empty; - string groupName = args.Aggregate(String.Empty, (current, t) => current + (t + " ")); + string groupName = args.Aggregate(string.Empty, (current, t) => current + (t + " ")); groupName = groupName.Trim(); UUID groupUUID = Client.GroupName2UUID(groupName); @@ -45,12 +45,12 @@ namespace OpenMetaverse.TestClient * TODO: Handle titles choosing. */ - if (String.IsNullOrEmpty(activeGroup)) - return Client.ToString() + " failed to activate the group " + groupName; + if (string.IsNullOrEmpty(activeGroup)) + return Client + " failed to activate the group " + groupName; return "Active group is now " + activeGroup; } - return Client.ToString() + " doesn't seem to be member of the group " + groupName; + return Client + " doesn't seem to be member of the group " + groupName; } private void AgentDataUpdateHandler(object sender, PacketReceivedEventArgs e) diff --git a/Programs/examples/TestClient/Commands/Groups/GroupMembersCommand.cs b/Programs/examples/TestClient/Commands/Groups/GroupMembersCommand.cs index 893eed81..bf2daebf 100644 --- a/Programs/examples/TestClient/Commands/Groups/GroupMembersCommand.cs +++ b/Programs/examples/TestClient/Commands/Groups/GroupMembersCommand.cs @@ -27,7 +27,7 @@ namespace OpenMetaverse.TestClient if (args.Length < 1) return Description; - GroupName = String.Empty; + GroupName = string.Empty; foreach (var arg in args) GroupName += arg + " "; @@ -40,9 +40,9 @@ namespace OpenMetaverse.TestClient GroupsEvent.WaitOne(30000, false); GroupsEvent.Reset(); Client.Groups.GroupMembersReply -= GroupMembersHandler; - return Client.ToString() + " got group members"; + return Client + " got group members"; } - return Client.ToString() + " doesn't seem to be member of the group " + GroupName; + return Client + " doesn't seem to be member of the group " + GroupName; } private void GroupMembersHandler(object sender, GroupMembersReplyEventArgs e) diff --git a/Programs/examples/TestClient/Commands/Groups/GroupRolesCommand.cs b/Programs/examples/TestClient/Commands/Groups/GroupRolesCommand.cs index 8012def0..7301660c 100644 --- a/Programs/examples/TestClient/Commands/Groups/GroupRolesCommand.cs +++ b/Programs/examples/TestClient/Commands/Groups/GroupRolesCommand.cs @@ -27,7 +27,7 @@ namespace OpenMetaverse.TestClient if (args.Length < 1) return Description; - GroupName = String.Empty; + GroupName = string.Empty; foreach (var arg in args) GroupName += arg + " "; @@ -40,9 +40,9 @@ namespace OpenMetaverse.TestClient GroupsEvent.WaitOne(30000, false); GroupsEvent.Reset(); Client.Groups.GroupRoleDataReply += Groups_GroupRoles; - return Client.ToString() + " got group roles"; + return Client + " got group roles"; } - return Client.ToString() + " doesn't seem to have any roles in the group " + GroupName; + return Client + " doesn't seem to have any roles in the group " + GroupName; } void Groups_GroupRoles(object sender, GroupRolesDataReplyEventArgs e) diff --git a/Programs/examples/TestClient/Commands/Groups/JoinGroupCommand.cs b/Programs/examples/TestClient/Commands/Groups/JoinGroupCommand.cs index 614697ed..99068119 100644 --- a/Programs/examples/TestClient/Commands/Groups/JoinGroupCommand.cs +++ b/Programs/examples/TestClient/Commands/Groups/JoinGroupCommand.cs @@ -24,9 +24,9 @@ namespace OpenMetaverse.TestClient if (args.Length < 1) return Description; - groupName = String.Empty; + groupName = string.Empty; resolvedGroupID = UUID.Zero; - resolvedGroupName = String.Empty; + resolvedGroupName = string.Empty; if (args[0].ToLower() == "uuid") { @@ -109,7 +109,7 @@ namespace OpenMetaverse.TestClient foreach (DirectoryManager.GroupSearchData groupRetrieved in e.MatchedGroups) { Console.WriteLine(groupRetrieved.GroupName + "\t\t\t(" + - Name + " UUID " + groupRetrieved.GroupID.ToString() + ")"); + Name + " UUID " + groupRetrieved.GroupID + ")"); if (groupRetrieved.GroupName.ToLower() == groupName.ToLower()) { @@ -119,7 +119,7 @@ namespace OpenMetaverse.TestClient } } if (string.IsNullOrEmpty(resolvedGroupName)) - resolvedGroupName = "Ambiguous name. Found " + e.MatchedGroups.Count.ToString() + " groups (UUIDs on console)"; + resolvedGroupName = "Ambiguous name. Found " + e.MatchedGroups.Count + " groups (UUIDs on console)"; } } @@ -129,7 +129,7 @@ namespace OpenMetaverse.TestClient void Groups_OnGroupJoined(object sender, GroupOperationEventArgs e) { - Console.WriteLine(Client.ToString() + (e.Success ? " joined " : " failed to join ") + e.GroupID.ToString()); + Console.WriteLine(Client + (e.Success ? " joined " : " failed to join ") + e.GroupID); /* A.Biondi * This code is not necessary because it is yet present in the diff --git a/Programs/examples/TestClient/Commands/Groups/LeaveGroupCommand.cs b/Programs/examples/TestClient/Commands/Groups/LeaveGroupCommand.cs index 307e44c8..b5ca7453 100644 --- a/Programs/examples/TestClient/Commands/Groups/LeaveGroupCommand.cs +++ b/Programs/examples/TestClient/Commands/Groups/LeaveGroupCommand.cs @@ -20,7 +20,7 @@ namespace OpenMetaverse.TestClient if (args.Length < 1) return Description; - string groupName = args.Aggregate(String.Empty, (current, t) => current + (t + " ")); + string groupName = args.Aggregate(string.Empty, (current, t) => current + (t + " ")); groupName = groupName.Trim(); UUID groupUUID = Client.GroupName2UUID(groupName); @@ -35,15 +35,15 @@ namespace OpenMetaverse.TestClient Client.ReloadGroupsCache(); if (leftGroup) - return Client.ToString() + " has left the group " + groupName; + return Client + " has left the group " + groupName; return "failed to leave the group " + groupName; } - return Client.ToString() + " doesn't seem to be member of the group " + groupName; + return Client + " doesn't seem to be member of the group " + groupName; } void Groups_GroupLeft(object sender, GroupOperationEventArgs e) { - Console.WriteLine(Client.ToString() + (e.Success ? " has left group " : " failed to left group ") + e.GroupID.ToString()); + Console.WriteLine(Client + (e.Success ? " has left group " : " failed to left group ") + e.GroupID); leftGroup = e.Success; GroupsEvent.Set(); diff --git a/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs b/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs index a1c6c57b..7cfa03b8 100644 --- a/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs @@ -57,26 +57,17 @@ namespace OpenMetaverse.TestClient /// /// true if either of the background threads is running /// - private bool BackgroundBackupRunning - { - get { return InventoryWalkerRunning || QueueRunnerRunning; } - } + private bool BackgroundBackupRunning => InventoryWalkerRunning || QueueRunnerRunning; /// /// true if the thread walking inventory is running /// - private bool InventoryWalkerRunning - { - get { return BackupWorker != null; } - } + private bool InventoryWalkerRunning => BackupWorker != null; /// /// true if the thread feeding the queue to the server is running /// - private bool QueueRunnerRunning - { - get { return QueueWorker != null; } - } + private bool QueueRunnerRunning => QueueWorker != null; /// /// returns a string summarizing activity @@ -140,15 +131,15 @@ namespace OpenMetaverse.TestClient QueueWorker = new BackgroundWorker(); QueueWorker.WorkerSupportsCancellation = true; - QueueWorker.DoWork += new DoWorkEventHandler(bwQueueRunner_DoWork); - QueueWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwQueueRunner_RunWorkerCompleted); + QueueWorker.DoWork += bwQueueRunner_DoWork; + QueueWorker.RunWorkerCompleted += bwQueueRunner_RunWorkerCompleted; QueueWorker.RunWorkerAsync(); BackupWorker = new BackgroundWorker(); BackupWorker.WorkerSupportsCancellation = true; - BackupWorker.DoWork += new DoWorkEventHandler(bwBackup_DoWork); - BackupWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwBackup_RunWorkerCompleted); + BackupWorker.DoWork += bwBackup_DoWork; + BackupWorker.RunWorkerCompleted += bwBackup_RunWorkerCompleted; BackupWorker.RunWorkerAsync(args); return "Started background operations."; @@ -173,7 +164,7 @@ namespace OpenMetaverse.TestClient { if ((qdi.WhenRequested + TimeSpan.FromSeconds(60)) < DateTime.Now) { - Logger.DebugLog(Name + ": timeout on asset " + qdi.AssetID.ToString(), Client); + Logger.DebugLog(Name + ": timeout on asset " + qdi.AssetID, Client); // submit request again var transferID = UUID.Random(); Client.Assets.RequestInventoryAsset( @@ -336,7 +327,7 @@ namespace OpenMetaverse.TestClient /// private static string BoolToNot(bool b) { - return b ? String.Empty : "not"; + return b ? string.Empty : "not"; } } } diff --git a/Programs/examples/TestClient/Commands/Inventory/BalanceCommand.cs b/Programs/examples/TestClient/Commands/Inventory/BalanceCommand.cs index 78746827..a7d6102e 100644 --- a/Programs/examples/TestClient/Commands/Inventory/BalanceCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/BalanceCommand.cs @@ -14,16 +14,20 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { System.Threading.AutoResetEvent waitBalance = new System.Threading.AutoResetEvent(false); - - EventHandler del = delegate(object sender, BalanceEventArgs e) { waitBalance.Set(); }; - Client.Self.MoneyBalance += del; + + void balance(object sender, BalanceEventArgs e) + { + waitBalance.Set(); + } + + Client.Self.MoneyBalance += balance; Client.Self.RequestBalance(); - String result = "Timeout waiting for balance reply"; + string result = "Timeout waiting for balance reply"; if (waitBalance.WaitOne(10000, false)) { - result = Client.ToString() + " has L$: " + Client.Self.Balance; + result = Client + " has L$: " + Client.Self.Balance; } - Client.Self.MoneyBalance -= del; + Client.Self.MoneyBalance -= balance; return result; } } diff --git a/Programs/examples/TestClient/Commands/Inventory/ChangeDirectoryCommand.cs b/Programs/examples/TestClient/Commands/Inventory/ChangeDirectoryCommand.cs index 28684e28..a698c49b 100644 --- a/Programs/examples/TestClient/Commands/Inventory/ChangeDirectoryCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/ChangeDirectoryCommand.cs @@ -22,13 +22,13 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell string[] path = null; if (args.Length == 0) { - path = new string[] { "" }; + path = new[] { "" }; // cd without any arguments doesn't do anything. } else if (args.Length == 1) { pathStr = args[0]; - path = pathStr.Split(new char[] { '/' }); + path = pathStr.Split(new[] { '/' }); // Use '/' as a path seperator. } InventoryFolder currentFolder = Client.CurrentDirectory; diff --git a/Programs/examples/TestClient/Commands/Inventory/CreateNotecardCommand.cs b/Programs/examples/TestClient/Commands/Inventory/CreateNotecardCommand.cs index 9ae09355..081161de 100644 --- a/Programs/examples/TestClient/Commands/Inventory/CreateNotecardCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/CreateNotecardCommand.cs @@ -25,7 +25,7 @@ namespace OpenMetaverse.TestClient UUID embedItemID = UUID.Zero, notecardItemID = UUID.Zero, notecardAssetID = UUID.Zero; string filename, fileData; bool success = false, finalUploadSuccess = false; - string message = String.Empty; + string message = string.Empty; AutoResetEvent notecardEvent = new AutoResetEvent(false); if (args.Length == 1) @@ -50,8 +50,10 @@ namespace OpenMetaverse.TestClient #region Notecard asset data - AssetNotecard notecard = new AssetNotecard(); - notecard.BodyText = fileData; + AssetNotecard notecard = new AssetNotecard + { + BodyText = fileData + }; // Item embedding if (embedItemID != UUID.Zero) @@ -83,8 +85,10 @@ namespace OpenMetaverse.TestClient #region Upload an empty notecard asset first AutoResetEvent emptyNoteEvent = new AutoResetEvent(false); - AssetNotecard empty = new AssetNotecard(); - empty.BodyText = "\n"; + AssetNotecard empty = new AssetNotecard + { + BodyText = "\n" + }; empty.Encode(); Client.Inventory.RequestUploadNotecardAsset(empty.AssetData, item.UUID, diff --git a/Programs/examples/TestClient/Commands/Inventory/DeleteFolderCommand.cs b/Programs/examples/TestClient/Commands/Inventory/DeleteFolderCommand.cs index 94c86b28..a7fa3694 100644 --- a/Programs/examples/TestClient/Commands/Inventory/DeleteFolderCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/DeleteFolderCommand.cs @@ -19,7 +19,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { // parse the command line - string target = args.Aggregate(String.Empty, (current, t) => current + t + " "); + string target = args.Aggregate(string.Empty, (current, t) => current + t + " "); target = target.TrimEnd(); // initialize results list @@ -33,10 +33,10 @@ namespace OpenMetaverse.TestClient // move the folder to the trash folder Client.Inventory.MoveFolder(found[0].UUID, Client.Inventory.FindFolderForType(FolderType.Trash)); - return String.Format("Moved folder {0} to Trash", found[0].Name); + return $"Moved folder {found[0].Name} to Trash"; } - return String.Empty; + return string.Empty; } } } \ No newline at end of file diff --git a/Programs/examples/TestClient/Commands/Inventory/DownloadCommand.cs b/Programs/examples/TestClient/Commands/Inventory/DownloadCommand.cs index ba70b9bb..7a78a86d 100644 --- a/Programs/examples/TestClient/Commands/Inventory/DownloadCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/DownloadCommand.cs @@ -47,10 +47,9 @@ namespace OpenMetaverse.TestClient if (DownloadHandle.WaitOne(120 * 1000, false)) { if (Success) - return String.Format("Saved {0}.{1}", AssetID, assetType.ToString().ToLower()); + return $"Saved {AssetID}.{assetType.ToString().ToLower()}"; else - return String.Format("Failed to download asset {0}, perhaps {1} is the incorrect asset type?", - AssetID, assetType); + return $"Failed to download asset {AssetID}, perhaps {assetType} is the incorrect asset type?"; } else { @@ -66,8 +65,7 @@ namespace OpenMetaverse.TestClient { try { - File.WriteAllBytes(String.Format("{0}.{1}", AssetID, - assetType.ToString().ToLower()), asset.AssetData); + File.WriteAllBytes($"{AssetID}.{assetType.ToString().ToLower()}", asset.AssetData); Success = true; } catch (Exception ex) diff --git a/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs b/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs index 4f00c6e2..62c9a1a0 100644 --- a/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs @@ -100,7 +100,7 @@ namespace OpenMetaverse.TestClient } } - return "Couldn't find avatar " + target.ToString(); + return "Couldn't find avatar " + target; } private void Assets_OnImageReceived(TextureRequestState state, AssetTexture assetTexture) diff --git a/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs b/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs index aa7079aa..0dbe4006 100644 --- a/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs @@ -30,7 +30,7 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell string ret = ""; string nl = "\n"; - string target = args.Aggregate(String.Empty, (current, t) => current + t + " "); + string target = args.Aggregate(string.Empty, (current, t) => current + t + " "); target = target.TrimEnd(); string inventoryName = target; diff --git a/Programs/examples/TestClient/Commands/Inventory/InventoryCommand.cs b/Programs/examples/TestClient/Commands/Inventory/InventoryCommand.cs index 8851510f..7e96e23e 100644 --- a/Programs/examples/TestClient/Commands/Inventory/InventoryCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/InventoryCommand.cs @@ -38,7 +38,7 @@ namespace OpenMetaverse.TestClient { foreach (InventoryBase i in contents) { - result.AppendFormat("{0}{1} ({2})\n", new String(' ', indent * 2), i.Name, i.UUID); + result.AppendFormat("{0}{1} ({2})\n", new string(' ', indent * 2), i.Name, i.UUID); if (i is InventoryFolder folder) { PrintFolder(folder, result, indent + 1); diff --git a/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs b/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs index 9ff542b2..433fc88f 100644 --- a/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs @@ -16,7 +16,7 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell { if (args.Length > 1) return "Usage: ls [-l]"; - bool longDisplay = false || args.Length > 0 && args[0] == "-l"; + bool longDisplay = args.Length > 0 && args[0] == "-l"; Manager = Client.Inventory; Inventory = Manager.Store; diff --git a/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs b/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs index 6e131619..f6b2857b 100644 --- a/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs @@ -26,13 +26,13 @@ namespace OpenMetaverse.TestClient if (found != null) objectLocalID = found.LocalID; else - return "Couldn't find prim " + objectID.ToString(); + return "Couldn't find prim " + objectID; List items = Client.Inventory.GetTaskInventory(objectID, objectLocalID, 1000 * 30); if (items != null) { - string result = String.Empty; + string result = string.Empty; foreach (var i in items) { diff --git a/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs b/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs index 8b39a515..f102fb1b 100644 --- a/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs @@ -36,31 +36,24 @@ namespace OpenMetaverse.TestClient bool setTaskTo = false; if (items != null) { - string result = String.Empty; - string matching = String.Empty; + string result = string.Empty; + string matching = string.Empty; bool setAny = false; if (args.Length > 1) { matching = args[1]; - string tf; - if (args.Length > 2) + var tf = args.Length > 2 ? args[2] : matching.ToLower(); + switch (tf) { - tf = args[2]; - } - else - { - tf = matching.ToLower(); - } - if (tf == "true") - { - setAny = true; - setTaskTo = true; - } - else if (tf == "false") - { - setAny = true; - setTaskTo = false; + case "true": + setAny = true; + setTaskTo = true; + break; + case "false": + setAny = true; + setTaskTo = false; + break; } } @@ -69,11 +62,11 @@ namespace OpenMetaverse.TestClient EventHandler callback; using (AutoResetEvent OnScriptRunningReset = new AutoResetEvent(false)) { - callback = ((object sender, ScriptRunningReplyEventArgs e) => + callback = ((sender, e) => { if (e.ObjectID == objectID) { - result += String.Format(" IsMono: {0} IsRunning: {1}", e.IsMono, e.IsRunning); + result += $" IsMono: {e.IsMono} IsRunning: {e.IsRunning}"; wasRunning = e.IsRunning; OnScriptRunningReset.Set(); } diff --git a/Programs/examples/TestClient/Commands/Inventory/TreeCommand.cs b/Programs/examples/TestClient/Commands/Inventory/TreeCommand.cs index 1db7eec7..59dde3cf 100644 --- a/Programs/examples/TestClient/Commands/Inventory/TreeCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/TreeCommand.cs @@ -17,7 +17,7 @@ namespace OpenMetaverse.TestClient { try { - string treeName = args[0].Trim(new char[] { ' ' }); + string treeName = args[0].Trim(new[] { ' ' }); Tree tree = (Tree)Enum.Parse(typeof(Tree), treeName); Vector3 treePosition = Client.Self.SimPosition; @@ -39,7 +39,7 @@ namespace OpenMetaverse.TestClient { usage += value + ","; } - usage = usage.TrimEnd(new char[] { ',' }); + usage = usage.TrimEnd(new[] { ',' }); usage += "]"; return usage; } diff --git a/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs b/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs index c05d3d8c..ef4030ff 100644 --- a/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs @@ -58,7 +58,7 @@ namespace OpenMetaverse.TestClient TextureID = UUID.Zero; inventoryName = args[0]; fileName = args[2]; - if (!UInt32.TryParse(args[1], out timeout)) + if (!uint.TryParse(args[1], out timeout)) return "Usage: uploadimage [inventoryname] [timeout] [filename]"; Console.WriteLine("Loading image " + fileName); @@ -71,8 +71,7 @@ namespace OpenMetaverse.TestClient if (UploadCompleteEvent.WaitOne((int)timeout, false)) { - return String.Format("Texture upload {0}: {1}", (TextureID != UUID.Zero) ? "succeeded" : "failed", - TextureID); + return $"Texture upload {((TextureID != UUID.Zero) ? "succeeded" : "failed")}: {TextureID}"; } else { @@ -172,7 +171,7 @@ namespace OpenMetaverse.TestClient } catch (Exception ex) { - Console.WriteLine(ex.ToString() + " SL Image Upload "); + Console.WriteLine(ex + " SL Image Upload "); return null; } return UploadData; diff --git a/Programs/examples/TestClient/Commands/Land/AgentLocationsCommand.cs b/Programs/examples/TestClient/Commands/Land/AgentLocationsCommand.cs index 69358cdd..7a4e187c 100644 --- a/Programs/examples/TestClient/Commands/Land/AgentLocationsCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/AgentLocationsCommand.cs @@ -23,7 +23,7 @@ namespace OpenMetaverse.TestClient if (args.Length == 0) regionHandle = Client.Network.CurrentSim.Handle; - else if (!(args.Length == 1 && UInt64.TryParse(args[0], out regionHandle))) + else if (!(args.Length == 1 && ulong.TryParse(args[0], out regionHandle))) return "Usage: agentlocations [regionhandle]"; List items = Client.Grid.MapItems(regionHandle, GridItemType.AgentLocations, diff --git a/Programs/examples/TestClient/Commands/Land/FindSimCommand.cs b/Programs/examples/TestClient/Commands/Land/FindSimCommand.cs index 3871eb21..8d00755d 100644 --- a/Programs/examples/TestClient/Commands/Land/FindSimCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/FindSimCommand.cs @@ -30,7 +30,7 @@ namespace OpenMetaverse.TestClient GridRegion region; if (Client.Grid.GetGridRegion(simName, GridLayerType.Objects, out region)) - return String.Format("{0}: handle={1} ({2},{3})", region.Name, region.RegionHandle, region.X, region.Y); + return $"{region.Name}: handle={region.RegionHandle} ({region.X},{region.Y})"; else return "Lookup of " + simName + " failed"; } diff --git a/Programs/examples/TestClient/Commands/Land/ParcelDetailsCommand.cs b/Programs/examples/TestClient/Commands/Land/ParcelDetailsCommand.cs index 53771475..e5f968f4 100644 --- a/Programs/examples/TestClient/Commands/Land/ParcelDetailsCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/ParcelDetailsCommand.cs @@ -21,7 +21,7 @@ namespace OpenMetaverse.TestClient Parcel parcel; // test argument that is is a valid integer, then verify we have that parcel data stored in the dictionary - if (Int32.TryParse(args[0], out parcelID) && Client.Network.CurrentSim.Parcels.TryGetValue(parcelID, out parcel)) + if (int.TryParse(args[0], out parcelID) && Client.Network.CurrentSim.Parcels.TryGetValue(parcelID, out parcel)) { // this request will update the parcels dictionary Client.Parcels.RequestParcelProperties(Client.Network.CurrentSim, parcelID, 0); @@ -39,7 +39,8 @@ namespace OpenMetaverse.TestClient } else { - return String.Format("Unable to find Parcel {0} in Parcels Dictionary, Did you run parcelinfo to populate the dictionary first?", args[0]); + return + $"Unable to find Parcel {args[0]} in Parcels Dictionary, Did you run parcelinfo to populate the dictionary first?"; } } } diff --git a/Programs/examples/TestClient/Commands/Land/ParcelInfoCommand.cs b/Programs/examples/TestClient/Commands/Land/ParcelInfoCommand.cs index ae2b4c33..8a0e237c 100644 --- a/Programs/examples/TestClient/Commands/Land/ParcelInfoCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/ParcelInfoCommand.cs @@ -21,14 +21,15 @@ namespace OpenMetaverse.TestClient { StringBuilder sb = new StringBuilder(); string result; - EventHandler del = delegate(object sender, SimParcelsDownloadedEventArgs e) + + void parcelsDownloaded(object sender, SimParcelsDownloadedEventArgs e) { ParcelsDownloaded.Set(); - }; - + } + ParcelsDownloaded.Reset(); - Client.Parcels.SimParcelsDownloaded += del; + Client.Parcels.SimParcelsDownloaded += parcelsDownloaded; Client.Parcels.RequestAllSimParcels(Client.Network.CurrentSim); if (Client.Network.CurrentSim.IsParcelMapFull()) @@ -50,7 +51,7 @@ namespace OpenMetaverse.TestClient else result = "Failed to retrieve information on all the simulator parcels"; - Client.Parcels.SimParcelsDownloaded -= del; + Client.Parcels.SimParcelsDownloaded -= parcelsDownloaded; return result; } diff --git a/Programs/examples/TestClient/Commands/Land/ParcelPrimOwnersCommand.cs b/Programs/examples/TestClient/Commands/Land/ParcelPrimOwnersCommand.cs index a05da0e7..f9241fb5 100644 --- a/Programs/examples/TestClient/Commands/Land/ParcelPrimOwnersCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/ParcelPrimOwnersCommand.cs @@ -22,7 +22,7 @@ namespace OpenMetaverse.TestClient Parcel parcel; StringBuilder result = new StringBuilder(); // test argument that is is a valid integer, then verify we have that parcel data stored in the dictionary - if (Int32.TryParse(args[0], out parcelID) && Client.Network.CurrentSim.Parcels.TryGetValue(parcelID, out parcel)) + if (int.TryParse(args[0], out parcelID) && Client.Network.CurrentSim.Parcels.TryGetValue(parcelID, out parcel)) { AutoResetEvent wait = new AutoResetEvent(false); @@ -49,7 +49,8 @@ namespace OpenMetaverse.TestClient } else { - return String.Format("Unable to find Parcel {0} in Parcels Dictionary, Did you run parcelinfo to populate the dictionary first?", args[0]); + return + $"Unable to find Parcel {args[0]} in Parcels Dictionary, Did you run parcelinfo to populate the dictionary first?"; } } } diff --git a/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs b/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs index 903b4b0d..3fa45656 100644 --- a/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs @@ -24,7 +24,7 @@ namespace OpenMetaverse.TestClient int counter = 0; StringBuilder result = new StringBuilder(); // test argument that is is a valid integer, then verify we have that parcel data stored in the dictionary - if (Int32.TryParse(args[0], out parcelID) + if (int.TryParse(args[0], out parcelID) && UUID.TryParse(args[1], out ownerUUID)) { AutoResetEvent wait = new AutoResetEvent(false); @@ -57,7 +57,8 @@ namespace OpenMetaverse.TestClient } else { - return String.Format("Unable to find Parcel {0} in Parcels Dictionary, Did you run parcelinfo to populate the dictionary first?", args[0]); + return + $"Unable to find Parcel {args[0]} in Parcels Dictionary, Did you run parcelinfo to populate the dictionary first?"; } } } diff --git a/Programs/examples/TestClient/Commands/Land/WindCommand.cs b/Programs/examples/TestClient/Commands/Land/WindCommand.cs index 85eb3127..2f5a1432 100644 --- a/Programs/examples/TestClient/Commands/Land/WindCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/WindCommand.cs @@ -19,7 +19,7 @@ namespace OpenMetaverse.TestClient Vector2 windSpeed = Client.Network.CurrentSim.WindSpeeds[yPos * 16 + xPos]; - return "Local wind speed is " + windSpeed.ToString(); + return "Local wind speed is " + windSpeed; } } } diff --git a/Programs/examples/TestClient/Commands/Movement/BackCommand.cs b/Programs/examples/TestClient/Commands/Movement/BackCommand.cs index 7587fef1..24e8ade8 100644 --- a/Programs/examples/TestClient/Commands/Movement/BackCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/BackCommand.cs @@ -27,7 +27,7 @@ namespace OpenMetaverse.TestClient.Commands.Movement { // Parse the number of seconds int duration; - if (!Int32.TryParse(args[0], out duration)) + if (!int.TryParse(args[0], out duration)) return "Usage: back [seconds]"; // Convert to milliseconds duration *= 1000; diff --git a/Programs/examples/TestClient/Commands/Movement/FlyToCommand.cs b/Programs/examples/TestClient/Commands/Movement/FlyToCommand.cs index 3227511f..64369ce1 100644 --- a/Programs/examples/TestClient/Commands/Movement/FlyToCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/FlyToCommand.cs @@ -44,7 +44,7 @@ namespace OpenMetaverse.TestClient.Commands.Movement target0.X = target.X; target0.Y = target.Y; - if (args.Length == 4 && Int32.TryParse(args[3], out duration)) + if (args.Length == 4 && int.TryParse(args[3], out duration)) duration *= 1000; startTime = Environment.TickCount; @@ -54,7 +54,7 @@ namespace OpenMetaverse.TestClient.Commands.Movement ZMovement(); Client.Self.Movement.TurnToward(target); - return string.Format("flying to {0} in {1} seconds", target.ToString(), duration / 1000); + return $"flying to {target.ToString()} in {duration / 1000} seconds"; } private void Objects_OnObjectUpdated(object sender, TerseObjectUpdateEventArgs e) diff --git a/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs b/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs index a863ed9b..8a3fcb5f 100644 --- a/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs @@ -21,7 +21,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { // Construct the target name from the passed arguments - string target = args.Aggregate(String.Empty, (current, t) => current + t + " "); + string target = args.Aggregate(string.Empty, (current, t) => current + t + " "); target = target.TrimEnd(); if (target.Length == 0 || target == "off") @@ -102,8 +102,8 @@ namespace OpenMetaverse.TestClient double yTarget = (double)targetAv.Position.Y + (double)regionY; double zTarget = targetAv.Position.Z - 2f; - Logger.DebugLog(String.Format("[Autopilot] {0} meters away from the target, starting autopilot to <{1},{2},{3}>", - distance, xTarget, yTarget, zTarget), Client); + Logger.DebugLog( + $"[Autopilot] {distance} meters away from the target, starting autopilot to <{xTarget},{yTarget},{zTarget}>", Client); Client.Self.AutoPilot(xTarget, yTarget, zTarget); } diff --git a/Programs/examples/TestClient/Commands/Movement/ForwardCommand.cs b/Programs/examples/TestClient/Commands/Movement/ForwardCommand.cs index 59b5263e..82a41c78 100644 --- a/Programs/examples/TestClient/Commands/Movement/ForwardCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/ForwardCommand.cs @@ -27,7 +27,7 @@ namespace OpenMetaverse.TestClient.Commands.Movement { // Parse the number of seconds int duration; - if (!Int32.TryParse(args[0], out duration)) + if (!int.TryParse(args[0], out duration)) return "Usage: forward [seconds]"; // Convert to milliseconds duration *= 1000; diff --git a/Programs/examples/TestClient/Commands/Movement/GotoCommand.cs b/Programs/examples/TestClient/Commands/Movement/GotoCommand.cs index efb6e7f3..fb008e23 100644 --- a/Programs/examples/TestClient/Commands/Movement/GotoCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/GotoCommand.cs @@ -16,7 +16,7 @@ namespace OpenMetaverse.TestClient if (args.Length < 1) return "Usage: goto sim/x/y/z"; - string destination = String.Empty; + string destination = string.Empty; // Handle multi-word sim names by combining the arguments foreach (string arg in args) @@ -25,7 +25,7 @@ namespace OpenMetaverse.TestClient } destination = destination.Trim(); - string[] tokens = destination.Split(new char[] { '/' }); + string[] tokens = destination.Split(new[] { '/' }); if (tokens.Length != 4) return "Usage: goto sim/x/y/z"; diff --git a/Programs/examples/TestClient/Commands/Movement/GotoLandmark.cs b/Programs/examples/TestClient/Commands/Movement/GotoLandmark.cs index a7d8f940..45008250 100644 --- a/Programs/examples/TestClient/Commands/Movement/GotoLandmark.cs +++ b/Programs/examples/TestClient/Commands/Movement/GotoLandmark.cs @@ -25,7 +25,7 @@ namespace OpenMetaverse.TestClient } else { - Console.WriteLine("Teleporting to " + landmark.ToString()); + Console.WriteLine("Teleporting to " + landmark); } if (Client.Self.Teleport(landmark)) { diff --git a/Programs/examples/TestClient/Commands/Movement/LeftCommand.cs b/Programs/examples/TestClient/Commands/Movement/LeftCommand.cs index 175979f9..63de1145 100644 --- a/Programs/examples/TestClient/Commands/Movement/LeftCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/LeftCommand.cs @@ -27,7 +27,7 @@ namespace OpenMetaverse.TestClient.Commands.Movement { // Parse the number of seconds int duration; - if (!Int32.TryParse(args[0], out duration)) + if (!int.TryParse(args[0], out duration)) return "Usage: left [seconds]"; // Convert to milliseconds duration *= 1000; diff --git a/Programs/examples/TestClient/Commands/Movement/LocationCommand.cs b/Programs/examples/TestClient/Commands/Movement/LocationCommand.cs index d2885385..31cb9eb4 100644 --- a/Programs/examples/TestClient/Commands/Movement/LocationCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/LocationCommand.cs @@ -11,8 +11,8 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { - return "CurrentSim: '" + Client.Network.CurrentSim.ToString() + "' Position: " + - Client.Self.SimPosition.ToString(); + return "CurrentSim: '" + Client.Network.CurrentSim + "' Position: " + + Client.Self.SimPosition; } } } diff --git a/Programs/examples/TestClient/Commands/Movement/MoveToCommand.cs b/Programs/examples/TestClient/Commands/Movement/MoveToCommand.cs index c270bf3d..37ebb6b4 100644 --- a/Programs/examples/TestClient/Commands/Movement/MoveToCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/MoveToCommand.cs @@ -20,9 +20,9 @@ namespace OpenMetaverse.TestClient.Commands.Movement Utils.LongToUInts(Client.Network.CurrentSim.Handle, out regionX, out regionY); double x, y, z; - if (!Double.TryParse(args[0], out x) || - !Double.TryParse(args[1], out y) || - !Double.TryParse(args[2], out z)) + if (!double.TryParse(args[0], out x) || + !double.TryParse(args[1], out y) || + !double.TryParse(args[2], out z)) { return "Usage: moveto x y z"; } @@ -33,7 +33,7 @@ namespace OpenMetaverse.TestClient.Commands.Movement Client.Self.AutoPilot(x, y, z); - return String.Format("Attempting to move to <{0},{1},{2}>", x, y, z); + return $"Attempting to move to <{x},{y},{z}>"; } } } diff --git a/Programs/examples/TestClient/Commands/Movement/RightCommand.cs b/Programs/examples/TestClient/Commands/Movement/RightCommand.cs index 8adb843d..f2bcf0a6 100644 --- a/Programs/examples/TestClient/Commands/Movement/RightCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/RightCommand.cs @@ -27,7 +27,7 @@ namespace OpenMetaverse.TestClient.Commands.Movement { // Parse the number of seconds int duration; - if (!Int32.TryParse(args[0], out duration)) + if (!int.TryParse(args[0], out duration)) return "Usage: right [seconds]"; // Convert to milliseconds duration *= 1000; diff --git a/Programs/examples/TestClient/Commands/Movement/SitCommand.cs b/Programs/examples/TestClient/Commands/Movement/SitCommand.cs index fd91e858..41c35eec 100644 --- a/Programs/examples/TestClient/Commands/Movement/SitCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/SitCommand.cs @@ -14,7 +14,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { Primitive closest = null; - double closestDistance = Double.MaxValue; + double closestDistance = double.MaxValue; Client.Network.CurrentSim.ObjectsPrimitives.ForEach( delegate(Primitive prim) diff --git a/Programs/examples/TestClient/Commands/Movement/SitOnCommand.cs b/Programs/examples/TestClient/Commands/Movement/SitOnCommand.cs index ca0da47b..e1c16735 100644 --- a/Programs/examples/TestClient/Commands/Movement/SitOnCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/SitOnCommand.cs @@ -26,7 +26,7 @@ namespace OpenMetaverse.TestClient { Client.Self.RequestSit(targetPrim.ID, Vector3.Zero); Client.Self.Sit(); - return "Requested to sit on prim " + targetPrim.ID.ToString() + + return "Requested to sit on prim " + targetPrim.ID + " (" + targetPrim.LocalID + ")"; } } diff --git a/Programs/examples/TestClient/Commands/Movement/TurnToCommand.cs b/Programs/examples/TestClient/Commands/Movement/TurnToCommand.cs index f6bead5f..5188803d 100644 --- a/Programs/examples/TestClient/Commands/Movement/TurnToCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/TurnToCommand.cs @@ -39,9 +39,9 @@ namespace OpenMetaverse.TestClient.Commands.Movement if (args.Length != 3) return "Usage: turnto x y z"; double x, y, z; - if (!Double.TryParse(args[0], out x) || - !Double.TryParse(args[1], out y) || - !Double.TryParse(args[2], out z)) + if (!double.TryParse(args[0], out x) || + !double.TryParse(args[1], out y) || + !double.TryParse(args[2], out z)) { return "Usage: turnto x y z"; } diff --git a/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs b/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs index db359f91..20759da9 100644 --- a/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs @@ -15,7 +15,7 @@ namespace OpenMetaverse.TestClient public ChangePermsCommand(TestClient testClient) { - testClient.Objects.ObjectProperties += new EventHandler(Objects_OnObjectProperties); + testClient.Objects.ObjectProperties += Objects_OnObjectProperties; Name = "changeperms"; Description = "Recursively changes all of the permissions for child and task inventory objects. Usage prim-uuid [copy] [mod] [xfer]"; @@ -59,14 +59,14 @@ namespace OpenMetaverse.TestClient } } - Logger.DebugLog("Using PermissionMask: " + Perms.ToString(), Client); + Logger.DebugLog($"Using PermissionMask: {Perms}", Client); // Find the requested prim rootPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(prim => prim.ID == rootID); if (rootPrim == null) - return "Cannot find requested prim " + rootID.ToString(); + return $"Cannot find requested prim {rootID}"; else - Logger.DebugLog("Found requested prim " + rootPrim.ID.ToString(), Client); + Logger.DebugLog($"Found requested prim {rootPrim.ID}", Client); if (rootPrim.ParentID != 0) { @@ -74,7 +74,7 @@ namespace OpenMetaverse.TestClient if (!Client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(rootPrim.ParentID, out rootPrim)) return "Cannot find root prim for requested object"; else - Logger.DebugLog("Set root prim to " + rootPrim.ID.ToString(), Client); + Logger.DebugLog($"Set root prim to {rootPrim.ID}", Client); } // Find all of the child objects linked to this root @@ -93,30 +93,24 @@ namespace OpenMetaverse.TestClient #region Set Linkset Permissions PermCount = 0; - if ((Perms & PermissionMask.Modify) == PermissionMask.Modify) - Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Modify, true); - else - Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Modify, false); + Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, + PermissionMask.Modify, (Perms & PermissionMask.Modify) == PermissionMask.Modify); PermsSent = true; if (!GotPermissionsEvent.WaitOne(1000 * 30, false)) return "Failed to set the modify bit, permissions in an unknown state"; PermCount = 0; - if ((Perms & PermissionMask.Copy) == PermissionMask.Copy) - Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Copy, true); - else - Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Copy, false); + Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, + PermissionMask.Copy, (Perms & PermissionMask.Copy) == PermissionMask.Copy); PermsSent = true; if (!GotPermissionsEvent.WaitOne(1000 * 30, false)) return "Failed to set the copy bit, permissions in an unknown state"; PermCount = 0; - if ((Perms & PermissionMask.Transfer) == PermissionMask.Transfer) - Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Transfer, true); - else - Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Transfer, false); + Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, + PermissionMask.Transfer, (Perms & PermissionMask.Transfer) == PermissionMask.Transfer); PermsSent = true; if (!GotPermissionsEvent.WaitOne(1000 * 30, false)) @@ -141,21 +135,20 @@ namespace OpenMetaverse.TestClient } } - return "Set permissions to " + Perms.ToString() + " on " + localIDs.Count + " objects and " + taskItems + " inventory items"; + return $"Set permissions to {Perms} on {localIDs.Count} objects and {taskItems} inventory items"; } void Objects_OnObjectProperties(object sender, ObjectPropertiesEventArgs e) { - if (PermsSent) - { - if (Objects.ContainsKey(e.Properties.ObjectID)) - { - // FIXME: Confirm the current operation against properties.Permissions.NextOwnerMask + if (!PermsSent) { return; } - ++PermCount; - if (PermCount >= Objects.Count) - GotPermissionsEvent.Set(); - } + if (Objects.ContainsKey(e.Properties.ObjectID)) + { + // FIXME: Confirm the current operation against properties.Permissions.NextOwnerMask + + ++PermCount; + if (PermCount >= Objects.Count) + GotPermissionsEvent.Set(); } } } diff --git a/Programs/examples/TestClient/Commands/Prims/DeRezObjectCommand.cs b/Programs/examples/TestClient/Commands/Prims/DeRezObjectCommand.cs index cdbd1033..c1ca8af5 100644 --- a/Programs/examples/TestClient/Commands/Prims/DeRezObjectCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/DeRezObjectCommand.cs @@ -32,7 +32,7 @@ } else { - return "Could not find prim " + primID.ToString(); + return "Could not find prim " + primID; } } else diff --git a/Programs/examples/TestClient/Commands/Prims/DownloadTextureCommand.cs b/Programs/examples/TestClient/Commands/Prims/DownloadTextureCommand.cs index 95b889bf..7b56e91d 100644 --- a/Programs/examples/TestClient/Commands/Prims/DownloadTextureCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/DownloadTextureCommand.cs @@ -36,7 +36,7 @@ namespace OpenMetaverse.TestClient if (args.Length > 1) { - if (!Int32.TryParse(args[1], out discardLevel)) + if (!int.TryParse(args[1], out discardLevel)) return "Usage: downloadtexture [texture-uuid] [discardlevel]"; } @@ -51,16 +51,16 @@ namespace OpenMetaverse.TestClient try { File.WriteAllBytes(Asset.AssetID + ".jp2", Asset.AssetData); } catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } - return String.Format("Saved {0}.jp2 ({1}x{2})", Asset.AssetID, Asset.Image.Width, Asset.Image.Height); + return $"Saved {Asset.AssetID}.jp2 ({Asset.Image.Width}x{Asset.Image.Height})"; } else { - return "Failed to decode texture " + TextureID.ToString(); + return "Failed to decode texture " + TextureID; } } else if (resultState == TextureRequestState.NotFound) { - return "Simulator reported texture not found: " + TextureID.ToString(); + return "Simulator reported texture not found: " + TextureID; } else { diff --git a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs index ee46009a..b5f2bb84 100644 --- a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs @@ -21,10 +21,10 @@ namespace OpenMetaverse.TestClient public ExportCommand(TestClient testClient) { - testClient.Objects.ObjectPropertiesFamily += new EventHandler(Objects_OnObjectPropertiesFamily); + testClient.Objects.ObjectPropertiesFamily += Objects_OnObjectPropertiesFamily; - testClient.Objects.ObjectProperties += new EventHandler(Objects_OnObjectProperties); - testClient.Avatars.ViewerEffectPointAt += new EventHandler(Avatars_ViewerEffectPointAt); + testClient.Objects.ObjectProperties += Objects_OnObjectProperties; + testClient.Avatars.ViewerEffectPointAt += Avatars_ViewerEffectPointAt; Name = "export"; Description = "Exports an object to an xml file. Usage: export uuid outputfile.xml"; @@ -152,7 +152,7 @@ namespace OpenMetaverse.TestClient } else { - return "Couldn't find UUID " + id.ToString() + " in the " + + return "Couldn't find UUID " + id + " in the " + Client.Network.CurrentSim.ObjectsPrimitives.Count + "objects currently indexed in the current simulator"; } @@ -187,27 +187,20 @@ namespace OpenMetaverse.TestClient lock (Textures) Textures.Remove(asset.AssetID); - if (state == TextureRequestState.Finished) + try { File.WriteAllBytes(asset.AssetID + ".jp2", asset.AssetData); } + catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client); } + + if (asset.Decode()) { - try { File.WriteAllBytes(asset.AssetID + ".jp2", asset.AssetData); } + try { File.WriteAllBytes(asset.AssetID + ".tga", asset.Image.ExportTGA()); } catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client); } - - if (asset.Decode()) - { - try { File.WriteAllBytes(asset.AssetID + ".tga", asset.Image.ExportTGA()); } - catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client); } - } - else - { - Logger.Log("Failed to decode image " + asset.AssetID, Helpers.LogLevel.Error, Client); - } - - Logger.Log("Finished downloading image " + asset.AssetID, Helpers.LogLevel.Info, Client); } else { - Logger.Log("Failed to download image " + asset.AssetID + ":" + state, Helpers.LogLevel.Warning, Client); + Logger.Log("Failed to decode image " + asset.AssetID, Helpers.LogLevel.Error, Client); } + + Logger.Log("Finished downloading image " + asset.AssetID, Helpers.LogLevel.Info, Client); } } diff --git a/Programs/examples/TestClient/Commands/Prims/ExportParticlesCommand.cs b/Programs/examples/TestClient/Commands/Prims/ExportParticlesCommand.cs index e01baf90..a339eb25 100644 --- a/Programs/examples/TestClient/Commands/Prims/ExportParticlesCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ExportParticlesCommand.cs @@ -80,25 +80,38 @@ namespace OpenMetaverse.TestClient lsl.Append("," + Environment.NewLine); - lsl.Append(" PSYS_PART_START_ALPHA, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartColor.A) + "," + Environment.NewLine); - lsl.Append(" PSYS_PART_END_ALPHA, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndColor.A) + "," + Environment.NewLine); + lsl.Append(" PSYS_PART_START_ALPHA, " + + $"{exportPrim.ParticleSys.PartStartColor.A:0.00000}" + "," + Environment.NewLine); + lsl.Append(" PSYS_PART_END_ALPHA, " + + $"{exportPrim.ParticleSys.PartEndColor.A:0.00000}" + "," + Environment.NewLine); lsl.Append(" PSYS_PART_START_COLOR, " + exportPrim.ParticleSys.PartStartColor.ToRGBString() + "," + Environment.NewLine); lsl.Append(" PSYS_PART_END_COLOR, " + exportPrim.ParticleSys.PartEndColor.ToRGBString() + "," + Environment.NewLine); - lsl.Append(" PSYS_PART_START_SCALE, <" + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartScaleX) + ", " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartScaleY) + ", 0>, " + Environment.NewLine); - lsl.Append(" PSYS_PART_END_SCALE, <" + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndScaleX) + ", " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndScaleY) + ", 0>, " + Environment.NewLine); - lsl.Append(" PSYS_PART_MAX_AGE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartMaxAge) + "," + Environment.NewLine); - lsl.Append(" PSYS_SRC_MAX_AGE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.MaxAge) + "," + Environment.NewLine); - lsl.Append(" PSYS_SRC_ACCEL, " + exportPrim.ParticleSys.PartAcceleration.ToString() + "," + Environment.NewLine); - lsl.Append(" PSYS_SRC_BURST_PART_COUNT, " + String.Format("{0:0}", exportPrim.ParticleSys.BurstPartCount) + "," + Environment.NewLine); - lsl.Append(" PSYS_SRC_BURST_RADIUS, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstRadius) + "," + Environment.NewLine); - lsl.Append(" PSYS_SRC_BURST_RATE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstRate) + "," + Environment.NewLine); - lsl.Append(" PSYS_SRC_BURST_SPEED_MIN, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstSpeedMin) + "," + Environment.NewLine); - lsl.Append(" PSYS_SRC_BURST_SPEED_MAX, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstSpeedMax) + "," + Environment.NewLine); - lsl.Append(" PSYS_SRC_INNERANGLE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.InnerAngle) + "," + Environment.NewLine); - lsl.Append(" PSYS_SRC_OUTERANGLE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.OuterAngle) + "," + Environment.NewLine); - lsl.Append(" PSYS_SRC_OMEGA, " + exportPrim.ParticleSys.AngularVelocity.ToString() + "," + Environment.NewLine); - lsl.Append(" PSYS_SRC_TEXTURE, (key)\"" + exportPrim.ParticleSys.Texture.ToString() + "\"," + Environment.NewLine); - lsl.Append(" PSYS_SRC_TARGET_KEY, (key)\"" + exportPrim.ParticleSys.Target.ToString() + "\"" + Environment.NewLine); + lsl.Append(" PSYS_PART_START_SCALE, <" + + $"{exportPrim.ParticleSys.PartStartScaleX:0.00000}" + ", " + + $"{exportPrim.ParticleSys.PartStartScaleY:0.00000}" + ", 0>, " + Environment.NewLine); + lsl.Append(" PSYS_PART_END_SCALE, <" + + $"{exportPrim.ParticleSys.PartEndScaleX:0.00000}" + ", " + + $"{exportPrim.ParticleSys.PartEndScaleY:0.00000}" + ", 0>, " + Environment.NewLine); + lsl.Append(" PSYS_PART_MAX_AGE, " + $"{exportPrim.ParticleSys.PartMaxAge:0.00000}" + "," + Environment.NewLine); + lsl.Append(" PSYS_SRC_MAX_AGE, " + $"{exportPrim.ParticleSys.MaxAge:0.00000}" + "," + Environment.NewLine); + lsl.Append(" PSYS_SRC_ACCEL, " + exportPrim.ParticleSys.PartAcceleration + "," + Environment.NewLine); + lsl.Append(" PSYS_SRC_BURST_PART_COUNT, " + + $"{exportPrim.ParticleSys.BurstPartCount:0}" + "," + Environment.NewLine); + lsl.Append(" PSYS_SRC_BURST_RADIUS, " + + $"{exportPrim.ParticleSys.BurstRadius:0.00000}" + "," + Environment.NewLine); + lsl.Append(" PSYS_SRC_BURST_RATE, " + + $"{exportPrim.ParticleSys.BurstRate:0.00000}" + "," + Environment.NewLine); + lsl.Append(" PSYS_SRC_BURST_SPEED_MIN, " + + $"{exportPrim.ParticleSys.BurstSpeedMin:0.00000}" + "," + Environment.NewLine); + lsl.Append(" PSYS_SRC_BURST_SPEED_MAX, " + + $"{exportPrim.ParticleSys.BurstSpeedMax:0.00000}" + "," + Environment.NewLine); + lsl.Append(" PSYS_SRC_INNERANGLE, " + + $"{exportPrim.ParticleSys.InnerAngle:0.00000}" + "," + Environment.NewLine); + lsl.Append(" PSYS_SRC_OUTERANGLE, " + + $"{exportPrim.ParticleSys.OuterAngle:0.00000}" + "," + Environment.NewLine); + lsl.Append(" PSYS_SRC_OMEGA, " + exportPrim.ParticleSys.AngularVelocity + "," + Environment.NewLine); + lsl.Append(" PSYS_SRC_TEXTURE, (key)\"" + exportPrim.ParticleSys.Texture + "\"," + Environment.NewLine); + lsl.Append(" PSYS_SRC_TARGET_KEY, (key)\"" + exportPrim.ParticleSys.Target + "\"" + Environment.NewLine); lsl.Append(" ]);" + Environment.NewLine); lsl.Append(" }" + Environment.NewLine); @@ -116,7 +129,7 @@ namespace OpenMetaverse.TestClient } } - return "Couldn't find prim " + id.ToString(); + return "Couldn't find prim " + id; } } } diff --git a/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs b/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs index 2ceae9bc..0a65b29f 100644 --- a/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs @@ -12,7 +12,7 @@ namespace OpenMetaverse.TestClient public FindObjectsCommand(TestClient testClient) { - testClient.Objects.ObjectProperties += new EventHandler(Objects_OnObjectProperties); + testClient.Objects.ObjectProperties += Objects_OnObjectProperties; Name = "findobjects"; Description = "Finds all objects, which name contains search-string. " + @@ -26,7 +26,7 @@ namespace OpenMetaverse.TestClient if ((args.Length < 1) || (args.Length > 2)) return "Usage: findobjects [radius] "; float radius = float.Parse(args[0]); - string searchString = (args.Length > 1) ? args[1] : String.Empty; + string searchString = (args.Length > 1) ? args[1] : string.Empty; // *** get current location *** Vector3 location = Client.Self.SimPosition; diff --git a/Programs/examples/TestClient/Commands/Prims/FindTextureCommand.cs b/Programs/examples/TestClient/Commands/Prims/FindTextureCommand.cs index d8a9047f..325babce 100644 --- a/Programs/examples/TestClient/Commands/Prims/FindTextureCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/FindTextureCommand.cs @@ -20,7 +20,7 @@ namespace OpenMetaverse.TestClient if (args.Length != 2) return "Usage: findtexture [face-index] [texture-uuid]"; - if (Int32.TryParse(args[0], out faceIndex) && + if (int.TryParse(args[0], out faceIndex) && UUID.TryParse(args[1], out textureID)) { Client.Network.CurrentSim.ObjectsPrimitives.ForEach( @@ -30,8 +30,8 @@ namespace OpenMetaverse.TestClient { if (prim.Textures.FaceTextures[faceIndex].TextureID == textureID) { - Logger.Log(String.Format("Primitive {0} ({1}) has face index {2} set to {3}", - prim.ID.ToString(), prim.LocalID, faceIndex, textureID.ToString()), + Logger.Log( + $"Primitive {prim.ID.ToString()} ({prim.LocalID}) has face index {faceIndex} set to {textureID.ToString()}", Helpers.LogLevel.Info, Client); } } diff --git a/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs b/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs index b947d99b..49ac79ae 100644 --- a/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Threading; using System.IO; +using System.Linq; using OpenMetaverse.StructuredData; namespace OpenMetaverse.TestClient @@ -110,7 +111,7 @@ namespace OpenMetaverse.TestClient if (!primDone.WaitOne(10000, false)) return "Rez failed, timed out while creating the root prim."; - Client.Objects.SetPosition(Client.Network.CurrentSim, primsCreated[primsCreated.Count - 1].LocalID, linkset.RootPrim.Position); + Client.Objects.SetPosition(Client.Network.CurrentSim, primsCreated[^1].LocalID, linkset.RootPrim.Position); state = ImporterState.RezzingChildren; @@ -125,22 +126,17 @@ namespace OpenMetaverse.TestClient if (!primDone.WaitOne(10000, false)) return "Rez failed, timed out while creating child prim."; - Client.Objects.SetPosition(Client.Network.CurrentSim, primsCreated[primsCreated.Count - 1].LocalID, currentPosition); + Client.Objects.SetPosition(Client.Network.CurrentSim, primsCreated[^1].LocalID, currentPosition); } // Create a list of the local IDs of the newly created prims - List primIDs = new List(primsCreated.Count); - primIDs.Add(rootLocalID); // Root prim is first in list. - + List primIDs = new List(primsCreated.Count) { rootLocalID /*Root prim is first in list.*/ }; + if (linkset.Children.Count != 0) { // Add the rest of the prims to the list of local IDs - foreach (Primitive prim in primsCreated) - { - if (prim.LocalID != rootLocalID) - primIDs.Add(prim.LocalID); - } + primIDs.AddRange(from prim in primsCreated where prim.LocalID != rootLocalID select prim.LocalID); linkQueue = new List(primIDs.Count); linkQueue.AddRange(primIDs); @@ -214,12 +210,12 @@ namespace OpenMetaverse.TestClient Client.Objects.SetSculpt(e.Simulator, prim.LocalID, currentPrim.Sculpt); } - if (currentPrim.Properties!= null && !String.IsNullOrEmpty(currentPrim.Properties.Name)) + if (currentPrim.Properties!= null && !string.IsNullOrEmpty(currentPrim.Properties.Name)) { Client.Objects.SetName(e.Simulator, prim.LocalID, currentPrim.Properties.Name); } - if (currentPrim.Properties != null && !String.IsNullOrEmpty(currentPrim.Properties.Description)) + if (currentPrim.Properties != null && !string.IsNullOrEmpty(currentPrim.Properties.Description)) { Client.Objects.SetDescription(e.Simulator, prim.LocalID, currentPrim.Properties.Description); } diff --git a/Programs/examples/TestClient/Commands/Prims/PrimInfoCommand.cs b/Programs/examples/TestClient/Commands/Prims/PrimInfoCommand.cs index 0b568123..a852816c 100644 --- a/Programs/examples/TestClient/Commands/Prims/PrimInfoCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/PrimInfoCommand.cs @@ -27,29 +27,27 @@ namespace OpenMetaverse.TestClient if (target != null) { - if (target.Text != String.Empty) + if (target.Text != string.Empty) { Logger.Log("Text: " + target.Text, Helpers.LogLevel.Info, Client); } if(target.Light != null) - Logger.Log("Light: " + target.Light.ToString(), Helpers.LogLevel.Info, Client); + Logger.Log("Light: " + target.Light, Helpers.LogLevel.Info, Client); if (target.ParticleSys.CRC != 0) - Logger.Log("Particles: " + target.ParticleSys.ToString(), Helpers.LogLevel.Info, Client); + Logger.Log("Particles: " + target.ParticleSys, Helpers.LogLevel.Info, Client); Logger.Log("TextureEntry:", Helpers.LogLevel.Info, Client); if (target.Textures != null) { - Logger.Log(String.Format("Default texure: {0}", - target.Textures.DefaultTexture.TextureID.ToString()), + Logger.Log($"Default texure: {target.Textures.DefaultTexture.TextureID.ToString()}", Helpers.LogLevel.Info); for (int i = 0; i < target.Textures.FaceTextures.Length; i++) { if (target.Textures.FaceTextures[i] != null) { - Logger.Log(String.Format("Face {0}: {1}", i, - target.Textures.FaceTextures[i].TextureID.ToString()), + Logger.Log($"Face {i}: {target.Textures.FaceTextures[i].TextureID.ToString()}", Helpers.LogLevel.Info, Client); } } @@ -63,10 +61,8 @@ namespace OpenMetaverse.TestClient EventHandler propsCallback = delegate(object sender, ObjectPropertiesEventArgs e) { - Logger.Log(String.Format( - "Category: {0}\nFolderID: {1}\nFromTaskID: {2}\nInventorySerial: {3}\nItemID: {4}\nCreationDate: {5}", - e.Properties.Category, e.Properties.FolderID, e.Properties.FromTaskID, e.Properties.InventorySerial, - e.Properties.ItemID, e.Properties.CreationDate), Helpers.LogLevel.Info); + Logger.Log( + $"Category: {e.Properties.Category}\nFolderID: {e.Properties.FolderID}\nFromTaskID: {e.Properties.FromTaskID}\nInventorySerial: {e.Properties.InventorySerial}\nItemID: {e.Properties.ItemID}\nCreationDate: {e.Properties.CreationDate}", Helpers.LogLevel.Info); propsEvent.Set(); }; @@ -81,7 +77,7 @@ namespace OpenMetaverse.TestClient } else { - return "Could not find prim " + primID.ToString(); + return "Could not find prim " + primID; } } else diff --git a/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs b/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs index 90f7e0f2..5dc7ac6b 100644 --- a/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs @@ -28,8 +28,8 @@ namespace OpenMetaverse.TestClient Regex regexPrimName = new Regex(predicatPrim.ToLower()); // Print result - Logger.Log(string.Format("Searching prim for [{0}] ({1} prims loaded in simulator)\n", predicatPrim, - Client.Network.CurrentSim.ObjectsPrimitives.Count), Helpers.LogLevel.Info, Client); + Logger.Log( + $"Searching prim for [{predicatPrim}] ({Client.Network.CurrentSim.ObjectsPrimitives.Count} prims loaded in simulator)\n", Helpers.LogLevel.Info, Client); Client.Network.CurrentSim.ObjectsPrimitives.ForEach( delegate(Primitive prim) @@ -55,8 +55,8 @@ namespace OpenMetaverse.TestClient name = prim.Properties.Name; description = prim.Properties.Description; } - Logger.Log(string.Format("\nNAME={0}\nID = {1}\nFLAGS = {2}\nTEXT = '{3}'\nDESC='{4}'", name, - prim.ID, prim.Flags.ToString(), prim.Text, description), Helpers.LogLevel.Info, Client); + Logger.Log( + $"\nNAME={name}\nID = {prim.ID}\nFLAGS = {prim.Flags.ToString()}\nTEXT = '{prim.Text}'\nDESC='{description}'", Helpers.LogLevel.Info, Client); } } ); diff --git a/Programs/examples/TestClient/Commands/Prims/TexturesCommand.cs b/Programs/examples/TestClient/Commands/Prims/TexturesCommand.cs index f8cbaf5f..965f4931 100644 --- a/Programs/examples/TestClient/Commands/Prims/TexturesCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/TexturesCommand.cs @@ -17,7 +17,7 @@ namespace OpenMetaverse.TestClient Description = "Turns automatic texture downloading on or off. Usage: textures [on/off]"; Category = CommandCategory.Objects; - testClient.Objects.ObjectUpdate += new EventHandler(Objects_OnNewPrim); + testClient.Objects.ObjectUpdate += Objects_OnNewPrim; testClient.Objects.AvatarUpdate += Objects_OnNewAvatar; } @@ -102,10 +102,7 @@ namespace OpenMetaverse.TestClient { if (state == TextureRequestState.Finished && enabled && alreadyRequested.ContainsKey(asset.AssetID)) { - if (state == TextureRequestState.Finished) - Logger.DebugLog(String.Format("Finished downloading texture {0} ({1} bytes)", asset.AssetID, asset.AssetData.Length)); - else - Logger.Log("Failed to download texture " + asset.AssetID + ": " + state, Helpers.LogLevel.Warning); + Logger.DebugLog($"Finished downloading texture {asset.AssetID} ({asset.AssetData.Length} bytes)"); } } } diff --git a/Programs/examples/TestClient/Commands/Stats/DilationCommand.cs b/Programs/examples/TestClient/Commands/Stats/DilationCommand.cs index 0c7bfec8..c45d5df6 100644 --- a/Programs/examples/TestClient/Commands/Stats/DilationCommand.cs +++ b/Programs/examples/TestClient/Commands/Stats/DilationCommand.cs @@ -11,7 +11,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { - return "Dilation is " + Client.Network.CurrentSim.Stats.Dilation.ToString(); + return "Dilation is " + Client.Network.CurrentSim.Stats.Dilation; } } } \ No newline at end of file diff --git a/Programs/examples/TestClient/Commands/Stats/NetstatsCommand.cs b/Programs/examples/TestClient/Commands/Stats/NetstatsCommand.cs index 91bd6d4b..a313dd8a 100644 --- a/Programs/examples/TestClient/Commands/Stats/NetstatsCommand.cs +++ b/Programs/examples/TestClient/Commands/Stats/NetstatsCommand.cs @@ -15,7 +15,6 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { - StringBuilder output = new StringBuilder(); if (!Client.Settings.TRACK_UTILIZATION) { return "TRACK_UTILIZATION is not enabled in Settings, statistics not available"; @@ -72,19 +71,19 @@ namespace OpenMetaverse.TestClient packetOutput.AppendFormat("{0,30}|{1,4}|{2,4}|{3,-10}|{4,-10}|" + System.Environment.NewLine, "Packet Totals", packetsSentCount, packetsRecvCount, FormatBytes(packetBytesSent), FormatBytes(packetBytesRecv)); - return System.Environment.NewLine + capsOutput.ToString() + System.Environment.NewLine + System.Environment.NewLine + packetOutput.ToString(); + return System.Environment.NewLine + capsOutput + System.Environment.NewLine + System.Environment.NewLine + packetOutput; } public string FormatBytes(long bytes) { const int scale = 1024; - string[] orders = new string[] { "GB", "MB", "KB", "Bytes" }; + string[] orders = new[] { "GB", "MB", "KB", "Bytes" }; long max = (long)Math.Pow(scale, orders.Length - 1); foreach (string order in orders) { if ( bytes > max ) - return string.Format("{0:##.##} {1}", decimal.Divide( bytes, max ), order); + return $"{decimal.Divide(bytes, max):##.##} {order}"; max /= scale; } diff --git a/Programs/examples/TestClient/Commands/Stats/RegionInfoCommand.cs b/Programs/examples/TestClient/Commands/Stats/RegionInfoCommand.cs index 1834a843..23ba205c 100644 --- a/Programs/examples/TestClient/Commands/Stats/RegionInfoCommand.cs +++ b/Programs/examples/TestClient/Commands/Stats/RegionInfoCommand.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Text; namespace OpenMetaverse.TestClient @@ -20,7 +21,7 @@ namespace OpenMetaverse.TestClient output.AppendLine(Client.Network.CurrentSim.ID.ToString()); uint x, y; Utils.LongToUInts(Client.Network.CurrentSim.Handle, out x, out y); - output.AppendLine(String.Format("Handle: {0} (X: {1} Y: {2})", Client.Network.CurrentSim.Handle, x, y)); + output.AppendLine($"Handle: {Client.Network.CurrentSim.Handle} (X: {x} Y: {y})"); output.Append("Access: "); output.AppendLine(Client.Network.CurrentSim.Access.ToString()); output.Append("Flags: "); @@ -42,7 +43,7 @@ namespace OpenMetaverse.TestClient output.Append("TerrainDetail3: "); output.AppendLine(Client.Network.CurrentSim.TerrainDetail3.ToString()); output.Append("Water Height: "); - output.AppendLine(Client.Network.CurrentSim.WaterHeight.ToString()); + output.AppendLine(Client.Network.CurrentSim.WaterHeight.ToString(CultureInfo.InvariantCulture)); output.Append("Datacenter:"); output.AppendLine(Client.Network.CurrentSim.ColoLocation); output.Append("CPU Ratio:"); diff --git a/Programs/examples/TestClient/Commands/Stats/StatsCommand.cs b/Programs/examples/TestClient/Commands/Stats/StatsCommand.cs index eebfb54c..1835d068 100644 --- a/Programs/examples/TestClient/Commands/Stats/StatsCommand.cs +++ b/Programs/examples/TestClient/Commands/Stats/StatsCommand.cs @@ -20,22 +20,20 @@ namespace OpenMetaverse.TestClient { foreach (var sim in Client.Network.Simulators) { - output.AppendLine(String.Format( - "[{0}] Dilation: {1} InBPS: {2} OutBPS: {3} ResentOut: {4} ResentIn: {5}", - sim.ToString(), sim.Stats.Dilation, sim.Stats.IncomingBPS, sim.Stats.OutgoingBPS, - sim.Stats.ResentPackets, sim.Stats.ReceivedResends)); + output.AppendLine( + $"[{sim}] Dilation: {sim.Stats.Dilation} InBPS: {sim.Stats.IncomingBPS} OutBPS: {sim.Stats.OutgoingBPS} ResentOut: {sim.Stats.ResentPackets} ResentIn: {sim.Stats.ReceivedResends}"); } } Simulator csim = Client.Network.CurrentSim; output.Append("Packets in the queue: " + Client.Network.InboxCount); - output.AppendLine(String.Format("FPS : {0} PhysicsFPS : {1} AgentUpdates : {2} Objects : {3} Scripted Objects : {4}", - csim.Stats.FPS, csim.Stats.PhysicsFPS, csim.Stats.AgentUpdates, csim.Stats.Objects, csim.Stats.ScriptedObjects)); - output.AppendLine(String.Format("Frame Time : {0} Net Time : {1} Image Time : {2} Physics Time : {3} Script Time : {4} Other Time : {5}", - csim.Stats.FrameTime, csim.Stats.NetTime, csim.Stats.ImageTime, csim.Stats.PhysicsTime, csim.Stats.ScriptTime, csim.Stats.OtherTime)); - output.AppendLine(String.Format("Agents : {0} Child Agents : {1} Active Scripts : {2}", - csim.Stats.Agents, csim.Stats.ChildAgents, csim.Stats.ActiveScripts)); + output.AppendLine( + $"FPS : {csim.Stats.FPS} PhysicsFPS : {csim.Stats.PhysicsFPS} AgentUpdates : {csim.Stats.AgentUpdates} Objects : {csim.Stats.Objects} Scripted Objects : {csim.Stats.ScriptedObjects}"); + output.AppendLine( + $"Frame Time : {csim.Stats.FrameTime} Net Time : {csim.Stats.NetTime} Image Time : {csim.Stats.ImageTime} Physics Time : {csim.Stats.PhysicsTime} Script Time : {csim.Stats.ScriptTime} Other Time : {csim.Stats.OtherTime}"); + output.AppendLine( + $"Agents : {csim.Stats.Agents} Child Agents : {csim.Stats.ChildAgents} Active Scripts : {csim.Stats.ActiveScripts}"); return output.ToString(); } diff --git a/Programs/examples/TestClient/Commands/System/HelpCommand.cs b/Programs/examples/TestClient/Commands/System/HelpCommand.cs index f84df965..e98cfed7 100644 --- a/Programs/examples/TestClient/Commands/System/HelpCommand.cs +++ b/Programs/examples/TestClient/Commands/System/HelpCommand.cs @@ -26,21 +26,17 @@ namespace OpenMetaverse.TestClient CommandCategory cc; foreach (Command c in Client.Commands.Values) - { - if (c.Category.Equals(null)) - cc = CommandCategory.Unknown; - else - cc = c.Category; + { + cc = c.Category.Equals(null) ? CommandCategory.Unknown : c.Category; if (CommandTree.ContainsKey(cc)) CommandTree[cc].Add(c); else { - List l = new List(); - l.Add(c); + List l = new List { c }; CommandTree.Add(cc, l); } - } + } foreach (KeyValuePair> kvp in CommandTree) { diff --git a/Programs/examples/TestClient/Commands/System/LogPacketCommand.cs b/Programs/examples/TestClient/Commands/System/LogPacketCommand.cs index cf9728d3..6a118288 100644 --- a/Programs/examples/TestClient/Commands/System/LogPacketCommand.cs +++ b/Programs/examples/TestClient/Commands/System/LogPacketCommand.cs @@ -23,22 +23,20 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { if (args.Length != 2) - return string.Format("Usage: {0} no-of-packets filename", Name); + return $"Usage: {Name} no-of-packets filename"; string rawNumberOfPackets = args[0]; string path = args[1]; int numberOfPackets; if (!int.TryParse(args[0], out numberOfPackets) || numberOfPackets <= 0) - return string.Format( - "{0} is not a valid number of packets for {1}", rawNumberOfPackets, m_client.Self.Name); + return $"{rawNumberOfPackets} is not a valid number of packets for {m_client.Self.Name}"; lock (this) { if (m_isLogging) - return string.Format( - "Still waiting to finish logging {0} packets for {1}", - m_packetsToLogRemaining, m_client.Self.Name); + return + $"Still waiting to finish logging {m_packetsToLogRemaining} packets for {m_client.Self.Name}"; try { @@ -46,7 +44,7 @@ namespace OpenMetaverse.TestClient } catch (Exception e) { - return string.Format("Could not open file with path [{0}], exception {1}", path, e); + return $"Could not open file with path [{path}], exception {e}"; } m_isLogging = true; @@ -54,7 +52,7 @@ namespace OpenMetaverse.TestClient m_packetsToLogRemaining = numberOfPackets; m_client.Network.RegisterCallback(PacketType.Default, HandlePacket); - return string.Format("Now logging {0} packets for {1}", m_packetsToLogRemaining, m_client.Self.Name); + return $"Now logging {m_packetsToLogRemaining} packets for {m_client.Self.Name}"; } /// diff --git a/Programs/examples/TestClient/Commands/System/SetMasterCommand.cs b/Programs/examples/TestClient/Commands/System/SetMasterCommand.cs index d911cf70..0c36d261 100644 --- a/Programs/examples/TestClient/Commands/System/SetMasterCommand.cs +++ b/Programs/examples/TestClient/Commands/System/SetMasterCommand.cs @@ -48,7 +48,7 @@ namespace OpenMetaverse.TestClient Client.Self.InstantMessage( Client.MasterKey, "You are now my master. IM me with \"help\" for a command list."); - return String.Format("Master set to {0} ({1})", masterName, Client.MasterKey.ToString()); + return $"Master set to {masterName} ({Client.MasterKey.ToString()})"; } private void KeyResolvHandler(object sender, DirPeopleReplyEventArgs e) diff --git a/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs b/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs index fae52d76..4d15f826 100644 --- a/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs +++ b/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs @@ -34,7 +34,7 @@ namespace OpenMetaverse.TestClient } } - return "Master set to " + Client.MasterKey.ToString(); + return "Master set to " + Client.MasterKey; } } } diff --git a/Programs/examples/TestClient/Commands/System/ShowEffectsCommand.cs b/Programs/examples/TestClient/Commands/System/ShowEffectsCommand.cs index a299a162..278d29a5 100644 --- a/Programs/examples/TestClient/Commands/System/ShowEffectsCommand.cs +++ b/Programs/examples/TestClient/Commands/System/ShowEffectsCommand.cs @@ -12,9 +12,9 @@ namespace OpenMetaverse.TestClient Description = "Prints out information for every viewer effect that is received. Usage: showeffects [on/off]"; Category = CommandCategory.Other; - testClient.Avatars.ViewerEffect += new EventHandler(Avatars_ViewerEffect); - testClient.Avatars.ViewerEffectPointAt += new EventHandler(Avatars_ViewerEffectPointAt); - testClient.Avatars.ViewerEffectLookAt += new EventHandler(Avatars_ViewerEffectLookAt); + testClient.Avatars.ViewerEffect += Avatars_ViewerEffect; + testClient.Avatars.ViewerEffectPointAt += Avatars_ViewerEffectPointAt; + testClient.Avatars.ViewerEffectLookAt += Avatars_ViewerEffectLookAt; } void Avatars_ViewerEffectLookAt(object sender, ViewerEffectLookAtEventArgs e) diff --git a/Programs/examples/TestClient/Commands/System/SleepCommand.cs b/Programs/examples/TestClient/Commands/System/SleepCommand.cs index 478c916f..6865b6db 100644 --- a/Programs/examples/TestClient/Commands/System/SleepCommand.cs +++ b/Programs/examples/TestClient/Commands/System/SleepCommand.cs @@ -17,23 +17,33 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { int seconds; - if (args.Length != 1 || !Int32.TryParse(args[0], out seconds)) + if (args.Length != 1 || !int.TryParse(args[0], out seconds)) return "Usage: sleep [seconds]"; - AgentPausePacket pause = new AgentPausePacket(); - pause.AgentData.AgentID = Client.Self.AgentID; - pause.AgentData.SessionID = Client.Self.SessionID; - pause.AgentData.SerialNum = sleepSerialNum++; + AgentPausePacket pause = new AgentPausePacket + { + AgentData = + { + AgentID = Client.Self.AgentID, + SessionID = Client.Self.SessionID, + SerialNum = sleepSerialNum++ + } + }; Client.Network.SendPacket(pause); // Sleep System.Threading.Thread.Sleep(seconds * 1000); - AgentResumePacket resume = new AgentResumePacket(); - resume.AgentData.AgentID = Client.Self.AgentID; - resume.AgentData.SessionID = Client.Self.SessionID; - resume.AgentData.SerialNum = pause.AgentData.SerialNum; + AgentResumePacket resume = new AgentResumePacket + { + AgentData = + { + AgentID = Client.Self.AgentID, + SessionID = Client.Self.SessionID, + SerialNum = pause.AgentData.SerialNum + } + }; Client.Network.SendPacket(resume); diff --git a/Programs/examples/TestClient/Commands/Voice/ParcelVoiceInfo.cs b/Programs/examples/TestClient/Commands/Voice/ParcelVoiceInfo.cs index 5bfa737e..62fa2252 100644 --- a/Programs/examples/TestClient/Commands/Voice/ParcelVoiceInfo.cs +++ b/Programs/examples/TestClient/Commands/Voice/ParcelVoiceInfo.cs @@ -37,7 +37,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { if (!IsVoiceManagerRunning()) - return String.Format("VoiceManager not running for {0}", fromAgentID); + return $"VoiceManager not running for {fromAgentID}"; if (!Client.VoiceManager.RequestParcelVoiceInfo()) { @@ -45,13 +45,13 @@ namespace OpenMetaverse.TestClient } ParcelVoiceInfoEvent.WaitOne(30 * 1000, false); - if (String.IsNullOrEmpty(VoiceRegionName) && -1 == VoiceLocalID) + if (string.IsNullOrEmpty(VoiceRegionName) && -1 == VoiceLocalID) { - return String.Format("Parcel Voice Info request for {0} failed.", Client.Self.Name); + return $"Parcel Voice Info request for {Client.Self.Name} failed."; } - return String.Format("Parcel Voice Info request for {0}: region name \"{1}\", parcel local id {2}, channel URI {3}", - Client.Self.Name, VoiceRegionName, VoiceLocalID, VoiceChannelURI); + return + $"Parcel Voice Info request for {Client.Self.Name}: region name \"{VoiceRegionName}\", parcel local id {VoiceLocalID}, channel URI {VoiceChannelURI}"; } void Voice_OnParcelVoiceInfo(string regionName, int localID, string channelURI) diff --git a/Programs/examples/TestClient/Commands/Voice/VoiceAcountCommand.cs b/Programs/examples/TestClient/Commands/Voice/VoiceAcountCommand.cs index d85587b5..e96d39b2 100644 --- a/Programs/examples/TestClient/Commands/Voice/VoiceAcountCommand.cs +++ b/Programs/examples/TestClient/Commands/Voice/VoiceAcountCommand.cs @@ -36,7 +36,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { if (!IsVoiceManagerRunning()) - return String.Format("VoiceManager not running for {0}", Client.Self.Name); + return $"VoiceManager not running for {Client.Self.Name}"; if (!Client.VoiceManager.RequestProvisionAccount()) { @@ -44,13 +44,12 @@ namespace OpenMetaverse.TestClient } ProvisionEvent.WaitOne(30 * 1000, false); - if (String.IsNullOrEmpty(VoiceAccount) && String.IsNullOrEmpty(VoicePassword)) + if (string.IsNullOrEmpty(VoiceAccount) && string.IsNullOrEmpty(VoicePassword)) { - return String.Format("Voice account information lookup for {0} failed.", Client.Self.Name); + return $"Voice account information lookup for {Client.Self.Name} failed."; } - return String.Format("Voice Account for {0}: user \"{1}\", password \"{2}\"", - Client.Self.Name, VoiceAccount, VoicePassword); + return $"Voice Account for {Client.Self.Name}: user \"{VoiceAccount}\", password \"{VoicePassword}\""; } void Voice_OnProvisionAccount(string username, string password) diff --git a/Programs/examples/TestClient/Parsing.cs b/Programs/examples/TestClient/Parsing.cs index d5e25d03..9a305c5f 100644 --- a/Programs/examples/TestClient/Parsing.cs +++ b/Programs/examples/TestClient/Parsing.cs @@ -46,7 +46,7 @@ namespace OpenMetaverse.TestClient } if (trimmed.Length > 0) list.Add(trimmed); - current = String.Empty; + current = string.Empty; } } else if (c == '\\') @@ -64,7 +64,7 @@ namespace OpenMetaverse.TestClient else { if (escaped) - throw new FormatException(c.ToString() + " is not an escapable character."); + throw new FormatException(c + " is not an escapable character."); current += c; } } diff --git a/Programs/examples/TestClient/Program.cs b/Programs/examples/TestClient/Program.cs index ceba5b25..bcae4842 100644 --- a/Programs/examples/TestClient/Program.cs +++ b/Programs/examples/TestClient/Program.cs @@ -30,12 +30,12 @@ namespace OpenMetaverse.TestClient List accounts = new List(); LoginDetails account; bool groupCommands = false; - string masterName = String.Empty; + string masterName = string.Empty; UUID masterKey = UUID.Zero; - string file = String.Empty; + string file = string.Empty; bool getTextures = false; bool noGUI = false; // true if to not prompt for input - string scriptFile = String.Empty; + string scriptFile = string.Empty; if (arguments["groupcommands"] != null) groupCommands = true; @@ -48,7 +48,7 @@ namespace OpenMetaverse.TestClient if (arguments["loginuri"] != null) LoginURI = arguments["loginuri"]; - if (String.IsNullOrEmpty(LoginURI)) + if (string.IsNullOrEmpty(LoginURI)) LoginURI = Settings.AGNI_LOGIN_SERVER; Logger.Log("Using login URI " + LoginURI, Helpers.LogLevel.Info); @@ -89,7 +89,7 @@ namespace OpenMetaverse.TestClient while ((line = reader.ReadLine()) != null) { lineNumber++; - string[] tokens = line.Trim().Split(new char[] {' ', ','}); + string[] tokens = line.Trim().Split(' ', ','); if (tokens.Length >= 3) { @@ -105,8 +105,8 @@ namespace OpenMetaverse.TestClient char sep = '/'; string[] startbits = tokens[3].Split(sep); account.StartLocation = NetworkManager.StartLocation(startbits[0], - Int32.Parse(startbits[1]), - Int32.Parse(startbits[2]), Int32.Parse(startbits[3])); + int.Parse(startbits[1]), + int.Parse(startbits[2]), int.Parse(startbits[3])); } accounts.Add(account); @@ -155,15 +155,15 @@ namespace OpenMetaverse.TestClient { char sep = '/'; string[] startbits = arguments["startpos"].Split(sep); - a.StartLocation = NetworkManager.StartLocation(startbits[0], Int32.Parse(startbits[1]), - Int32.Parse(startbits[2]), Int32.Parse(startbits[3])); + a.StartLocation = NetworkManager.StartLocation(startbits[0], int.Parse(startbits[1]), + int.Parse(startbits[2]), int.Parse(startbits[3])); } } // Login the accounts and run the input loop ClientManager.Instance.Start(accounts, getTextures); - if (!String.IsNullOrEmpty(scriptFile)) + if (!string.IsNullOrEmpty(scriptFile)) ClientManager.Instance.DoCommandAll("script " + scriptFile, UUID.Zero); // Then Run the ClientManager normally diff --git a/Programs/examples/TestClient/TestClient.cs b/Programs/examples/TestClient/TestClient.cs index 4819b46e..ead6027c 100644 --- a/Programs/examples/TestClient/TestClient.cs +++ b/Programs/examples/TestClient/TestClient.cs @@ -15,7 +15,7 @@ namespace OpenMetaverse.TestClient public Dictionary Commands = new Dictionary(); public bool Running = true; public bool GroupCommands = false; - public string MasterName = String.Empty; + public string MasterName = string.Empty; public UUID MasterKey = UUID.Zero; public bool AllowObjectMaster = false; public ClientManager ClientManager; @@ -36,7 +36,7 @@ namespace OpenMetaverse.TestClient ClientManager = manager; updateTimer = new System.Timers.Timer(500); - updateTimer.Elapsed += new System.Timers.ElapsedEventHandler(updateTimer_Elapsed); + updateTimer.Elapsed += updateTimer_Elapsed; RegisterAllCommands(Assembly.GetExecutingAssembly()); @@ -50,9 +50,9 @@ namespace OpenMetaverse.TestClient Network.RegisterCallback(PacketType.AgentDataUpdate, AgentDataUpdateHandler); Network.LoginProgress += LoginHandler; - Objects.AvatarUpdate += new EventHandler(Objects_AvatarUpdate); - Objects.TerseObjectUpdate += new EventHandler(Objects_TerseObjectUpdate); - Network.SimChanged += new EventHandler(Network_SimChanged); + Objects.AvatarUpdate += Objects_AvatarUpdate; + Objects.TerseObjectUpdate += Objects_TerseObjectUpdate; + Network.SimChanged += Network_SimChanged; Self.IM += Self_IM; Groups.GroupMembersReply += GroupMembersHandler; Inventory.InventoryObjectOffered += Inventory_OnInventoryObjectReceived; @@ -149,7 +149,7 @@ namespace OpenMetaverse.TestClient { if (t.IsSubclassOf(typeof(Command))) { - ConstructorInfo info = t.GetConstructor(new Type[] { typeof(TestClient) }); + ConstructorInfo info = t.GetConstructor(new[] { typeof(TestClient) }); Command command = (Command)info.Invoke(new object[] { this }); RegisterCommand(command); } @@ -188,7 +188,7 @@ namespace OpenMetaverse.TestClient GroupsEvent.Set(); } - public UUID GroupName2UUID(String groupName) + public UUID GroupName2UUID(string groupName) { UUID tryUUID; if (UUID.TryParse(groupName,out tryUUID)) @@ -201,7 +201,7 @@ namespace OpenMetaverse.TestClient lock(GroupsCache) { if (GroupsCache.Count > 0) { foreach (Group currentGroup in GroupsCache.Values) - if (String.Equals(currentGroup.Name, groupName, StringComparison.CurrentCultureIgnoreCase)) + if (string.Equals(currentGroup.Name, groupName, StringComparison.CurrentCultureIgnoreCase)) return currentGroup.ID; } }