diff --git a/LibreMetaverse.GUI/AvatarList.cs b/LibreMetaverse.GUI/AvatarList.cs index b2edbc7e..1f326c6a 100644 --- a/LibreMetaverse.GUI/AvatarList.cs +++ b/LibreMetaverse.GUI/AvatarList.cs @@ -338,22 +338,22 @@ namespace OpenMetaverse.GUI if (removedEntries != null) { - for (int i = 0; i < removedEntries.Count; i++) - RemoveAvatar(removedEntries[i]); + foreach (var entry in removedEntries) + RemoveAvatar(entry); } if (newEntries != null) { - for (int i = 0; i < newEntries.Count; i++) + foreach (var entry in newEntries) { - int index = this.Items.IndexOfKey(newEntries[i].ToString()); + int index = this.Items.IndexOfKey(entry.ToString()); if (index == -1) { Vector3 coarsePos; - if (!sim.AvatarPositions.TryGetValue(newEntries[i], out coarsePos)) + if (!sim.AvatarPositions.TryGetValue(entry, out coarsePos)) continue; - AddAvatar(newEntries[i], null, coarsePos); + AddAvatar(entry, null, coarsePos); } } } diff --git a/LibreMetaverse.Tests/PacketTests.cs b/LibreMetaverse.Tests/PacketTests.cs index ac84a36b..aed423b6 100644 --- a/LibreMetaverse.Tests/PacketTests.cs +++ b/LibreMetaverse.Tests/PacketTests.cs @@ -131,9 +131,8 @@ namespace OpenMetaverse.Tests int queryDataCount = 0; int queryRepliesCount = 0; int statusDataCount = 0; - for (int i = 0; i < splitPackets.Length; i++) + foreach (var packetData in splitPackets) { - byte[] packetData = splitPackets[i]; int len = packetData.Length - 1; DirPlacesReplyPacket packet = (DirPlacesReplyPacket)Packet.BuildPacket(packetData, ref len, packetData); diff --git a/LibreMetaverse/Assets/Archiving/OarFile.cs b/LibreMetaverse/Assets/Archiving/OarFile.cs index 6d78a040..b1f56847 100644 --- a/LibreMetaverse/Assets/Archiving/OarFile.cs +++ b/LibreMetaverse/Assets/Archiving/OarFile.cs @@ -537,9 +537,8 @@ namespace OpenMetaverse.Assets if (prim.Textures.FaceTextures != null) { - for (int i = 0; i < prim.Textures.FaceTextures.Length; i++) + foreach (var face in prim.Textures.FaceTextures) { - Primitive.TextureEntryFace face = prim.Textures.FaceTextures[i]; if (face != null) textureList[face.TextureID] = face.TextureID; } diff --git a/LibreMetaverse/Assets/AssetTypes/AssetPrim.cs b/LibreMetaverse/Assets/AssetTypes/AssetPrim.cs index 00855401..d6f475db 100644 --- a/LibreMetaverse/Assets/AssetTypes/AssetPrim.cs +++ b/LibreMetaverse/Assets/AssetTypes/AssetPrim.cs @@ -782,8 +782,9 @@ namespace OpenMetaverse.Assets if (Items != null) { OSDArray array = new OSDArray(Items.Length); - for (int i = 0; i < Items.Length; i++) - array.Add(Items[i].Serialize()); + foreach (var i in Items) + array.Add(i.Serialize()); + map["items"] = array; } diff --git a/LibreMetaverse/GridManager.cs b/LibreMetaverse/GridManager.cs index 78e313a3..d3c682b7 100644 --- a/LibreMetaverse/GridManager.cs +++ b/LibreMetaverse/GridManager.cs @@ -624,9 +624,9 @@ namespace OpenMetaverse if (m_GridLayer != null) { - for (int i = 0; i < layerData.Count; i++) + foreach (var data in layerData) { - OSDMap thisLayerData = (OSDMap)layerData[i]; + OSDMap thisLayerData = (OSDMap)data; GridLayer layer; layer.Bottom = thisLayerData["Bottom"].AsInteger(); @@ -635,7 +635,7 @@ namespace OpenMetaverse layer.Right = thisLayerData["Right"].AsInteger(); layer.ImageID = thisLayerData["ImageID"].AsUUID(); - OnGridLayer(new GridLayerEventArgs(layer)); + OnGridLayer(new GridLayerEventArgs(layer)); } } @@ -695,18 +695,18 @@ namespace OpenMetaverse GridItemType type = (GridItemType)reply.RequestData.ItemType; List items = new List(); - for (int i = 0; i < reply.Data.Length; i++) + foreach (var data in reply.Data) { - string name = Utils.BytesToString(reply.Data[i].Name); + string name = Utils.BytesToString(data.Name); switch (type) { case GridItemType.AgentLocations: MapAgentLocation location = new MapAgentLocation(); - location.GlobalX = reply.Data[i].X; - location.GlobalY = reply.Data[i].Y; + location.GlobalX = data.X; + location.GlobalY = data.Y; location.Identifier = name; - location.AvatarCount = reply.Data[i].Extra; + location.AvatarCount = data.Extra; items.Add(location); break; case GridItemType.Classified: @@ -715,28 +715,28 @@ namespace OpenMetaverse break; case GridItemType.LandForSale: MapLandForSale landsale = new MapLandForSale(); - landsale.GlobalX = reply.Data[i].X; - landsale.GlobalY = reply.Data[i].Y; - landsale.ID = reply.Data[i].ID; + landsale.GlobalX = data.X; + landsale.GlobalY = data.Y; + landsale.ID = data.ID; landsale.Name = name; - landsale.Size = reply.Data[i].Extra; - landsale.Price = reply.Data[i].Extra2; + landsale.Size = data.Extra; + landsale.Price = data.Extra2; items.Add(landsale); break; case GridItemType.MatureEvent: MapMatureEvent matureEvent = new MapMatureEvent(); - matureEvent.GlobalX = reply.Data[i].X; - matureEvent.GlobalY = reply.Data[i].Y; + matureEvent.GlobalX = data.X; + matureEvent.GlobalY = data.Y; matureEvent.Description = name; - matureEvent.Flags = (DirectoryManager.EventFlags)reply.Data[i].Extra2; + matureEvent.Flags = (DirectoryManager.EventFlags)data.Extra2; items.Add(matureEvent); break; case GridItemType.PgEvent: MapPGEvent PGEvent = new MapPGEvent(); - PGEvent.GlobalX = reply.Data[i].X; - PGEvent.GlobalY = reply.Data[i].Y; + PGEvent.GlobalX = data.X; + PGEvent.GlobalY = data.Y; PGEvent.Description = name; - PGEvent.Flags = (DirectoryManager.EventFlags)reply.Data[i].Extra2; + PGEvent.Flags = (DirectoryManager.EventFlags)data.Extra2; items.Add(PGEvent); break; case GridItemType.Popular: @@ -745,26 +745,26 @@ namespace OpenMetaverse break; case GridItemType.Telehub: MapTelehub teleHubItem = new MapTelehub(); - teleHubItem.GlobalX = reply.Data[i].X; - teleHubItem.GlobalY = reply.Data[i].Y; + teleHubItem.GlobalX = data.X; + teleHubItem.GlobalY = data.Y; items.Add(teleHubItem); break; case GridItemType.AdultLandForSale: MapAdultLandForSale adultLandsale = new MapAdultLandForSale(); - adultLandsale.GlobalX = reply.Data[i].X; - adultLandsale.GlobalY = reply.Data[i].Y; - adultLandsale.ID = reply.Data[i].ID; + adultLandsale.GlobalX = data.X; + adultLandsale.GlobalY = data.Y; + adultLandsale.ID = data.ID; adultLandsale.Name = name; - adultLandsale.Size = reply.Data[i].Extra; - adultLandsale.Price = reply.Data[i].Extra2; + adultLandsale.Size = data.Extra; + adultLandsale.Price = data.Extra2; items.Add(adultLandsale); break; case GridItemType.AdultEvent: MapAdultEvent adultEvent = new MapAdultEvent(); - adultEvent.GlobalX = reply.Data[i].X; - adultEvent.GlobalY = reply.Data[i].Y; - adultEvent.Description = Utils.BytesToString(reply.Data[i].Name); - adultEvent.Flags = (DirectoryManager.EventFlags)reply.Data[i].Extra2; + adultEvent.GlobalX = data.X; + adultEvent.GlobalY = data.Y; + adultEvent.Description = Utils.BytesToString(data.Name); + adultEvent.Flags = (DirectoryManager.EventFlags)data.Extra2; items.Add(adultEvent); break; default: diff --git a/LibreMetaverse/ImportExport/ModelUploader.cs b/LibreMetaverse/ImportExport/ModelUploader.cs index 9eb4044f..d8d6f6f1 100644 --- a/LibreMetaverse/ImportExport/ModelUploader.cs +++ b/LibreMetaverse/ImportExport/ModelUploader.cs @@ -149,16 +149,9 @@ namespace OpenMetaverse.ImportExport resources["mesh_list"] = meshList; OSDArray textureList = new OSDArray(); - for (int i = 0; i < Images.Count; i++) + foreach (var img in Images) { - if (upload) - { - textureList.Add(new OSDBinary(Images[i])); - } - else - { - textureList.Add(new OSDBinary(Utils.EmptyBytes)); - } + textureList.Add(upload ? new OSDBinary(img) : new OSDBinary(Utils.EmptyBytes)); } resources["texture_list"] = textureList; diff --git a/LibreMetaverse/Primitives/ObjectMedia.cs b/LibreMetaverse/Primitives/ObjectMedia.cs index 1741cb44..31096245 100644 --- a/LibreMetaverse/Primitives/ObjectMedia.cs +++ b/LibreMetaverse/Primitives/ObjectMedia.cs @@ -26,6 +26,7 @@ using System; using System.Collections.Generic; +using System.Linq; using OpenMetaverse.StructuredData; namespace OpenMetaverse @@ -130,8 +131,7 @@ namespace OpenMetaverse List wl = new List(); if (WhiteList != null && WhiteList.Length > 0) { - for (int i = 0; i < WhiteList.Length; i++) - wl.Add(OSD.FromString(WhiteList[i])); + wl.AddRange(WhiteList.Select(OSD.FromString)); } map["whitelist"] = new OSDArray(wl); diff --git a/LibreMetaverseTypes/UtilsConversions.cs b/LibreMetaverseTypes/UtilsConversions.cs index 4f1218de..4413c2a0 100644 --- a/LibreMetaverseTypes/UtilsConversions.cs +++ b/LibreMetaverseTypes/UtilsConversions.cs @@ -767,9 +767,9 @@ namespace OpenMetaverse char c; // remove all non A-F, 0-9, characters - for (int i = 0; i < hexString.Length; i++) + foreach (var str in hexString) { - c = hexString[i]; + c = str; if (IsHexDigit(c)) stripped.Append(c); } diff --git a/Programs/GridProxy/Plugins/Analyst.cs b/Programs/GridProxy/Plugins/Analyst.cs index 9e33f95f..64b4909e 100644 --- a/Programs/GridProxy/Plugins/Analyst.cs +++ b/Programs/GridProxy/Plugins/Analyst.cs @@ -687,11 +687,11 @@ public class Analyst : ProxyPlugin Type packetTypeType = typeof(PacketType); System.Reflection.MemberInfo[] packetTypes = packetTypeType.GetMembers(); - for (int i = 0; i < packetTypes.Length; i++) + foreach (var t in packetTypes) { - if (packetTypes[i].MemberType == System.Reflection.MemberTypes.Field && packetTypes[i].DeclaringType == packetTypeType) + if (t.MemberType == System.Reflection.MemberTypes.Field && t.DeclaringType == packetTypeType) { - string name = packetTypes[i].Name; + string name = t.Name; PacketType pType; try @@ -718,9 +718,9 @@ public class Analyst : ProxyPlugin string[] lines = File.ReadAllLines(whitelistFile); int count = 0; - for (int i = 0; i < lines.Length; i++) + foreach (var l in lines) { - string line = lines[i].Trim(); + string line = l.Trim(); if (line.Length == 0) continue; @@ -754,9 +754,9 @@ public class Analyst : ProxyPlugin string[] lines = File.ReadAllLines(blacklistFile); int count = 0; - for (int i = 0; i < lines.Length; i++) + foreach (var l in lines) { - string line = lines[i].Trim(); + string line = l.Trim(); if (line.Length == 0) continue; @@ -802,11 +802,11 @@ public class Analyst : ProxyPlugin Type packetTypeType = typeof(PacketType); System.Reflection.MemberInfo[] packetTypes = packetTypeType.GetMembers(); - for (int i = 0; i < packetTypes.Length; i++) + foreach (var t in packetTypes) { - if (packetTypes[i].MemberType == System.Reflection.MemberTypes.Field && packetTypes[i].DeclaringType == packetTypeType) + if (t.MemberType == System.Reflection.MemberTypes.Field && t.DeclaringType == packetTypeType) { - string name = packetTypes[i].Name; + string name = t.Name; PacketType pType; try diff --git a/Programs/GridProxy/Plugins/ClientAO.cs b/Programs/GridProxy/Plugins/ClientAO.cs index 03bbf4c6..e1033df1 100644 --- a/Programs/GridProxy/Plugins/ClientAO.cs +++ b/Programs/GridProxy/Plugins/ClientAO.cs @@ -331,12 +331,12 @@ public class ClientAO : ProxyPlugin //SayToUser("nb received: " + nbdescendantsreceived); //folders are present, and we are not at end of path. //look at them - for (int i = 0; i < reply.FolderData.Length; i++) + foreach (var fd in reply.FolderData) { //SayToUser("Folder: " + Utils.BytesToString(reply.FolderData[i].Name)); - if (searchPath[searchLevel] == Utils.BytesToString(reply.FolderData[i].Name)) { + if (searchPath[searchLevel] == Utils.BytesToString(fd.Name)) { //We found the next folder in the path - currentFolder = reply.FolderData[i].FolderID; + currentFolder = fd.FolderID; if (searchLevel < searchPath.Length - 1) { // ask for next item in path @@ -381,32 +381,32 @@ public class ClientAO : ProxyPlugin //count them nbdescendantsreceived += reply.ItemData.Length; //SayToUser("nb received: " + nbdescendantsreceived); - for (int i = 0; i < reply.ItemData.Length; i++) + foreach (var d in reply.ItemData) { //we are going to store info on all items. we'll need //it to get the asset ID of animations refered to by the //configuration notecard - if (reply.ItemData[i].ItemID != UUID.Zero) + if (d.ItemID != UUID.Zero) { - InventoryItem item = CreateInventoryItem((InventoryType)reply.ItemData[i].InvType, reply.ItemData[i].ItemID); - item.ParentUUID = reply.ItemData[i].FolderID; - item.CreatorID = reply.ItemData[i].CreatorID; - item.AssetType = (AssetType)reply.ItemData[i].Type; - item.AssetUUID = reply.ItemData[i].AssetID; - item.CreationDate = Utils.UnixTimeToDateTime((uint)reply.ItemData[i].CreationDate); - item.Description = Utils.BytesToString(reply.ItemData[i].Description); - item.Flags = (uint)reply.ItemData[i].Flags; - item.Name = Utils.BytesToString(reply.ItemData[i].Name); - item.GroupID = reply.ItemData[i].GroupID; - item.GroupOwned = reply.ItemData[i].GroupOwned; + InventoryItem item = CreateInventoryItem((InventoryType)d.InvType, d.ItemID); + item.ParentUUID = d.FolderID; + item.CreatorID = d.CreatorID; + item.AssetType = (AssetType)d.Type; + item.AssetUUID = d.AssetID; + item.CreationDate = Utils.UnixTimeToDateTime((uint)d.CreationDate); + item.Description = Utils.BytesToString(d.Description); + item.Flags = (uint)d.Flags; + item.Name = Utils.BytesToString(d.Name); + item.GroupID = d.GroupID; + item.GroupOwned = d.GroupOwned; item.Permissions = new Permissions( - reply.ItemData[i].BaseMask, - reply.ItemData[i].EveryoneMask, - reply.ItemData[i].GroupMask, - reply.ItemData[i].NextOwnerMask, - reply.ItemData[i].OwnerMask); - item.SalePrice = reply.ItemData[i].SalePrice; - item.SaleType = (SaleType)reply.ItemData[i].SaleType; + d.BaseMask, + d.EveryoneMask, + d.GroupMask, + d.NextOwnerMask, + d.OwnerMask); + item.SalePrice = d.SalePrice; + item.SaleType = (SaleType)d.SaleType; item.OwnerID = reply.AgentData.OwnerID; //SayToUser("item in folder: " + item.Name); @@ -575,10 +575,10 @@ public class ClientAO : ProxyPlugin // Reset the signaled animation list SignaledAnimations.Clear(); //fill it with the fresh list from simulator - for (int i = 0; i < animation.AnimationList.Length; i++) + foreach (var anim in animation.AnimationList) { - UUID animID = animation.AnimationList[i].AnimID; - int sequenceID = animation.AnimationList[i].AnimSequenceID; + UUID animID = anim.AnimID; + int sequenceID = anim.AnimSequenceID; // Add this animation to the list of currently signaled animations SignaledAnimations[animID] = sequenceID; diff --git a/Programs/examples/TestClient/Commands/Agent/BotsCommand.cs b/Programs/examples/TestClient/Commands/Agent/BotsCommand.cs index ab673d9e..2ff90055 100644 --- a/Programs/examples/TestClient/Commands/Agent/BotsCommand.cs +++ b/Programs/examples/TestClient/Commands/Agent/BotsCommand.cs @@ -59,9 +59,9 @@ namespace OpenMetaverse.TestClient lock (Client.Network.Simulators) { - for (int i = 0; i < Client.Network.Simulators.Count; i++) + foreach (var sim in Client.Network.Simulators) { - Client.Network.Simulators[i].ObjectsAvatars.ForEach( + sim.ObjectsAvatars.ForEach( delegate(Avatar av) { lock (m_AgentList) diff --git a/Programs/examples/TestClient/Commands/Agent/WhoCommand.cs b/Programs/examples/TestClient/Commands/Agent/WhoCommand.cs index dc5615e6..7ceb1174 100644 --- a/Programs/examples/TestClient/Commands/Agent/WhoCommand.cs +++ b/Programs/examples/TestClient/Commands/Agent/WhoCommand.cs @@ -21,9 +21,11 @@ namespace OpenMetaverse.TestClient lock (Client.Network.Simulators) { - for (int i = 0; i < Client.Network.Simulators.Count; i++) + foreach (var sim + in Client.Network.Simulators) { - Client.Network.Simulators[i].ObjectsAvatars.ForEach( + sim +.ObjectsAvatars.ForEach( delegate(Avatar av) { result.AppendLine(); diff --git a/Programs/examples/TestClient/Commands/Appearance/CloneCommand.cs b/Programs/examples/TestClient/Commands/Appearance/CloneCommand.cs index 09269800..3a43536a 100644 --- a/Programs/examples/TestClient/Commands/Appearance/CloneCommand.cs +++ b/Programs/examples/TestClient/Commands/Appearance/CloneCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using OpenMetaverse; using OpenMetaverse.Packets; @@ -22,8 +23,7 @@ namespace OpenMetaverse.TestClient string targetName = String.Empty; List matches; - for (int ct = 0; ct < args.Length; ct++) - targetName = targetName + args[ct] + " "; + targetName = args.Aggregate(targetName, (current, t) => current + t + " "); targetName = targetName.TrimEnd(); if (targetName.Length == 0) diff --git a/Programs/examples/TestClient/Commands/Directory/SearchClassifiedsCommand.cs b/Programs/examples/TestClient/Commands/Directory/SearchClassifiedsCommand.cs index fa1b6eba..038558d3 100644 --- a/Programs/examples/TestClient/Commands/Directory/SearchClassifiedsCommand.cs +++ b/Programs/examples/TestClient/Commands/Directory/SearchClassifiedsCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; namespace OpenMetaverse.TestClient.Commands @@ -20,9 +21,7 @@ namespace OpenMetaverse.TestClient.Commands if (args.Length < 1) return "Usage: searchclassifieds [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/SearchEventsCommand.cs b/Programs/examples/TestClient/Commands/Directory/SearchEventsCommand.cs index 3029b374..51b1cec7 100644 --- a/Programs/examples/TestClient/Commands/Directory/SearchEventsCommand.cs +++ b/Programs/examples/TestClient/Commands/Directory/SearchEventsCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; namespace OpenMetaverse.TestClient.Commands @@ -22,9 +23,7 @@ namespace OpenMetaverse.TestClient.Commands if (args.Length < 1) return "Usage: searchevents [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/SearchPeopleCommand.cs b/Programs/examples/TestClient/Commands/Directory/SearchPeopleCommand.cs index a9efc771..9a2be426 100644 --- a/Programs/examples/TestClient/Commands/Directory/SearchPeopleCommand.cs +++ b/Programs/examples/TestClient/Commands/Directory/SearchPeopleCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; namespace OpenMetaverse.TestClient.Commands @@ -22,9 +23,7 @@ namespace OpenMetaverse.TestClient.Commands if (args.Length < 1) return "Usage: searchpeople [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/SearchPlacesCommand.cs b/Programs/examples/TestClient/Commands/Directory/SearchPlacesCommand.cs index 93aafe85..ded2d3a3 100644 --- a/Programs/examples/TestClient/Commands/Directory/SearchPlacesCommand.cs +++ b/Programs/examples/TestClient/Commands/Directory/SearchPlacesCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; namespace OpenMetaverse.TestClient.Commands @@ -20,9 +21,7 @@ namespace OpenMetaverse.TestClient.Commands if (args.Length < 1) return "Usage: searchplaces [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/Groups/ActivateGroupCommand.cs b/Programs/examples/TestClient/Commands/Groups/ActivateGroupCommand.cs index c58cc012..bd78e353 100644 --- a/Programs/examples/TestClient/Commands/Groups/ActivateGroupCommand.cs +++ b/Programs/examples/TestClient/Commands/Groups/ActivateGroupCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using OpenMetaverse; using OpenMetaverse.Packets; @@ -28,9 +29,7 @@ namespace OpenMetaverse.TestClient activeGroup = string.Empty; - string groupName = String.Empty; - for (int i = 0; i < args.Length; i++) - groupName += args[i] + " "; + string groupName = args.Aggregate(String.Empty, (current, t) => current + (t + " ")); groupName = groupName.Trim(); UUID groupUUID = Client.GroupName2UUID(groupName); diff --git a/Programs/examples/TestClient/Commands/Groups/GroupMembersCommand.cs b/Programs/examples/TestClient/Commands/Groups/GroupMembersCommand.cs index bf0ef917..43e47288 100644 --- a/Programs/examples/TestClient/Commands/Groups/GroupMembersCommand.cs +++ b/Programs/examples/TestClient/Commands/Groups/GroupMembersCommand.cs @@ -30,8 +30,9 @@ namespace OpenMetaverse.TestClient return Description; GroupName = String.Empty; - for (int i = 0; i < args.Length; i++) - GroupName += args[i] + " "; + foreach (var arg in args) + GroupName += arg + " "; + GroupName = GroupName.Trim(); GroupUUID = Client.GroupName2UUID(GroupName); diff --git a/Programs/examples/TestClient/Commands/Groups/GroupRolesCommand.cs b/Programs/examples/TestClient/Commands/Groups/GroupRolesCommand.cs index e1618546..30f5b436 100644 --- a/Programs/examples/TestClient/Commands/Groups/GroupRolesCommand.cs +++ b/Programs/examples/TestClient/Commands/Groups/GroupRolesCommand.cs @@ -30,8 +30,9 @@ namespace OpenMetaverse.TestClient return Description; GroupName = String.Empty; - for (int i = 0; i < args.Length; i++) - GroupName += args[i] + " "; + foreach (var arg in args) + GroupName += arg + " "; + GroupName = GroupName.Trim(); GroupUUID = Client.GroupName2UUID(GroupName); diff --git a/Programs/examples/TestClient/Commands/Groups/JoinGroupCommand.cs b/Programs/examples/TestClient/Commands/Groups/JoinGroupCommand.cs index b83e2fd8..11261c4e 100644 --- a/Programs/examples/TestClient/Commands/Groups/JoinGroupCommand.cs +++ b/Programs/examples/TestClient/Commands/Groups/JoinGroupCommand.cs @@ -42,8 +42,9 @@ namespace OpenMetaverse.TestClient } else { - for (int i = 0; i < args.Length; i++) - groupName += args[i] + " "; + foreach (var arg in args) + groupName += arg + " "; + groupName = groupName.Trim(); Client.Directory.DirGroupsReply += Directory_DirGroups; diff --git a/Programs/examples/TestClient/Commands/Groups/LeaveGroupCommand.cs b/Programs/examples/TestClient/Commands/Groups/LeaveGroupCommand.cs index f8798a6d..918c6ffb 100644 --- a/Programs/examples/TestClient/Commands/Groups/LeaveGroupCommand.cs +++ b/Programs/examples/TestClient/Commands/Groups/LeaveGroupCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using OpenMetaverse; using OpenMetaverse.Packets; @@ -23,9 +24,7 @@ namespace OpenMetaverse.TestClient if (args.Length < 1) return Description; - string groupName = String.Empty; - for (int i = 0; i < args.Length; i++) - groupName += args[i] + " "; + string groupName = args.Aggregate(String.Empty, (current, t) => current + (t + " ")); groupName = groupName.Trim(); UUID groupUUID = Client.GroupName2UUID(groupName); diff --git a/Programs/examples/TestClient/Commands/Inventory/DeleteFolderCommand.cs b/Programs/examples/TestClient/Commands/Inventory/DeleteFolderCommand.cs index ea8b357a..b3e5eed1 100644 --- a/Programs/examples/TestClient/Commands/Inventory/DeleteFolderCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/DeleteFolderCommand.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using System.Threading; using System.Xml; @@ -24,9 +25,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { // parse the command line - string target = String.Empty; - for (int ct = 0; ct < args.Length; ct++) - target = target + args[ct] + " "; + string target = args.Aggregate(String.Empty, (current, t) => current + t + " "); target = target.TrimEnd(); // initialize results list diff --git a/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs b/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs index 4fa1a049..3295d35b 100644 --- a/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs @@ -57,9 +57,9 @@ namespace OpenMetaverse.TestClient lock (Client.Network.Simulators) { - for (int i = 0; i < Client.Network.Simulators.Count; i++) + foreach (var sim in Client.Network.Simulators) { - Avatar targetAv = Client.Network.Simulators[i].ObjectsAvatars.Find( + Avatar targetAv = sim.ObjectsAvatars.Find( avatar => avatar.ID == target ); diff --git a/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs b/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs index 0bb83f8a..4f771817 100644 --- a/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; namespace OpenMetaverse.TestClient.Commands.Inventory.Shell @@ -30,9 +31,7 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell string ret = ""; string nl = "\n"; - string target = String.Empty; - for (int ct = 0; ct < args.Length; ct++) - target = target + args[ct] + " "; + string target = args.Aggregate(String.Empty, (current, t) => current + t + " "); target = target.TrimEnd(); string inventoryName = target; diff --git a/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs b/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs index 5eda450a..7ddf5911 100644 --- a/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/ObjectInventoryCommand.cs @@ -35,17 +35,16 @@ namespace OpenMetaverse.TestClient { string result = String.Empty; - for (int i = 0; i < items.Count; i++) + foreach (var i in items) { - if (items[i] is InventoryFolder) + if (i is InventoryFolder) { - result += String.Format("[Folder] Name: {0}", items[i].Name) + Environment.NewLine; + result += $"[Folder] Name: {i.Name}" + Environment.NewLine; } else { - InventoryItem item = (InventoryItem)items[i]; - result += String.Format("[Item] Name: {0} Desc: {1} Type: {2}", item.Name, item.Description, - item.AssetType) + Environment.NewLine; + InventoryItem item = (InventoryItem)i; + result += $"[Item] Name: {item.Name} Desc: {item.Description} Type: {item.AssetType}" + Environment.NewLine; } } diff --git a/Programs/examples/TestClient/Commands/Inventory/ScriptCommand.cs b/Programs/examples/TestClient/Commands/Inventory/ScriptCommand.cs index e72fb448..fd91e7e6 100644 --- a/Programs/examples/TestClient/Commands/Inventory/ScriptCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/ScriptCommand.cs @@ -24,9 +24,9 @@ namespace OpenMetaverse.TestClient catch (Exception e) { return e.Message; } // Execute all of the commands - for (int i = 0; i < lines.Length; i++) + foreach (var l in lines) { - string line = lines[i].Trim(); + string line = l.Trim(); if (line.Length > 0) ClientManager.Instance.DoCommandAll(line, UUID.Zero); diff --git a/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs b/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs index 5181e8b1..ae935721 100644 --- a/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/TaskRunningCommand.cs @@ -82,19 +82,18 @@ namespace OpenMetaverse.TestClient Client.Inventory.ScriptRunningReply += callback; - for (int i = 0; i < items.Count; i++) + foreach (var t in items) { - if (items[i] is InventoryFolder) + if (t is InventoryFolder) { // this shouldn't happen this year - result += String.Format("[Folder] Name: {0}", items[i].Name) + Environment.NewLine; + result += $"[Folder] Name: {t.Name}" + Environment.NewLine; } else { - InventoryItem item = (InventoryItem)items[i]; + InventoryItem item = (InventoryItem)t; AssetType assetType = item.AssetType; - result += String.Format("[Item] Name: {0} Desc: {1} Type: {2}", item.Name, item.Description, - assetType); + result += $"[Item] Name: {item.Name} Desc: {item.Description} Type: {assetType}"; if (assetType == AssetType.LSLBytecode || assetType == AssetType.LSLText) { OnScriptRunningReset.Reset(); diff --git a/Programs/examples/TestClient/Commands/Land/AgentLocationsCommand.cs b/Programs/examples/TestClient/Commands/Land/AgentLocationsCommand.cs index b06278a1..bf9571d8 100644 --- a/Programs/examples/TestClient/Commands/Land/AgentLocationsCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/AgentLocationsCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; using OpenMetaverse; @@ -34,12 +35,9 @@ namespace OpenMetaverse.TestClient StringBuilder ret = new StringBuilder(); ret.AppendLine("Agent locations:"); - for (int i = 0; i < items.Count; i++) + foreach (var location in items.Cast()) { - MapAgentLocation location = (MapAgentLocation)items[i]; - - ret.AppendLine(String.Format("{0} avatar(s) at {1},{2}", location.AvatarCount, location.LocalX, - location.LocalY)); + ret.AppendLine($"{location.AvatarCount} avatar(s) at {location.LocalX},{location.LocalY}"); } return ret.ToString(); diff --git a/Programs/examples/TestClient/Commands/Land/FindSimCommand.cs b/Programs/examples/TestClient/Commands/Land/FindSimCommand.cs index f69d52cc..0c277eeb 100644 --- a/Programs/examples/TestClient/Commands/Land/FindSimCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/FindSimCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; using OpenMetaverse; using OpenMetaverse.Packets; @@ -20,9 +21,7 @@ namespace OpenMetaverse.TestClient return "Usage: findsim [Simulator Name]"; // Build the simulator name from the args list - string simName = string.Empty; - for (int i = 0; i < args.Length; i++) - simName += args[i] + " "; + string simName = args.Aggregate(string.Empty, (current, t) => current + (t + " ")); simName = simName.TrimEnd().ToLower(); //if (!GridDataCached[Client]) diff --git a/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs b/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs index afdd5ca7..d1553265 100644 --- a/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs @@ -32,13 +32,12 @@ namespace OpenMetaverse.TestClient AutoResetEvent wait = new AutoResetEvent(false); EventHandler callback = delegate(object sender, ForceSelectObjectsReplyEventArgs e) { - - for (int i = 0; i < e.ObjectIDs.Count; i++) + foreach (var id in e.ObjectIDs) { - result.Append(e.ObjectIDs[i].ToString() + " "); + result.Append(id + " "); counter++; } - + if (e.ObjectIDs.Count < 251) wait.Set(); }; diff --git a/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs b/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs index 1fb279eb..fba7fb1c 100644 --- a/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; using OpenMetaverse; using OpenMetaverse.Packets; @@ -23,10 +24,8 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { // Construct the target name from the passed arguments - string target = String.Empty; - for (int ct = 0; ct < args.Length; ct++) - target = target + args[ct] + " "; - target = target.TrimEnd(); + string target = args.Aggregate(String.Empty, (current, t) => current + t + " "); + target = target.TrimEnd(); if (target.Length == 0 || target == "off") { @@ -48,9 +47,9 @@ namespace OpenMetaverse.TestClient { lock (Client.Network.Simulators) { - for (int i = 0; i < Client.Network.Simulators.Count; i++) + foreach (var sim in Client.Network.Simulators) { - Avatar target = Client.Network.Simulators[i].ObjectsAvatars.Find( + Avatar target = sim.ObjectsAvatars.Find( avatar => avatar.Name == name ); @@ -79,15 +78,15 @@ namespace OpenMetaverse.TestClient // Find the target position lock (Client.Network.Simulators) { - for (int i = 0; i < Client.Network.Simulators.Count; i++) + foreach (var t in Client.Network.Simulators) { Avatar targetAv; - if (Client.Network.Simulators[i].ObjectsAvatars.TryGetValue(targetLocalID, out targetAv)) + if (t.ObjectsAvatars.TryGetValue(targetLocalID, out targetAv)) { float distance = 0.0f; - if (Client.Network.Simulators[i] == Client.Network.CurrentSim) + if (t == Client.Network.CurrentSim) { distance = Vector3.Distance(targetAv.Position, Client.Self.SimPosition); } @@ -99,7 +98,7 @@ namespace OpenMetaverse.TestClient if (distance > DISTANCE_BUFFER) { uint regionX, regionY; - Utils.LongToUInts(Client.Network.Simulators[i].Handle, out regionX, out regionY); + Utils.LongToUInts(t.Handle, out regionX, out regionY); double xTarget = (double)targetAv.Position.X + (double)regionX; double yTarget = (double)targetAv.Position.Y + (double)regionY; diff --git a/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs b/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs index e93ac9fc..db359f91 100644 --- a/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading; namespace OpenMetaverse.TestClient @@ -81,13 +82,12 @@ namespace OpenMetaverse.TestClient // Build a dictionary of primitives for referencing later Objects[rootPrim.ID] = rootPrim; - for (int i = 0; i < childPrims.Count; i++) - Objects[childPrims[i].ID] = childPrims[i]; + foreach (var p in childPrims) + Objects[p.ID] = p; // Build a list of all the localIDs to set permissions for localIDs.Add(rootPrim.LocalID); - for (int i = 0; i < childPrims.Count; i++) - localIDs.Add(childPrims[i].LocalID); + localIDs.AddRange(childPrims.Select(t => t.LocalID)); // Go through each of the three main permissions and enable or disable them #region Set Linkset Permissions @@ -128,24 +128,16 @@ namespace OpenMetaverse.TestClient int taskItems = 0; foreach (Primitive prim in Objects.Values) { - if ((prim.Flags & PrimFlags.InventoryEmpty) == 0) + if ((prim.Flags & PrimFlags.InventoryEmpty) != 0) continue; + List items = Client.Inventory.GetTaskInventory(prim.ID, prim.LocalID, 1000 * 30); + + if (items == null) continue; + foreach (var item in items.Where(i => !(i is InventoryFolder)).Cast()) { - List items = Client.Inventory.GetTaskInventory(prim.ID, prim.LocalID, 1000 * 30); + item.Permissions.NextOwnerMask = Perms; - if (items != null) - { - for (int i = 0; i < items.Count; i++) - { - if (!(items[i] is InventoryFolder)) - { - InventoryItem item = (InventoryItem)items[i]; - item.Permissions.NextOwnerMask = Perms; - - Client.Inventory.UpdateTaskInventory(prim.LocalID, item); - ++taskItems; - } - } - } + Client.Inventory.UpdateTaskInventory(prim.LocalID, item); + ++taskItems; } } diff --git a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs index cc2a2cfd..13505582 100644 --- a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -114,23 +115,21 @@ namespace OpenMetaverse.TestClient lock (Textures) { - for (int i = 0; i < prims.Count; i++) + foreach (var prim in prims) { - Primitive prim = prims[i]; - if (prim.Textures.DefaultTexture.TextureID != Primitive.TextureEntry.WHITE_TEXTURE && !Textures.Contains(prim.Textures.DefaultTexture.TextureID)) { Textures.Add(prim.Textures.DefaultTexture.TextureID); } - for (int j = 0; j < prim.Textures.FaceTextures.Length; j++) + foreach (var face in prim.Textures.FaceTextures) { - if (prim.Textures.FaceTextures[j] != null && - prim.Textures.FaceTextures[j].TextureID != Primitive.TextureEntry.WHITE_TEXTURE && - !Textures.Contains(prim.Textures.FaceTextures[j].TextureID)) + if (face != null && + face.TextureID != Primitive.TextureEntry.WHITE_TEXTURE && + !Textures.Contains(face.TextureID)) { - Textures.Add(prim.Textures.FaceTextures[j].TextureID); + Textures.Add(face.TextureID); } } @@ -141,8 +140,7 @@ namespace OpenMetaverse.TestClient } // Create a request list from all of the images - for (int i = 0; i < Textures.Count; i++) - textureRequests.Add(new ImageRequest(Textures[i], ImageType.Normal, 1013000.0f, 0)); + textureRequests.AddRange(Textures.Select(t => new ImageRequest(t, ImageType.Normal, 1013000.0f, 0))); } // Download all of the textures in the export list diff --git a/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs b/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs index 257b0663..11acfed5 100644 --- a/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs @@ -68,10 +68,8 @@ namespace OpenMetaverse.TestClient // Build an organized structure from the imported prims Dictionary linksets = new Dictionary(); - for (int i = 0; i < prims.Count; i++) + foreach (var prim in prims) { - Primitive prim = prims[i]; - if (prim.ParentID == 0) { if (linksets.ContainsKey(prim.LocalID)) diff --git a/Programs/examples/TestClient/Commands/Prims/PrimCountCommand.cs b/Programs/examples/TestClient/Commands/Prims/PrimCountCommand.cs index 764e36d8..72138144 100644 --- a/Programs/examples/TestClient/Commands/Prims/PrimCountCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/PrimCountCommand.cs @@ -18,13 +18,13 @@ namespace OpenMetaverse.TestClient lock (Client.Network.Simulators) { - for (int i = 0; i < Client.Network.Simulators.Count; i++) + foreach (var sim in Client.Network.Simulators) { - int avcount = Client.Network.Simulators[i].ObjectsAvatars.Count; - int primcount = Client.Network.Simulators[i].ObjectsPrimitives.Count; + int avcount = sim.ObjectsAvatars.Count; + int primcount = sim.ObjectsPrimitives.Count; Console.WriteLine("{0} (Avatars: {1} Primitives: {2})", - Client.Network.Simulators[i].Name, avcount, primcount); + sim.Name, avcount, primcount); count += avcount; count += primcount; diff --git a/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs b/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs index ec2386c3..9ec9d402 100644 --- a/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Text.RegularExpressions; using OpenMetaverse; @@ -22,9 +23,7 @@ namespace OpenMetaverse.TestClient try { // Build the predicat from the args list - string predicatPrim = string.Empty; - for (int i = 0; i < args.Length; i++) - predicatPrim += args[i] + " "; + string predicatPrim = args.Aggregate(string.Empty, (current, t) => current + (t + " ")); predicatPrim = predicatPrim.TrimEnd(); // Build Regex diff --git a/Programs/examples/TestClient/Commands/Prims/TexturesCommand.cs b/Programs/examples/TestClient/Commands/Prims/TexturesCommand.cs index ffed3937..b448555c 100644 --- a/Programs/examples/TestClient/Commands/Prims/TexturesCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/TexturesCommand.cs @@ -87,17 +87,13 @@ namespace OpenMetaverse.TestClient if (enabled) { // Search this prim for textures - for (int i = 0; i < prim.Textures.FaceTextures.Length; i++) + foreach (var face in prim.Textures.FaceTextures) { - Primitive.TextureEntryFace face = prim.Textures.FaceTextures[i]; - - if (face != null) + if (face == null) continue; + if (!alreadyRequested.ContainsKey(face.TextureID)) { - if (!alreadyRequested.ContainsKey(face.TextureID)) - { - alreadyRequested[face.TextureID] = face.TextureID; - Client.Assets.RequestImage(face.TextureID, ImageType.Normal, Assets_OnImageReceived); - } + alreadyRequested[face.TextureID] = face.TextureID; + Client.Assets.RequestImage(face.TextureID, ImageType.Normal, Assets_OnImageReceived); } } } diff --git a/Programs/examples/TestClient/Commands/Stats/StatsCommand.cs b/Programs/examples/TestClient/Commands/Stats/StatsCommand.cs index d999d440..2514a226 100644 --- a/Programs/examples/TestClient/Commands/Stats/StatsCommand.cs +++ b/Programs/examples/TestClient/Commands/Stats/StatsCommand.cs @@ -21,10 +21,8 @@ namespace OpenMetaverse.TestClient lock (Client.Network.Simulators) { - for (int i = 0; i < Client.Network.Simulators.Count; i++) + foreach (var sim in Client.Network.Simulators) { - Simulator sim = Client.Network.Simulators[i]; - 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, diff --git a/Programs/examples/TestClient/Commands/System/HelpCommand.cs b/Programs/examples/TestClient/Commands/System/HelpCommand.cs index 669b9e7d..9b1ea3b7 100644 --- a/Programs/examples/TestClient/Commands/System/HelpCommand.cs +++ b/Programs/examples/TestClient/Commands/System/HelpCommand.cs @@ -49,7 +49,7 @@ namespace OpenMetaverse.TestClient { result.AppendFormat(System.Environment.NewLine + "* {0} Related Commands:" + System.Environment.NewLine, kvp.Key.ToString()); int colMax = 0; - for (int i = 0; i < kvp.Value.Count; i++) + foreach (var val in kvp.Value) { if (colMax >= 120) { @@ -57,7 +57,7 @@ namespace OpenMetaverse.TestClient colMax = 0; } - result.AppendFormat(" {0,-15}", kvp.Value[i].Name); + result.AppendFormat(" {0,-15}", val.Name); colMax += 15; } result.AppendLine(); diff --git a/Programs/examples/TestClient/Commands/System/SetMasterCommand.cs b/Programs/examples/TestClient/Commands/System/SetMasterCommand.cs index c5dd0823..ff578ebe 100644 --- a/Programs/examples/TestClient/Commands/System/SetMasterCommand.cs +++ b/Programs/examples/TestClient/Commands/System/SetMasterCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Threading; using OpenMetaverse; @@ -23,9 +24,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { - string masterName = String.Empty; - for (int ct = 0; ct < args.Length;ct++) - masterName = masterName + args[ct] + " "; + string masterName = args.Aggregate(string.Empty, (current, t) => current + t + " "); masterName = masterName.TrimEnd(); if (masterName.Length == 0) diff --git a/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs b/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs index 9eda35de..24335f06 100644 --- a/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs +++ b/Programs/examples/TestClient/Commands/System/SetMasterKeyCommand.cs @@ -23,9 +23,9 @@ namespace OpenMetaverse.TestClient lock (Client.Network.Simulators) { - for (int i = 0; i < Client.Network.Simulators.Count; i++) + foreach (var sim in Client.Network.Simulators) { - Avatar master = Client.Network.Simulators[i].ObjectsAvatars.Find( + Avatar master = sim.ObjectsAvatars.Find( avatar => avatar.ID == Client.MasterKey );