public Application( IWebSocketCore webSocketCore, IConnectionService connectionService, ILoginSystem loginSystem, ICommandSystem commandSystem, IMovementSystem movementSystem, IChatSystem chatSystem, IStoreSystem storeSystem, ICombatSystem combatSystem, IInventorySystem inventorySystem, ILocationSender locationSender, IChatSender chatSender, IJoinSender joinSender) { _webSocketCore = webSocketCore; _connectionService = connectionService; _commandSystem = commandSystem; _movementSystem = movementSystem; _chatSystem = chatSystem; _storeSystem = storeSystem; _combatSystem = combatSystem; _inventorySystem = inventorySystem; _loginSystem = loginSystem; _locationSender = locationSender; _chatSender = chatSender; _joinSender = joinSender; }
protected CommandEventBase(ICommandSender sender, string message, string prefix, ICommandSystem system, EventType type) { Sender = sender; Message = message; Prefix = prefix; System = system; Type = type; }
public void UnregisterCommand(string command, Plugin plugin) { ICommandSystem commandSystem = this.cmdSystem; if (commandSystem == null) { return; } commandSystem.UnregisterCommand(command, plugin); }
public PathsTests() { //Arrange _commandSystemMock = new Mock <ICommandSystem>(MockBehavior.Strict); this._commandSystem = _commandSystemMock.Object; _fileSystemMock = new Mock <IFileSystem>(MockBehavior.Strict); this._fileSystem = _fileSystemMock.Object; _commandSystemMock .Setup(cs => cs.GetHomeFolder(It.Is <string>(s => s == "~"))) .Returns("/Users/user"); this._userFolder = _commandSystem.GetHomeFolder("~"); }
public PathsConfigurator(ICommandSystem commandSystem, IFileSystem fileSystem) { if (commandSystem == null) { throw new ArgumentException(nameof(commandSystem)); } if (fileSystem == null) { throw new ArgumentException(nameof(fileSystem)); } _commandSystem = commandSystem; _fileSystem = fileSystem; }
public DiskTests() { //Arrange Mock <ICommandSystem> commandSystemMock = new Mock <ICommandSystem>(MockBehavior.Strict); ICommandSystem commandSystem = commandSystemMock.Object; _fileSystemMock = new Mock <IFileSystem>(MockBehavior.Strict); this._fileSystem = _fileSystemMock.Object; commandSystemMock .Setup(cs => cs.GetHomeFolder(It.Is <string>(s => s == "~"))) .Returns("/Users/user"); this._userFolder = commandSystem.GetHomeFolder("~"); _notificationSystemMock = new Mock <INotificationSystem>(MockBehavior.Strict); this._notificationSystem = _notificationSystemMock.Object; }
public CommandPostExecutionEvent(ICommandSender sender, string message, string prefix, ICommandSystem system) : base(sender, message, prefix, system, EventType.Post) { }
/// <summary> /// Initializes the Covalence library /// </summary> internal void Initialize() { // Search for all provider types var baseType = typeof(ICovalenceProvider); IEnumerable <Type> candidateSet = null; foreach (var ass in AppDomain.CurrentDomain.GetAssemblies()) { Type[] assTypes = null; try { assTypes = ass.GetTypes(); } catch (ReflectionTypeLoadException rtlEx) { assTypes = rtlEx.Types; } catch (TypeLoadException tlEx) { logger.Write(LogType.Warning, "Covalence: Type {0} could not be loaded from assembly '{1}': {2}", tlEx.TypeName, ass.FullName, tlEx); } if (assTypes != null) { candidateSet = candidateSet?.Concat(assTypes) ?? assTypes; } } if (candidateSet == null) { logger.Write(LogType.Warning, "No Covalence providers found, Covalence will not be functional for this session."); return; } var candidates = new List <Type>( candidateSet.Where(t => t != null && t.IsClass && !t.IsAbstract && t.FindInterfaces((m, o) => m == baseType, null).Length == 1) ); // Select a candidate Type selectedCandidate; if (candidates.Count == 0) { logger.Write(LogType.Warning, "No Covalence providers found, Covalence will not be functional for this session."); return; } if (candidates.Count > 1) { selectedCandidate = candidates[0]; var sb = new StringBuilder(); for (var i = 1; i < candidates.Count; i++) { if (i > 1) { sb.Append(','); } sb.Append(candidates[i].FullName); } logger.Write(LogType.Warning, "Multiple Covalence providers found! Using {0}. (Also found {1})", selectedCandidate, sb); } else { selectedCandidate = candidates[0]; } // Create it try { provider = (ICovalenceProvider)Activator.CreateInstance(selectedCandidate); } catch (Exception ex) { logger.Write(LogType.Warning, "Got exception when instantiating Covalence provider, Covalence will not be functional for this session."); logger.Write(LogType.Warning, "{0}", ex); return; } // Create mediators Server = provider.CreateServer(); Players = provider.CreatePlayerManager(); cmdSystem = provider.CreateCommandSystemProvider(); // Initialize other things commands = new Dictionary <string, RegisteredCommand>(); // Log logger.Write(LogType.Info, "Using Covalence provider for game '{0}'", provider.GameName); }
public static bool ShouldProcess(string command, ICommandSystem system) { return(system.GetPrefixes().Any(command.StartsWith)); }
public static void AddCommandSystem(ICommandSystem commandSystem) { CommandSystems.Add(commandSystem); }
/// <summary> /// Initializes the Covalence library /// </summary> internal void Initialize() { // Search for all provider types Type baseType = typeof(ICovalenceProvider); IEnumerable<Type> candidateSet = null; foreach (var ass in AppDomain.CurrentDomain.GetAssemblies()) { Type[] assTypes = null; try { assTypes = ass.GetTypes(); } catch (ReflectionTypeLoadException rtlEx) { assTypes = rtlEx.Types; } catch (TypeLoadException tlEx) { logger.Write(LogType.Warning, "Covalence: Type {0} could not be loaded from assembly '{1}': {2}", tlEx.TypeName, ass.FullName, tlEx); } if (assTypes != null) { if (candidateSet == null) candidateSet = assTypes; else candidateSet = candidateSet.Concat(assTypes); } } if (candidateSet == null) { logger.Write(LogType.Warning, "No Covalence providers found, Covalence will not be functional for this session."); return; } List<Type> candidates = new List<Type>( candidateSet.Where((t) => t != null && t.IsClass && !t.IsAbstract && t.FindInterfaces((m, o) => m == baseType, null).Length == 1) ); // Select a candidate Type selectedCandidate; if (candidates.Count == 0) { logger.Write(LogType.Warning, "No Covalence providers found, Covalence will not be functional for this session."); return; } else if (candidates.Count > 1) { selectedCandidate = candidates[0]; StringBuilder sb = new StringBuilder(); for (int i = 1; i < candidates.Count; i++) { if (i > 1) sb.Append(','); sb.Append(candidates[i].FullName); } logger.Write(LogType.Warning, "Multiple Covalence providers found! Using {0}. (Also found {1})", selectedCandidate, sb); } else selectedCandidate = candidates[0]; // Create it try { provider = (ICovalenceProvider) Activator.CreateInstance(selectedCandidate); } catch (Exception ex) { logger.Write(LogType.Warning, "Got exception when instantiating Covalence provider, Covalence will not be functional for this session."); logger.Write(LogType.Warning, "{0}", ex); return; } // Create mediators Server = provider.CreateServer(); Players = provider.CreatePlayerManager(); cmdSystem = provider.CreateCommandSystemProvider(); // Initialize other things commands = new Dictionary<string, RegisteredCommand>(); // Log logger.Write(LogType.Info, "Using Covalence provider for game '{0}'", provider.GameName); }
internal void Initialize() { Type item; object obj; TypeFilter typeFilter2 = null; Type type1 = typeof(ICovalenceProvider); IEnumerable <Type> types = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < (int)assemblies.Length; i++) { Assembly assembly = assemblies[i]; Type[] typeArray = null; try { typeArray = assembly.GetTypes(); } catch (ReflectionTypeLoadException reflectionTypeLoadException) { typeArray = reflectionTypeLoadException.Types; } catch (TypeLoadException typeLoadException1) { TypeLoadException typeLoadException = typeLoadException1; this.logger.Write(LogType.Warning, "Covalence: Type {0} could not be loaded from assembly '{1}': {2}", new object[] { typeLoadException.TypeName, assembly.FullName, typeLoadException }); } if (typeArray != null) { if (types != null) { obj = types.Concat <Type>(typeArray); } else { obj = null; } if (obj == null) { obj = typeArray; } types = (IEnumerable <Type>)obj; } } if (types == null) { this.logger.Write(LogType.Warning, "Covalence not available yet for this game", Array.Empty <object>()); return; } List <Type> types1 = new List <Type>(types.Where <Type>((Type t) => { if (!(t != null) || !t.IsClass || t.IsAbstract) { return(false); } Type type = t; TypeFilter u003cu003e9_1 = typeFilter2; if (u003cu003e9_1 == null) { TypeFilter typeFilter = (Type m, object o) => m == type1; TypeFilter typeFilter1 = typeFilter; typeFilter2 = typeFilter; u003cu003e9_1 = typeFilter1; } return((int)type.FindInterfaces(u003cu003e9_1, null).Length == 1); })); if (types1.Count == 0) { this.logger.Write(LogType.Warning, "Covalence not available yet for this game", Array.Empty <object>()); return; } if (types1.Count <= 1) { item = types1[0]; } else { item = types1[0]; StringBuilder stringBuilder = new StringBuilder(); for (int j = 1; j < types1.Count; j++) { if (j > 1) { stringBuilder.Append(','); } stringBuilder.Append(types1[j].FullName); } this.logger.Write(LogType.Warning, "Multiple Covalence providers found! Using {0}. (Also found {1})", new object[] { item, stringBuilder }); } try { this.provider = (ICovalenceProvider)Activator.CreateInstance(item); } catch (Exception exception1) { Exception exception = exception1; this.logger.Write(LogType.Warning, "Got exception when instantiating Covalence provider, Covalence will not be functional for this session.", Array.Empty <object>()); this.logger.Write(LogType.Warning, "{0}", new object[] { exception }); return; } this.Server = this.provider.CreateServer(); this.Players = this.provider.CreatePlayerManager(); this.cmdSystem = this.provider.CreateCommandSystemProvider(); this.logger.Write(LogType.Info, "Using Covalence provider for game '{0}'", new object[] { this.provider.GameName }); }
public static ICommandContext CreateContext(this ICommandSystem commandSystem, string name, params ICommandContext[] sharedContexts) => commandSystem.CreateContext(name, protectedVariableChangeString: null, sharedContexts);