diff --git a/.gitignore b/.gitignore index 828a8ca4..a20c64ad 100644 --- a/.gitignore +++ b/.gitignore @@ -3,9 +3,11 @@ compile.bat *.userprefs *.suo *.cache +*.pfx [Oo]bj/ [Bb]in/ packages/ .idea/ .vs/ +/Programs/examples/TestClient/Properties/launchSettings.json diff --git a/Programs/examples/TestClient/Arguments.cs b/Programs/examples/TestClient/Arguments.cs index 7e3bf4b1..4b63a901 100644 --- a/Programs/examples/TestClient/Arguments.cs +++ b/Programs/examples/TestClient/Arguments.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Specialized; using System.Text.RegularExpressions; @@ -100,12 +99,6 @@ namespace CommandLine.Utility // Retrieve a parameter value if it exists // (overriding C# indexer property) - public string this[string Param] - { - get - { - return (Parameters[Param]); - } - } + public string this[string Param] => (Parameters[Param]); } } diff --git a/Programs/examples/TestClient/ClientManager.cs b/Programs/examples/TestClient/ClientManager.cs index 985b7534..6e66cd9a 100644 --- a/Programs/examples/TestClient/ClientManager.cs +++ b/Programs/examples/TestClient/ClientManager.cs @@ -41,7 +41,7 @@ namespace OpenMetaverse.TestClient const string VERSION = "1.0.0"; class Singleton { internal static readonly ClientManager Instance = new ClientManager(); } - public static ClientManager Instance { get { return Singleton.Instance; } } + public static ClientManager Instance => Singleton.Instance; public Dictionary Clients = new Dictionary(); public Dictionary> SimPrims = new Dictionary>(); @@ -49,7 +49,7 @@ namespace OpenMetaverse.TestClient public bool Running = true; public bool GetTextures = false; public volatile int PendingLogins = 0; - public string onlyAvatar = String.Empty; + public string onlyAvatar = string.Empty; ClientManager() { @@ -70,10 +70,13 @@ namespace OpenMetaverse.TestClient Console.WriteLine("Usage: login firstname lastname password [simname] [login server url]"); return null; } - LoginDetails account = new LoginDetails(); - account.FirstName = args[0]; - account.LastName = args[1]; - account.Password = args[2]; + + LoginDetails account = new LoginDetails + { + FirstName = args[0], + LastName = args[1], + Password = args[2] + }; if (args.Length > 3) { @@ -90,8 +93,8 @@ namespace OpenMetaverse.TestClient string[] startbits = args[3].Split(sep); try { - account.StartLocation = NetworkManager.StartLocation(startbits[0], Int32.Parse(startbits[1]), - Int32.Parse(startbits[2]), Int32.Parse(startbits[3])); + account.StartLocation = NetworkManager.StartLocation(startbits[0], int.Parse(startbits[1]), + int.Parse(startbits[2]), int.Parse(startbits[3])); } catch (FormatException) { } } @@ -131,7 +134,7 @@ namespace OpenMetaverse.TestClient client.Network.LoginProgress += delegate(object sender, LoginProgressEventArgs e) { - Logger.Log(String.Format("Login {0}: {1}", e.Status, e.Message), Helpers.LogLevel.Info, client); + Logger.Log($"Login {e.Status}: {e.Message}", Helpers.LogLevel.Info, client); if (e.Status == LoginStatus.Success) { @@ -349,7 +352,7 @@ namespace OpenMetaverse.TestClient result = testClient.Commands[firstToken].Execute(args, fromAgentID); Logger.Log(result, Helpers.LogLevel.Info, testClient); } catch(Exception e) { - Logger.Log(String.Format("{0} raised exception {1}", firstToken, e), + Logger.Log($"{firstToken} raised exception {e}", Helpers.LogLevel.Error, testClient); } diff --git a/Programs/examples/TestClient/Command.cs b/Programs/examples/TestClient/Command.cs index be13c2dd..a007e8a0 100644 --- a/Programs/examples/TestClient/Command.cs +++ b/Programs/examples/TestClient/Command.cs @@ -48,9 +48,8 @@ namespace OpenMetaverse.TestClient public int CompareTo(object obj) { - if (obj is Command) + if (obj is Command c2) { - Command c2 = (Command)obj; return Category.CompareTo(c2.Category); } else diff --git a/Programs/examples/TestClient/Parsing.cs b/Programs/examples/TestClient/Parsing.cs index b5b7f06b..9ae15512 100644 --- a/Programs/examples/TestClient/Parsing.cs +++ b/Programs/examples/TestClient/Parsing.cs @@ -9,7 +9,7 @@ namespace OpenMetaverse.TestClient public static string[] ParseArguments(string str) { List list = new List(); - string current = String.Empty; + string current = string.Empty; string trimmed = null; bool withinQuote = false; bool escaped = false; diff --git a/Programs/examples/TestClient/Program.cs b/Programs/examples/TestClient/Program.cs index bd35aaf9..c2f614e1 100644 --- a/Programs/examples/TestClient/Program.cs +++ b/Programs/examples/TestClient/Program.cs @@ -60,7 +60,7 @@ namespace OpenMetaverse.TestClient scriptFile = arguments["scriptfile"]; if (!File.Exists(scriptFile)) { - Logger.Log(String.Format("File {0} Does not exist", scriptFile), Helpers.LogLevel.Error); + Logger.Log($"File {scriptFile} Does not exist", Helpers.LogLevel.Error); return; } } @@ -71,46 +71,46 @@ namespace OpenMetaverse.TestClient if (!File.Exists(file)) { - Logger.Log(String.Format("File {0} Does not exist", file), Helpers.LogLevel.Error); + Logger.Log($"File {file} Does not exist", Helpers.LogLevel.Error); return; } // Loading names from a file try { - using (StreamReader reader = new StreamReader(file)) + using StreamReader reader = new StreamReader(file); + string line; + int lineNumber = 0; + + while ((line = reader.ReadLine()) != null) { - string line; - int lineNumber = 0; + lineNumber++; + string[] tokens = line.Trim().Split(new char[] { ' ', ',' }); - while ((line = reader.ReadLine()) != null) + if (tokens.Length >= 3) { - lineNumber++; - string[] tokens = line.Trim().Split(new char[] { ' ', ',' }); - - if (tokens.Length >= 3) + account = new LoginDetails { - account = new LoginDetails(); - account.FirstName = tokens[0]; - account.LastName = tokens[1]; - account.Password = tokens[2]; + FirstName = tokens[0], + LastName = tokens[1], + Password = tokens[2] + }; - if (tokens.Length >= 4) // Optional starting position - { - 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])); - } - - accounts.Add(account); - } - else + if (tokens.Length >= 4) // Optional starting position { - Logger.Log("Invalid data on line " + lineNumber + - ", must be in the format of: FirstName LastName Password [Sim/StartX/StartY/StartZ]", - Helpers.LogLevel.Warning); + 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])); } + + accounts.Add(account); + } + else + { + Logger.Log("Invalid data on line " + lineNumber + + ", must be in the format of: FirstName LastName Password [Sim/StartX/StartY/StartZ]", + Helpers.LogLevel.Warning); } } } @@ -123,10 +123,12 @@ namespace OpenMetaverse.TestClient else if (arguments["first"] != null && arguments["last"] != null && arguments["pass"] != null) { // Taking a single login off the command-line - account = new LoginDetails(); - account.FirstName = arguments["first"]; - account.LastName = arguments["last"]; - account.Password = arguments["pass"]; + account = new LoginDetails + { + FirstName = arguments["first"], + LastName = arguments["last"], + Password = arguments["pass"] + }; accounts.Add(account); } diff --git a/Programs/examples/TestClient/TestClient.cs b/Programs/examples/TestClient/TestClient.cs index abce396f..4e6070e2 100644 --- a/Programs/examples/TestClient/TestClient.cs +++ b/Programs/examples/TestClient/TestClient.cs @@ -28,7 +28,7 @@ namespace OpenMetaverse.TestClient private System.Timers.Timer updateTimer; private UUID GroupMembersRequestID; public Dictionary GroupsCache = null; - private ManualResetEvent GroupsEvent = new ManualResetEvent(false); + private readonly ManualResetEvent GroupsEvent = new ManualResetEvent(false); /// /// @@ -203,7 +203,7 @@ namespace OpenMetaverse.TestClient lock(GroupsCache) { if (GroupsCache.Count > 0) { foreach (Group currentGroup in GroupsCache.Values) - if (currentGroup.Name.ToLower() == groupName.ToLower()) + if (String.Equals(currentGroup.Name, groupName, StringComparison.CurrentCultureIgnoreCase)) return currentGroup.ID; } }