public DefaultConsole(IDependencyContainer container, IUserManager userManager) { UserManager = userManager; SessionConnectTime = DateTime.Now; BaseLogger.SkipTypeFromLogging(GetType()); Container = container.CreateChildContainer(); }
protected ClrPluginLoader(IDependencyContainer dependencyContainer, IEventBus eventBus, ILogger logger) { EventBus = eventBus; Logger = logger; ParentContainer = dependencyContainer; Container = dependencyContainer.CreateChildContainer(); cachedAssemblies = new Dictionary <string, Assembly>(); }
protected CLRPluginManager(IDependencyContainer dependencyContainer, IEventManager eventManager, ILogger logger) { EventManager = eventManager; Logger = logger; ParentContainer = dependencyContainer; Container = dependencyContainer.CreateChildContainer(); cachedAssemblies = new Dictionary <string, Assembly>(); }
public override ScriptResult ExecuteFile( string path, IDependencyContainer container, ref IScriptContext context, ScriptPluginMeta meta, bool createPluginInstanceOnNull = false, string entryPoint = null, params object[] arguments ) { if (context == null) { context = CreateScriptContext(container.CreateChildContainer()); if (createPluginInstanceOnNull) { var plugin = (JavaScriptPlugin)GetPlugin(meta.Name); if (plugin == null) { plugin = new JavaScriptPlugin(meta, context.Container, this, (JavaScriptContext)context); AddPlugin(plugin); } ((JavaScriptContext)context).Plugin = plugin; context.SetGlobalVariables(); ExecuteFromFileWithImports(((JavaScriptContext)context).ScriptEngine, path); plugin.Load(false); return(new ScriptResult(ScriptExecutionResult.Success)); } } context.SetGlobalVariables(); var engine = ((JavaScriptContext)context).ScriptEngine; if (engine == null) { return(new ScriptResult(ScriptExecutionResult.FailedMisc)); } ExecuteFromFileWithImports(engine, path); if (entryPoint != null) { engine.Invoke(entryPoint, arguments); } var ret = engine.GetCompletionValue(); return(new ScriptResult(ScriptExecutionResult.Success) { HasReturn = ret.Type != Types.None, Return = ret == JsValue.Null ? null : ret }); }
public override ScriptResult ExecuteFile( string path, IDependencyContainer container, ref IScriptContext context, ScriptPluginMeta meta, bool createPluginInstanceOnNull = false, string entryPoint = null, params object[] arguments ) { if (context == null) { context = CreateScriptContext(container.CreateChildContainer()); if (createPluginInstanceOnNull) { var plugin = (CSharpPlugin)GetPlugin(meta.Name); if (plugin == null) { plugin = new CSharpPlugin(meta, context.Container, this, (CSharpScriptContext)context); _plugins.Add(plugin); } ((CSharpScriptContext)context).Plugin = plugin; context.SetGlobalVariables(); plugin.Load(false); return(new ScriptResult(ScriptExecutionResult.Success)); } } context.SetGlobalVariables(); var engine = ((CSharpScriptContext)context).Evaluator; if (engine == null) { return(new ScriptResult(ScriptExecutionResult.FailedMisc)); } engine.LoadFile(path); /* * var ret = engine.CallGlobalFunction(entryPoint, context); * var res = new ScriptResult(ScriptExecutionResult.Success) * { * HasReturn = ret is Undefined, * Return = ret is Null ? null : ret * }; * return res; */ return(new ScriptResult(ScriptExecutionResult.Success)); }
public RconConnection(IDependencyContainer container, TcpClient client, IUserManager userManager, ILogger logger, int connectionId, bool useAnsi) { _logger = logger; _useAnsi = useAnsi; Client = client; RemoteEndPoint = client.Client.RemoteEndPoint; Authenticated = false; SessionConnectTime = DateTime.Now; UserManager = userManager; ConnectionId = connectionId; Container = container.CreateChildContainer(); }
public async Task <bool> HandleCommandAsync(IUser user, string commandLine, string prefix) { GuardUser(user); commandLine = commandLine.Trim(); string[] args = commandLine.Split(' '); IDependencyContainer contextContainer = container.CreateChildContainer(); IRocketSettingsProvider settings = contextContainer.Resolve <IRocketSettingsProvider>(); CommandContext context = new CommandContext(contextContainer, user, prefix, null, args[0], args.Skip(1).ToArray(), null, null); ICommand target = context.Container.Resolve <ICommandProvider>() .Commands.GetCommand(context.CommandAlias, user); if (target == null) { return(false); // only return false when the command was not found } context.Command = target; List <ICommand> tree = new List <ICommand> { context.Command }; context = GetChild(context, context, tree); var permission = GetPermission(context); try { IPermissionProvider provider = container.Resolve <IPermissionProvider>(); if (await provider.CheckPermissionAsync(user, permission) != PermissionResult.Grant) { var logger = container.Resolve <ILogger>(); logger.LogInformation($"User \"{user.UserName}\" does not have permission to execute: \"{commandLine}\""); throw new NotEnoughPermissionsException(user, permission); } if (settings.Settings.Logging.EnableCommandExecutionsLogs) { contextContainer.Resolve <ILogger>().LogInformation($"{user.UserName} has executed command: \"{commandLine}\""); } await context.Command.ExecuteAsync(context); } catch (Exception e) { if (e is ICommandFriendlyException exception) { await exception.SendErrorMessageAsync(context); return(true); } await context.User.SendMessageAsync("An internal error occured.", Color.DarkRed); throw new Exception($"Command \"{commandLine}\" of user \"{user.UserName}\" caused an exception: ", e); } return(true); }
public StdConsole(IDependencyContainer container) { SessionConnectTime = DateTime.UtcNow; BaseLogger.SkipTypeFromLogging(GetType()); Container = container.CreateChildContainer(); }
public IScope <T> Create() { var childContainer = _container.CreateChildContainer(); return(new ScopeResolve <T>(childContainer, childContainer.Resolve <T>())); }
protected ScriptingProvider(IDependencyContainer container) { Container = container.CreateChildContainer(); }
protected BasePlayer(IDependencyContainer container) { Container = container.CreateChildContainer(); }
protected BasePlayer(IDependencyContainer container, IPlayerManager manager) { Container = container.CreateChildContainer(); PlayerManager = manager; }
public TViewModel Create <TViewModel>() where TViewModel : IViewModel { IDependencyContainer childContainer = _container.CreateChildContainer(); return(childContainer.Resolve <TViewModel>()); }
public TestConsole(IDependencyContainer container) { BaseLogger.SkipTypeFromLogging(GetType()); Container = container.CreateChildContainer(); }