Modernize TestClient
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<UUID, TestClient> Clients = new Dictionary<UUID, TestClient>();
|
||||
public Dictionary<Simulator, Dictionary<uint, Primitive>> SimPrims = new Dictionary<Simulator, Dictionary<uint, Primitive>>();
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace OpenMetaverse.TestClient
|
||||
public static string[] ParseArguments(string str)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
string current = String.Empty;
|
||||
string current = string.Empty;
|
||||
string trimmed = null;
|
||||
bool withinQuote = false;
|
||||
bool escaped = false;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenMetaverse.TestClient
|
||||
private System.Timers.Timer updateTimer;
|
||||
private UUID GroupMembersRequestID;
|
||||
public Dictionary<UUID, Group> GroupsCache = null;
|
||||
private ManualResetEvent GroupsEvent = new ManualResetEvent(false);
|
||||
private readonly ManualResetEvent GroupsEvent = new ManualResetEvent(false);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user