diff --git a/LibreMetaverse.StructuredData/JSON/JsonWriter.cs b/LibreMetaverse.StructuredData/JSON/JsonWriter.cs index dbc7bb77..8d612ce6 100644 --- a/LibreMetaverse.StructuredData/JSON/JsonWriter.cs +++ b/LibreMetaverse.StructuredData/JSON/JsonWriter.cs @@ -87,10 +87,7 @@ namespace LitJson public JsonWriter (TextWriter writer) { - if (writer == null) - throw new ArgumentNullException (nameof(writer)); - - this.TextWriter = writer; + this.TextWriter = writer ?? throw new ArgumentNullException (nameof(writer)); Init (); } diff --git a/LibreMetaverse.Tests/BinaryLLSDTests.cs b/LibreMetaverse.Tests/BinaryLLSDTests.cs index 4d1031e5..ff8bbb78 100644 --- a/LibreMetaverse.Tests/BinaryLLSDTests.cs +++ b/LibreMetaverse.Tests/BinaryLLSDTests.cs @@ -717,7 +717,7 @@ namespace OpenMetaverse.Tests { if (arrays == null) { - throw new ArgumentNullException("arrays"); + throw new ArgumentNullException(nameof(arrays)); } if (arrays.Length == 0) { diff --git a/LibreMetaverse.Tests/XmlLLSDTests.cs b/LibreMetaverse.Tests/XmlLLSDTests.cs index 0a5502c7..263b18ef 100644 --- a/LibreMetaverse.Tests/XmlLLSDTests.cs +++ b/LibreMetaverse.Tests/XmlLLSDTests.cs @@ -483,7 +483,7 @@ namespace OpenMetaverse.Tests byte[] bytes = Encoding.UTF8.GetBytes(testSD); theSD = OSDParser.DeserializeLLSDXml(bytes); - Assert.IsTrue(theSD is OSD); + Assert.IsTrue(theSD != null); } /// diff --git a/LibreMetaverse/AssetManager.cs b/LibreMetaverse/AssetManager.cs index b9b3c93a..4dfa6b17 100644 --- a/LibreMetaverse/AssetManager.cs +++ b/LibreMetaverse/AssetManager.cs @@ -220,11 +220,6 @@ namespace OpenMetaverse public uint PacketNum; public string Filename = String.Empty; public TransferError Error = TransferError.None; - - public XferDownload() - : base() - { - } } /// @@ -241,11 +236,6 @@ namespace OpenMetaverse public float Priority; internal int InitialDataSize; internal ManualResetEvent HeaderReceivedEvent = new ManualResetEvent(false); - - public ImageDownload() - : base() - { - } } /// @@ -257,11 +247,6 @@ namespace OpenMetaverse public AssetType Type; public ulong XferID; public uint PacketNum; - - public AssetUpload() - : base() - { - } } /// diff --git a/LibreMetaverse/Avatar.cs b/LibreMetaverse/Avatar.cs index 42d19d1f..8b130618 100644 --- a/LibreMetaverse/Avatar.cs +++ b/LibreMetaverse/Avatar.cs @@ -555,15 +555,5 @@ namespace OpenMetaverse #endregion Properties - #region Constructors - - /// - /// Default constructor - /// - public Avatar() - { - } - - #endregion Constructors } } diff --git a/LibreMetaverse/Capabilities/CapsBase.cs b/LibreMetaverse/Capabilities/CapsBase.cs index cb5afaed..bdd0ed32 100644 --- a/LibreMetaverse/Capabilities/CapsBase.cs +++ b/LibreMetaverse/Capabilities/CapsBase.cs @@ -113,10 +113,10 @@ namespace OpenMetaverse.Http static HttpWebRequest SetupRequest(Uri address, X509Certificate2 clientCert) { if (address == null) - throw new ArgumentNullException("address"); + throw new ArgumentNullException(nameof(address)); // Create the request - HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(address); + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address); // Add the client certificate to the request if one was given if (clientCert != null) diff --git a/LibreMetaverse/Capabilities/EventQueueClient.cs b/LibreMetaverse/Capabilities/EventQueueClient.cs index c88db197..8c34460e 100644 --- a/LibreMetaverse/Capabilities/EventQueueClient.cs +++ b/LibreMetaverse/Capabilities/EventQueueClient.cs @@ -221,17 +221,16 @@ namespace OpenMetaverse.Http #region Handle incoming events - if (OnEvent != null && events != null && events.Count > 0) + if (OnEvent == null || events == null || events.Count <= 0) return; + // Fire callbacks for each event received + foreach (var osd in events) { - // Fire callbacks for each event received - foreach (OSDMap evt in events) - { - string msg = evt["message"].AsString(); - OSDMap body = (OSDMap)evt["body"]; + var evt = (OSDMap) osd; + string msg = evt["message"].AsString(); + OSDMap body = (OSDMap)evt["body"]; - try { OnEvent(msg, body); } - catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, ex); } - } + try { OnEvent(msg, body); } + catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, ex); } } #endregion Handle incoming events diff --git a/LibreMetaverse/ImportExport/ModelUploader.cs b/LibreMetaverse/ImportExport/ModelUploader.cs index 77acc943..c29d9900 100644 --- a/LibreMetaverse/ImportExport/ModelUploader.cs +++ b/LibreMetaverse/ImportExport/ModelUploader.cs @@ -243,7 +243,7 @@ namespace OpenMetaverse.ImportExport req["texture_folder_id"] = Client.Inventory.FindFolderForType(AssetType.Texture); req["everyone_mask"] = (int)PermissionMask.All; - req["group_mask"] = (int)PermissionMask.All; ; + req["group_mask"] = (int) PermissionMask.All; req["next_owner_mask"] = (int)PermissionMask.All; CapsClient request = new CapsClient(url); diff --git a/LibreMetaverse/InventoryManager.cs b/LibreMetaverse/InventoryManager.cs index 7f96c697..ad732341 100644 --- a/LibreMetaverse/InventoryManager.cs +++ b/LibreMetaverse/InventoryManager.cs @@ -3827,7 +3827,7 @@ namespace OpenMetaverse if (_Store.Contains(reply.AgentData.FolderID) && _Store[reply.AgentData.FolderID] is InventoryFolder) { - parentFolder = _Store[reply.AgentData.FolderID] as InventoryFolder; + parentFolder = (InventoryFolder) _Store[reply.AgentData.FolderID]; } else { diff --git a/LibreMetaverse/MultiValueDict.cs b/LibreMetaverse/MultiValueDict.cs index b68abce2..14bd08ad 100644 --- a/LibreMetaverse/MultiValueDict.cs +++ b/LibreMetaverse/MultiValueDict.cs @@ -40,14 +40,6 @@ namespace LibreMetaverse /// The type of the value. public class MultiValueDictionary : Dictionary> { - /// - /// Initializes a new instance of the class. - /// - public MultiValueDictionary() : base() - { - } - - /// /// Adds the specified value under the specified key /// diff --git a/LibreMetaverse/ObservableDictionary.cs b/LibreMetaverse/ObservableDictionary.cs index b6ad64da..80061b9b 100644 --- a/LibreMetaverse/ObservableDictionary.cs +++ b/LibreMetaverse/ObservableDictionary.cs @@ -207,7 +207,7 @@ namespace OpenMetaverse if (match(value)) return value; } - return default(TValue); + return default(TValue); } /// Find All items in an @@ -234,7 +234,7 @@ namespace OpenMetaverse if (match(kvp.Value)) found.Add(kvp.Value); } - return found; + return found; } /// Find All items in an diff --git a/LibreMetaverse/OutgoingPacket.cs b/LibreMetaverse/OutgoingPacket.cs index 4513080b..6e952c9a 100644 --- a/LibreMetaverse/OutgoingPacket.cs +++ b/LibreMetaverse/OutgoingPacket.cs @@ -81,7 +81,7 @@ namespace OpenMetaverse public Simulator Simulator { - get { return Client is Simulator ? Client as Simulator : null; } + get { return Client is Simulator ? (Simulator) Client : null; } } /// @@ -89,7 +89,7 @@ namespace OpenMetaverse /// public IPEndPoint Destination { - get { return Buffer.RemoteEndPoint is IPEndPoint ? Buffer.RemoteEndPoint as IPEndPoint : null; } + get { return Buffer.RemoteEndPoint is IPEndPoint ? (IPEndPoint) Buffer.RemoteEndPoint : null; } } /// diff --git a/LibreMetaverse/ProtocolManager.cs b/LibreMetaverse/ProtocolManager.cs index f0991521..df77959e 100644 --- a/LibreMetaverse/ProtocolManager.cs +++ b/LibreMetaverse/ProtocolManager.cs @@ -642,7 +642,7 @@ namespace OpenMetaverse } catch (Exception e) { - throw new Exception("Map file parsing error", e); ; + throw new Exception("Map file parsing error", e); } } diff --git a/LibreMetaverse/Rendering/LindenMesh.cs b/LibreMetaverse/Rendering/LindenMesh.cs index 03e49cb5..cd421b27 100644 --- a/LibreMetaverse/Rendering/LindenMesh.cs +++ b/LibreMetaverse/Rendering/LindenMesh.cs @@ -497,7 +497,7 @@ namespace OpenMetaverse.Rendering public virtual void LoadLODMesh(int level, string filename) { if (filename == "avatar_eye_1.llm") - throw new ArgumentException("Eyballs are not LOD Meshes", "filename"); + throw new ArgumentException("Eyeballs are not LOD Meshes", nameof(filename)); LODMesh lod = new LODMesh(); lod.LoadMesh(filename); @@ -529,7 +529,7 @@ namespace OpenMetaverse.Rendering public virtual ReferenceMesh LoadReferenceMesh(int lodLevel, string filename) { if (filename == "avatar_eye_1.llm") - throw new ArgumentException("Eyballs are not LOD Meshes", "filename"); + throw new ArgumentException("Eyeballs are not LOD Meshes", nameof(filename)); ReferenceMesh reference = new ReferenceMesh(); reference.LoadMesh(filename); diff --git a/LibreMetaverse/Rendering/LindenSkeleton.Ext.cs b/LibreMetaverse/Rendering/LindenSkeleton.Ext.cs index 2e10615a..c3b6b653 100644 --- a/LibreMetaverse/Rendering/LindenSkeleton.Ext.cs +++ b/LibreMetaverse/Rendering/LindenSkeleton.Ext.cs @@ -100,9 +100,9 @@ namespace OpenMetaverse.Rendering // not really sure about this algorithm, but it seems to fit the bill: // and the mesh doesn't seem to be overly distorted - if(bone.bone != null) - foreach (Joint child in bone.bone) - ExpandJoint(bone, child, expandedJointList, jointsFilter); + if (bone.bone == null) return expandedJointList; + foreach (Joint child in bone.bone) + ExpandJoint(bone, child, expandedJointList, jointsFilter); return expandedJointList; } @@ -117,26 +117,24 @@ namespace OpenMetaverse.Rendering private void ExpandJoint(Joint parentJoint, Joint currentJoint, List expandedJointList, IEnumerable jointsFilter) { // does the mesh reference this joint - if (jointsFilter.Contains(currentJoint.name)) + var enumerable = jointsFilter as string[] ?? jointsFilter.ToArray(); + if (enumerable.Contains(currentJoint.name)) { if (expandedJointList.Count > 0 && parentJoint != null && parentJoint.name == expandedJointList[expandedJointList.Count - 1]) expandedJointList.Add(currentJoint.name); else { - if (parentJoint != null) - expandedJointList.Add(parentJoint.name); - else - expandedJointList.Add(currentJoint.name); // only happens on the root joint + expandedJointList.Add(parentJoint != null ? parentJoint.name : currentJoint.name); expandedJointList.Add(currentJoint.name); } } // recurse the joint hierarchy - if(currentJoint.bone != null) - foreach (Joint child in currentJoint.bone) - ExpandJoint(currentJoint, child, expandedJointList, jointsFilter); + if (currentJoint.bone == null) return; + foreach (Joint child in currentJoint.bone) + ExpandJoint(currentJoint, child, expandedJointList, enumerable); } } } diff --git a/LibreMetaverse/Voice/TCPPipe.cs b/LibreMetaverse/Voice/TCPPipe.cs index c2432d79..59553a91 100644 --- a/LibreMetaverse/Voice/TCPPipe.cs +++ b/LibreMetaverse/Voice/TCPPipe.cs @@ -51,17 +51,7 @@ namespace OpenMetaverse.Voice public bool Connected { - get - { - if (_TCPSocket != null && _TCPSocket.Connected) - return true; - else - return false; - } - } - - public TCPPipe() - { + get { return _TCPSocket != null && _TCPSocket.Connected; } } public SocketException Connect(string address, int port) diff --git a/LibreMetaverse/Voice/VoiceControl.cs b/LibreMetaverse/Voice/VoiceControl.cs index 51d4a3f6..8fb7fb93 100644 --- a/LibreMetaverse/Voice/VoiceControl.cs +++ b/LibreMetaverse/Voice/VoiceControl.cs @@ -422,7 +422,7 @@ namespace OpenMetaverse.Voice string result = null; if (id == UUID.Zero) - return result; + return null; // Prepending this apparently prevents conflicts with reserved names inside the vivox and diamondware code. result = "x"; @@ -926,7 +926,7 @@ namespace OpenMetaverse.Voice spatialCredentials = cred["channel_credentials"].AsString(); } - if (spatialUri == null || spatialUri == "") + if (string.IsNullOrEmpty(spatialUri)) { // "No voice chat allowed here"); return; diff --git a/LibreMetaverse/Voice/VoiceSession.cs b/LibreMetaverse/Voice/VoiceSession.cs index 22c7fdd7..aadc96ea 100644 --- a/LibreMetaverse/Voice/VoiceSession.cs +++ b/LibreMetaverse/Voice/VoiceSession.cs @@ -184,7 +184,7 @@ namespace OpenMetaverse.Voice sb.Append(VoiceGateway.MakeXML("AccountHandle", AccountHandle)); sb.Append(VoiceGateway.MakeXML("URI", URI)); sb.Append(VoiceGateway.MakeXML("Name", Name)); - if (Password != null && Password != "") + if (!string.IsNullOrEmpty(Password)) { sb.Append(VoiceGateway.MakeXML("Password", Password)); sb.Append(VoiceGateway.MakeXML("PasswordHashAlgorithm", PasswordHashAlgorithm)); diff --git a/LibreMetaverseTypes/BlockingQueue.cs b/LibreMetaverseTypes/BlockingQueue.cs index b0ef2c4f..b3d37beb 100644 --- a/LibreMetaverseTypes/BlockingQueue.cs +++ b/LibreMetaverseTypes/BlockingQueue.cs @@ -146,7 +146,7 @@ namespace OpenMetaverse { lock (_syncRoot) { - while (_open && (base.Count == 0)) + while (_open && (Count == 0)) { if (!Monitor.Wait(_syncRoot, timeout)) return false; diff --git a/LibreMetaverseTypes/ReaderWriterLockSlim.cs b/LibreMetaverseTypes/ReaderWriterLockSlim.cs index e6c5cdc5..014a799f 100644 --- a/LibreMetaverseTypes/ReaderWriterLockSlim.cs +++ b/LibreMetaverseTypes/ReaderWriterLockSlim.cs @@ -122,11 +122,6 @@ namespace OpenMetaverse smp = Environment.ProcessorCount > 1; } - public ReaderWriterLockSlim() - { - // NoRecursion (0) is the default value - } - public void EnterReadLock() { TryEnterReadLock(-1); @@ -135,7 +130,7 @@ namespace OpenMetaverse public bool TryEnterReadLock(int millisecondsTimeout) { if (millisecondsTimeout < Timeout.Infinite) - throw new ArgumentOutOfRangeException("millisecondsTimeout"); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout)); if (read_locks == null) throw new ObjectDisposedException(null); @@ -149,7 +144,7 @@ namespace OpenMetaverse if (ld.ReadLocks != 0) { ExitMyLock(); - throw new LockRecursionException("Recursive read lock can only be aquired in SupportsRecursion mode"); + throw new LockRecursionException("Recursive read lock can only be acquired in SupportsRecursion mode"); } ++ld.ReadLocks; @@ -218,7 +213,7 @@ namespace OpenMetaverse public bool TryEnterWriteLock(int millisecondsTimeout) { if (millisecondsTimeout < Timeout.Infinite) - throw new ArgumentOutOfRangeException("millisecondsTimeout"); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout)); if (read_locks == null) throw new ObjectDisposedException(null); @@ -336,7 +331,7 @@ namespace OpenMetaverse public bool TryEnterUpgradeableReadLock(int millisecondsTimeout) { if (millisecondsTimeout < Timeout.Infinite) - throw new ArgumentOutOfRangeException("millisecondsTimeout"); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout)); if (read_locks == null) throw new ObjectDisposedException(null); @@ -583,7 +578,7 @@ namespace OpenMetaverse } catch (System.OverflowException) { - throw new ArgumentOutOfRangeException("timeout"); + throw new ArgumentOutOfRangeException(nameof(timeout)); } } diff --git a/Programs/GridProxy/GridProxy.cs b/Programs/GridProxy/GridProxy.cs index e23cbbb2..4ff38ac6 100644 --- a/Programs/GridProxy/GridProxy.cs +++ b/Programs/GridProxy/GridProxy.cs @@ -2024,7 +2024,7 @@ namespace GridProxy simPort = (ushort)fakeSim.Port; byte[] bytes = fakeSim.Address.GetAddressBytes(); simIP = Utils.BytesToUInt(bytes); - if (simCaps != null && simCaps.Length > 0) + if (!string.IsNullOrEmpty(simCaps)) { CapInfo info = new CapInfo(simCaps, realSim, "SeedCapability"); info.AddDelegate(new CapsDelegate(FixupSeedCapsResponse)); diff --git a/Programs/GridProxy/Plugins/Analyst.cs b/Programs/GridProxy/Plugins/Analyst.cs index 90c4ccca..26224ef7 100644 --- a/Programs/GridProxy/Plugins/Analyst.cs +++ b/Programs/GridProxy/Plugins/Analyst.cs @@ -739,7 +739,7 @@ public class Analyst : ProxyPlugin } } - Console.WriteLine(String.Format("Logging {0} packet types loaded from whitelist", count)); + Console.WriteLine($"Logging {count} packet types loaded from whitelist"); } catch (Exception) { @@ -775,7 +775,7 @@ public class Analyst : ProxyPlugin } } - Console.WriteLine(String.Format("Not logging {0} packet types loaded from blacklist", count)); + Console.WriteLine($"Not logging {count} packet types loaded from blacklist"); } catch (Exception) { @@ -792,7 +792,7 @@ public class Analyst : ProxyPlugin } catch (Exception) { - Console.WriteLine(String.Format("Failed to open {0} for logging", outputFile)); + Console.WriteLine($"Failed to open {outputFile} for logging"); } } diff --git a/Programs/GridProxy/Plugins/ClientAO.cs b/Programs/GridProxy/Plugins/ClientAO.cs index 6535a44c..47a77bc3 100644 --- a/Programs/GridProxy/Plugins/ClientAO.cs +++ b/Programs/GridProxy/Plugins/ClientAO.cs @@ -275,7 +275,7 @@ public class ClientAO : ProxyPlugin //start requesting an item by its path public void RequestFindObjectByPath(UUID baseFolder, string path) { - if (path == null || path.Length == 0) + if (string.IsNullOrEmpty(path)) throw new ArgumentException("Empty path is not supported"); currentFolder = baseFolder; //split path by '/' @@ -343,7 +343,7 @@ public class ClientAO : ProxyPlugin searchLevel++; RequestFolderContents(currentFolder, true, - (searchLevel < searchPath.Length - 1) ? false : true, + (searchLevel >= searchPath.Length - 1), InventorySortOrder.ByName); //Jump to end goto End; diff --git a/Programs/VoiceTest/VoiceTest.cs b/Programs/VoiceTest/VoiceTest.cs index 041cf0ba..c571b9c4 100644 --- a/Programs/VoiceTest/VoiceTest.cs +++ b/Programs/VoiceTest/VoiceTest.cs @@ -98,14 +98,14 @@ namespace VoiceTest Console.WriteLine("Capture Devices:"); for (int i = 0; i < captureDevices.Count; i++) - Console.WriteLine(String.Format("{0}. \"{1}\"", i, captureDevices[i])); + Console.WriteLine("{0}. \"{1}\"", i, captureDevices[i]); Console.WriteLine(); List renderDevices = voice.RenderDevices(); Console.WriteLine("Render Devices:"); for (int i = 0; i < renderDevices.Count; i++) - Console.WriteLine(String.Format("{0}. \"{1}\"", i, renderDevices[i])); + Console.WriteLine("{0}. \"{1}\"", i, renderDevices[i]); Console.WriteLine(); @@ -163,7 +163,7 @@ namespace VoiceTest catch(Exception e) { Console.WriteLine(e.Message); - if (e is VoiceException && (e as VoiceException).LoggedIn) + if (e is VoiceException && ((VoiceException) e).LoggedIn) { client.Network.Logout(); } diff --git a/Programs/examples/PacketDump/PacketDump.cs b/Programs/examples/PacketDump/PacketDump.cs index ecbb605d..b5918869 100644 --- a/Programs/examples/PacketDump/PacketDump.cs +++ b/Programs/examples/PacketDump/PacketDump.cs @@ -80,7 +80,7 @@ namespace PacketDump // Determine how long to run for int start = Environment.TickCount; int milliseconds = Int32.Parse(args[3]) * 1000; - bool forever = (milliseconds > 0) ? false : true; + bool forever = (milliseconds <= 0); // Packet handling is done with asynchronous callbacks. Run a sleeping loop in the main // thread until we run out of time or the program is closed diff --git a/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs b/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs index 454ed951..d5e9ca78 100644 --- a/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs +++ b/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs @@ -56,7 +56,7 @@ namespace OpenMetaverse.TestClient } else { - result.AppendFormat("The {0} Asset Animation is being played, sequence is {0}", kvp.Key, kvp.Value); + result.AppendFormat("The {0} Asset Animation is being played, sequence is {1}", kvp.Key, kvp.Value); } }); } diff --git a/Programs/examples/TestClient/Commands/Groups/InviteGroupCommand.cs b/Programs/examples/TestClient/Commands/Groups/InviteGroupCommand.cs index ff1397c2..d1cb5398 100644 --- a/Programs/examples/TestClient/Commands/Groups/InviteGroupCommand.cs +++ b/Programs/examples/TestClient/Commands/Groups/InviteGroupCommand.cs @@ -19,24 +19,33 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { if (args.Length < 2) + { return Description; + } UUID avatar = UUID.Zero; UUID group = UUID.Zero; UUID role = UUID.Zero; List roles = new List(); - if (!UUID.TryParse(args[0], out avatar)) - return "parse error avatar UUID"; - if (!UUID.TryParse(args[1], out group)) - return "parse error group UUID"; + if (!UUID.TryParse(args[0], out avatar)) { return "parse error avatar UUID"; } + if (!UUID.TryParse(args[1], out group)) { return "parse error group UUID"; } + if (2 == args.Length) - roles.Add(UUID.Zero); - else - for (int i = 2; i < args.Length; i++) - if (UUID.TryParse(args[i], out role)) - roles.Add(role); - + { + roles.Add(UUID.Zero); + } + else + { + for (int i = 2; i < args.Length; i++) + { + if (UUID.TryParse(args[i], out role)) + { + roles.Add(role); + } + } + } + Client.Groups.Invite(group, roles, avatar); return "invited "+avatar+" to "+group; diff --git a/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs b/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs index 4e79351a..68165e7a 100644 --- a/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs @@ -255,39 +255,33 @@ namespace OpenMetaverse.TestClient // first scan this folder for text foreach (InventoryNode iNode in folder.Nodes.Values) { - if (BackupWorker.CancellationPending) - return; - if (iNode.Data is OpenMetaverse.InventoryItem) + if (BackupWorker.CancellationPending) return; + if (!(iNode.Data is InventoryItem ii)) continue; + if (ii.AssetType != AssetType.LSLText && ii.AssetType != AssetType.Notecard) continue; + // check permissions on scripts + if (ii.AssetType == AssetType.LSLText) { - InventoryItem ii = iNode.Data as InventoryItem; - if (ii.AssetType == AssetType.LSLText || ii.AssetType == AssetType.Notecard) + if ((ii.Permissions.OwnerMask & PermissionMask.Modify) == PermissionMask.None) { - // check permissions on scripts - if (ii.AssetType == AssetType.LSLText) - { - if ((ii.Permissions.OwnerMask & PermissionMask.Modify) == PermissionMask.None) - { - // skip this one - continue; - } - } - - string sExtension = (ii.AssetType == AssetType.LSLText) ? ".lsl" : ".txt"; - // make the output file - string sPath = sPathSoFar + @"\" + MakeValid(ii.Name.Trim()) + sExtension; - - // create the new qdi - QueuedDownloadInfo qdi = new QueuedDownloadInfo(sPath, ii.AssetUUID, iNode.Data.UUID, UUID.Zero, - Client.Self.AgentID, ii.AssetType); - - // add it to the queue - lock (PendingDownloads) - { - TextItemsFound++; - PendingDownloads.Enqueue(qdi); - } + // skip this one + continue; } } + + string sExtension = (ii.AssetType == AssetType.LSLText) ? ".lsl" : ".txt"; + // make the output file + string sPath = sPathSoFar + @"\" + MakeValid(ii.Name.Trim()) + sExtension; + + // create the new qdi + QueuedDownloadInfo qdi = new QueuedDownloadInfo(sPath, ii.AssetUUID, ii.UUID, UUID.Zero, + Client.Self.AgentID, ii.AssetType); + + // add it to the queue + lock (PendingDownloads) + { + TextItemsFound++; + PendingDownloads.Enqueue(qdi); + } } // now run any subfolders diff --git a/Programs/examples/TestClient/Commands/Inventory/ChangeDirectoryCommand.cs b/Programs/examples/TestClient/Commands/Inventory/ChangeDirectoryCommand.cs index 30299103..a95a482f 100644 --- a/Programs/examples/TestClient/Commands/Inventory/ChangeDirectoryCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/ChangeDirectoryCommand.cs @@ -42,9 +42,8 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell return "Error: Client not logged in."; // Traverse the path, looking for the - for (int i = 0; i < path.Length; ++i) + foreach (var nextName in path) { - string nextName = path[i]; if (string.IsNullOrEmpty(nextName) || nextName == ".") continue; // Ignore '.' and blanks, stay in the current directory. if (nextName == ".." && currentFolder != Inventory.RootFolder) diff --git a/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs b/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs index 73cda4c7..b662327c 100644 --- a/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs @@ -19,9 +19,7 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell { if (args.Length > 1) return "Usage: ls [-l]"; - bool longDisplay = false; - if (args.Length > 0 && args[0] == "-l") - longDisplay = true; + bool longDisplay = false || args.Length > 0 && args[0] == "-l"; Manager = Client.Inventory; Inventory = Manager.Store; diff --git a/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs b/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs index c359423b..28fe8478 100644 --- a/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs @@ -63,12 +63,12 @@ namespace OpenMetaverse.TestClient AssetType.Texture, InventoryType.Texture, Client.Inventory.FindFolderForType(AssetType.Texture), delegate(bool success, string status, UUID itemID, UUID assetID) { - Console.WriteLine(String.Format( - "RequestCreateItemFromAsset() returned: Success={0}, Status={1}, ItemID={2}, AssetID={3}", - success, status, itemID, assetID)); + Console.WriteLine( + "RequestCreateItemFromAsset() returned: Success={0}, Status={1}, ItemID={2}, AssetID={3}", + success, status, itemID, assetID); TextureID = assetID; - Console.WriteLine(String.Format("Upload took {0}", DateTime.Now.Subtract(start))); + Console.WriteLine("Upload took {0}", DateTime.Now.Subtract(start)); UploadCompleteEvent.Set(); } ); diff --git a/Programs/examples/TestClient/Commands/Land/GridLayerCommand.cs b/Programs/examples/TestClient/Commands/Land/GridLayerCommand.cs index bb775feb..d1ece210 100644 --- a/Programs/examples/TestClient/Commands/Land/GridLayerCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/GridLayerCommand.cs @@ -16,8 +16,8 @@ namespace OpenMetaverse.TestClient void Grid_GridLayer(object sender, GridLayerEventArgs e) { - Console.WriteLine(String.Format("Layer({0}) Bottom: {1} Left: {2} Top: {3} Right: {4}", - e.Layer.ImageID.ToString(), e.Layer.Bottom, e.Layer.Left, e.Layer.Top, e.Layer.Right)); + Console.WriteLine("Layer({0}) Bottom: {1} Left: {2} Top: {3} Right: {4}", + e.Layer.ImageID.ToString(), e.Layer.Bottom, e.Layer.Left, e.Layer.Top, e.Layer.Right); } public override string Execute(string[] args, UUID fromAgentID) diff --git a/Programs/examples/TestClient/Commands/Movement/CrouchCommand.cs b/Programs/examples/TestClient/Commands/Movement/CrouchCommand.cs index ac5a1ce2..a7ac10b2 100644 --- a/Programs/examples/TestClient/Commands/Movement/CrouchCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/CrouchCommand.cs @@ -14,10 +14,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { - bool start = true; - - if (args.Length == 1 && args[0].ToLower() == "stop") - start = false; + bool start = !(args.Length == 1 && args[0].ToLower() == "stop"); if (start) { diff --git a/Programs/examples/TestClient/Commands/Movement/FlyCommand.cs b/Programs/examples/TestClient/Commands/Movement/FlyCommand.cs index aaf85e96..6698aa88 100644 --- a/Programs/examples/TestClient/Commands/Movement/FlyCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/FlyCommand.cs @@ -14,10 +14,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { - bool start = true; - - if (args.Length == 1 && args[0].ToLower() == "stop") - start = false; + bool start = !(args.Length == 1 && args[0].ToLower() == "stop"); if (start) { diff --git a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs index e5f3e725..30586501 100644 --- a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs @@ -86,8 +86,7 @@ namespace OpenMetaverse.TestClient { GotPermissions = false; if (Properties.OwnerID != Client.Self.AgentID && - Properties.OwnerID != Client.MasterKey && - Client.Self.AgentID != Client.Self.AgentID) + Properties.OwnerID != Client.MasterKey) { return "That object is owned by " + Properties.OwnerID + ", we don't have permission " + "to export it"; @@ -95,10 +94,7 @@ namespace OpenMetaverse.TestClient } List prims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll( - delegate(Primitive prim) - { - return (prim.LocalID == localid || prim.ParentID == localid); - } + prim => (prim.LocalID == localid || prim.ParentID == localid) ); bool complete = RequestObjectProperties(prims, 250); diff --git a/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs b/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs index 90b75e25..6a50961c 100644 --- a/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs @@ -49,15 +49,13 @@ namespace OpenMetaverse.TestClient { string name = p.Properties != null ? p.Properties.Name : null; if (String.IsNullOrEmpty(searchString) || ((name != null) && (name.Contains(searchString)))) - Console.WriteLine(String.Format("Object '{0}': {1}", name, p.ID.ToString())); + Console.WriteLine("Object '{0}': {1}", name, p.ID.ToString()); } - if (!complete) - { - Console.WriteLine("Warning: Unable to retrieve full properties for:"); - foreach (UUID uuid in PrimsWaiting.Keys) - Console.WriteLine(uuid); - } + if (complete) return "Done searching"; + Console.WriteLine("Warning: Unable to retrieve full properties for:"); + foreach (UUID uuid in PrimsWaiting.Keys) + Console.WriteLine(uuid); return "Done searching"; } diff --git a/Programs/examples/TestClient/Commands/System/LogPacketCommand.cs b/Programs/examples/TestClient/Commands/System/LogPacketCommand.cs index 1226f0ed..7a0178dd 100644 --- a/Programs/examples/TestClient/Commands/System/LogPacketCommand.cs +++ b/Programs/examples/TestClient/Commands/System/LogPacketCommand.cs @@ -76,7 +76,7 @@ namespace OpenMetaverse.TestClient if (!m_isLogging) return; - m_logStreamWriter.WriteLine("Received: {0}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff")); + m_logStreamWriter.WriteLine("Received: {0:yyyy-MM-dd hh:mm:ss.fff}", DateTime.Now); try {