示例#1
0
		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);

        }
示例#3
0
		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);
			}
		}
示例#4
0
		public void Execute(ShellContext context, string arguments)
		{
			if (arguments.Length == 0)
			{
				Console.WriteLine("Syntax : !run <file>");
			}
			else
			{
				context.Script.DoFile(arguments);
			}
		}
示例#5
0
		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);
		}
示例#8
0
        /// <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);
        }
示例#9
0
		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);
 }
示例#12
0
		public void Execute(ShellContext context, string arguments)
		{
			Environment.Exit(0);
		}