public void Execute(ShellContext context, string arguments) { if (arguments.Length > 0) { var cmd = CommandManager.Find(arguments); if (cmd != null) cmd.DisplayLongHelp(); else Console.WriteLine("Command '{0}' not found.", arguments); } else { Console.WriteLine("Type Lua code to execute Lua code (multilines are accepted)"); Console.WriteLine("or type one of the following commands to execute them."); Console.WriteLine(""); Console.WriteLine("Commands:"); Console.WriteLine(""); foreach (var cmd in CommandManager.GetCommands()) { Console.Write(" !"); cmd.DisplayShortHelp(); } Console.WriteLine(""); } }
public void Init() { var builder = new ContainerBuilder(); builder.RegisterType<DefaultProcessingEngine>().As<IProcessingEngine>(); builder.RegisterModule(new WorkContextModule()); builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>(); builder.RegisterAutoMocking(MockBehavior.Loose); _container = builder.Build(); _shellContext = new ShellContext { Descriptor = new ShellDescriptor(), Settings = new ShellSettings(), LifetimeScope = _container.BeginLifetimeScope(), }; var httpContext = new StubHttpContext(); _container.Mock<IShellContextFactory>() .Setup(x => x.CreateDescribedContext(_shellContext.Settings, _shellContext.Descriptor)) .Returns(_shellContext); _container.Mock<IHttpContextAccessor>() .Setup(x=>x.Current()) .Returns(httpContext); _container.Mock<IHttpContextAccessor>() .Setup(x => x.CreateContext(It.IsAny<ILifetimeScope>())) .Returns(httpContext); }
public void Execute(ShellContext context, string arguments) { if (m_Debugger == null) { m_Debugger = new RemoteDebuggerService(); m_Debugger.Attach(context.Script, "MoonSharp REPL interpreter", false); Process.Start(m_Debugger.HttpUrlStringLocalHost); } }
public void Execute(ShellContext context, string arguments) { if (arguments.Length == 0) { Console.WriteLine("Syntax : !run <file>"); } else { context.Script.DoFile(arguments); } }
public void Execute(ShellContext context, string p) { string targetFileName = p + "-compiled"; Script S = new Script(CoreModules.None); DynValue chunk = S.LoadFile(p); using (Stream stream = new FileStream(targetFileName, FileMode.Create, FileAccess.Write)) S.Dump(chunk, stream); }
public void Execute(ShellContext context, string argument) { if (argument.Length > 0) { Type t = Type.GetType(argument); if (t == null) Console.WriteLine("Type {0} not found.", argument); else UserData.RegisterType(t); } else { foreach (var type in UserData.GetRegisteredTypes()) { Console.WriteLine(type.FullName); } } }
public void Execute(ShellContext context, string argument) { Console.WriteLine("At any question, type #quit to abort."); Console.WriteLine(); string language = AskQuestion("Language, cs or vb ? [cs] : ", "cs", s => s == "cs" || s == "vb", "Must be 'cs' or 'vb'."); if (language == null) return; string luafile = AskQuestion("Lua dump table file: ", "", s => File.Exists(s), "File does not exists."); if (luafile == null) return; string destfile = AskQuestion("Destination file: ", "", s => true, ""); if (destfile == null) return; string allowinternals = AskQuestion("Allow internals y/n ? [y]: ", "y", s => s == "y" || s == "n", ""); if (allowinternals == null) return; string namespaceName = AskQuestion("Namespace ? [HardwiredClasses]: ", "HardwiredClasses", s => IsValidIdentifier(s), "Not a valid identifier."); if (namespaceName == null) return; string className = AskQuestion("Class ? [HardwireTypes]: ", "HardwireTypes", s => IsValidIdentifier(s), "Not a valid identifier."); if (className == null) return; Generate(language, luafile, destfile, allowinternals == "y", className, namespaceName); }
/// <summary> /// Starts a Shell and registers its settings in RunningShellTable /// </summary> private void ActivateShell(ShellContext context) { Logger.Debug("Activating context for tenant {0}", context.Settings.Name); context.Shell.Activate(); _shellContexts = (_shellContexts ?? Enumerable.Empty<ShellContext>()) .Where(c => c.Settings.Name != context.Settings.Name) .Concat(new[] { context }) .ToArray(); _runningShellTable.Add(context.Settings); }
public static void Execute(ShellContext context, string commandLine) { }
/// <summary> /// Start a Shell and register its settings in RunningShellTable /// </summary> private void ActivateShell(ShellContext context) { Logger.Debug("Activating context for tenant {0}", context.Settings.Name); context.Shell.Activate(); _shellContexts = (_shellContexts ?? Enumerable.Empty<ShellContext>()).Union(new [] {context}); _runningShellTable.Add(context.Settings); }
private void ActivateShell(ShellContext context) { context.Shell.Activate(); _runningShellTable.Add(context.Settings); HackSimulateExtensionActivation(context.LifetimeScope); }
public void Execute(ShellContext context, string arguments) { Environment.Exit(0); }