public ExecuteReplCommand( string scriptName, string[] scriptArgs, IFileSystem fileSystem, IScriptPackResolver scriptPackResolver, IRepl repl, ILogProvider logProvider, IConsole console, IAssemblyResolver assemblyResolver, IFileSystemMigrator fileSystemMigrator, IScriptLibraryComposer composer) { Guard.AgainstNullArgument("fileSystem", fileSystem); Guard.AgainstNullArgument("scriptPackResolver", scriptPackResolver); Guard.AgainstNullArgument("repl", repl); Guard.AgainstNullArgument("logProvider", logProvider); Guard.AgainstNullArgument("console", console); Guard.AgainstNullArgument("assemblyResolver", assemblyResolver); Guard.AgainstNullArgument("fileSystemMigrator", fileSystemMigrator); Guard.AgainstNullArgument("composer", composer); _scriptName = scriptName; _scriptArgs = scriptArgs; _fileSystem = fileSystem; _scriptPackResolver = scriptPackResolver; _repl = repl; _logger = logProvider.ForCurrentType(); _console = console; _assemblyResolver = assemblyResolver; _fileSystemMigrator = fileSystemMigrator; _composer = composer; }
public ScriptServices( IFileSystem fileSystem, IPackageAssemblyResolver packageAssemblyResolver, IScriptExecutor executor, IRepl repl, IScriptEngine engine, IFilePreProcessor filePreProcessor, IScriptPackResolver scriptPackResolver, IPackageInstaller packageInstaller, IObjectSerializer objectSerializer, ILog logger, IAssemblyResolver assemblyResolver, IEnumerable <IReplCommand> replCommands, IFileSystemMigrator fileSystemMigrator, IConsole console = null, IInstallationProvider installationProvider = null) { FileSystem = fileSystem; PackageAssemblyResolver = packageAssemblyResolver; Executor = executor; Repl = repl; Engine = engine; FilePreProcessor = filePreProcessor; ScriptPackResolver = scriptPackResolver; PackageInstaller = packageInstaller; ObjectSerializer = objectSerializer; Logger = logger; Console = console; AssemblyResolver = assemblyResolver; InstallationProvider = installationProvider; ReplCommands = replCommands; FileSystemMigrator = fileSystemMigrator; }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); var packContexts = repl.ScriptPackSession.Contexts; if (packContexts.IsNullOrEmpty()) { PrintInColor("There are no script packs available in this REPL session"); return(null); } var importedNamespaces = repl.ScriptPackSession.Namespaces.IsNullOrEmpty() ? repl.Namespaces.ToArray() : repl.Namespaces.Union(repl.ScriptPackSession.Namespaces).ToArray(); foreach (var packContext in packContexts) { var contextType = packContext.GetType(); PrintInColor(contextType.ToString()); var methods = contextType.GetAllMethods(); var properties = contextType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); PrintMethods(methods, importedNamespaces); PrintProperties(properties, importedNamespaces); _console.WriteLine(); } return(null); }
protected override void OnViewLoaded(object view) { replView = (IReplView)view; internalRepl = replView.GetRepl(); timer.Start(); }
public ScriptServices Build(IRepl repl) { //TODO: this need to be wired up properly using our own IoC container from caliburn. var underlyingLogger = LogManager.GetCurrentClassLogger(); var replLogger = new ReplLogger(LogLevel.Info, repl, underlyingLogger); ILog logger = replLogger; var fileSystem = new FileSystem(); var engine = new RoslynScriptEngine(new ReplScriptHostFactory(), logger); var filePreProcessor = new FilePreProcessor(fileSystem, logger, new ILineProcessor[] {new LoadLineProcessor(fileSystem), new ReferenceLineProcessor(fileSystem), new UsingLineProcessor() }); var packageAssemblyResolver = new PackageAssemblyResolver(fileSystem, new PackageContainer(fileSystem, logger), logger); var installationProvider = new NugetInstallationProvider(fileSystem, logger); return new ScriptServices( fileSystem, packageAssemblyResolver, new ScriptExecutor(fileSystem, filePreProcessor, engine, logger), engine, filePreProcessor, new ScriptPackResolver(new IScriptPack[0]), new PackageInstaller(installationProvider, logger), null, //IObjectSerializer logger, new AssemblyResolver(fileSystem, packageAssemblyResolver, new AssemblyUtility(), logger), null, //IConsole installationProvider ); }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); var replEngine = repl.ScriptEngine as IReplEngine; return replEngine != null ? replEngine.GetLocalVariables(repl.ScriptPackSession) : null; }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); _console.WriteLine("\nThe following commands are available in the REPL:"); foreach (var command in repl.Commands.OrderBy(x => x.Key)) { string key = string.Format(" :{0,-15} - ", command.Key); // make sure we have a good width for formatting purposes int descWidth = _console.Width - key.Length - 1; if (descWidth > 25) { _console.WriteLine(string.Format("{0}{1,10}", key, WrapTextToColumn(command.Value.Description, descWidth, indentWidth: key.Length))); } else { // safe-guard: just in the case we have a really long Repl Command "key" // and a really narrow console width don't wrap the description // note: the extra newline if to at least make somewhat readable _console.WriteLine(string.Format("{0}{1,10}\n", key, command.Value.Description)); } } _console.WriteLine(string.Empty); return(null); }
private bool ExecuteLine(IRepl repl) { var prompt = string.IsNullOrWhiteSpace(repl.Buffer) ? "> " : "* "; try { var line = _console.ReadLine(prompt); if (line == null) { return(false); } if (!string.IsNullOrWhiteSpace(line)) { repl.Execute(line); } return(true); } catch { return(false); } }
public WishModel() { _runspace = RunspaceFactory.CreateRunspace(); _runspace.Open(); _runner = new Powershell(_runspace); _repl = new Repl(_runner); }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); repl.Reset(); return(null); }
public ScriptServices( IFileSystem fileSystem, IPackageAssemblyResolver packageAssemblyResolver, IScriptExecutor executor, IRepl repl, IScriptEngine engine, IFilePreProcessor filePreProcessor, IScriptPackResolver scriptPackResolver, IPackageInstaller packageInstaller, IObjectSerializer objectSerializer, ILog logger, IAssemblyResolver assemblyResolver, IEnumerable<IReplCommand> replCommands, IConsole console = null, IInstallationProvider installationProvider = null) { FileSystem = fileSystem; PackageAssemblyResolver = packageAssemblyResolver; Executor = executor; Repl = repl; Engine = engine; FilePreProcessor = filePreProcessor; ScriptPackResolver = scriptPackResolver; PackageInstaller = packageInstaller; ObjectSerializer = objectSerializer; Logger = logger; Console = console; AssemblyResolver = assemblyResolver; InstallationProvider = installationProvider; ReplCommands = replCommands; }
public object Execute(IRepl repl, object[] args) { var packContexts = repl.ScriptPackSession.Contexts; if (packContexts.IsNullOrEmpty()) { PrintInColor("There are no script packs available in this REPL session"); return null; } var importedNamespaces = repl.ScriptPackSession.Namespaces.IsNullOrEmpty() ? repl.Namespaces.ToArray() : repl.Namespaces.Union(repl.ScriptPackSession.Namespaces).ToArray(); foreach (var packContext in packContexts) { var contextType = packContext.GetType(); PrintInColor(contextType.ToString()); var methods = contextType.GetAllMethods(); var properties = contextType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); PrintMethods(methods, importedNamespaces); PrintProperties(properties, importedNamespaces); _console.WriteLine(); } return null; }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); repl.Reset(); return null; }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); return repl.References != null ? repl.References.Assemblies.Select(x => x.FullName).Union(repl.References.PathReferences) : null; }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); var replEngine = repl.ScriptEngine as IReplEngine; return(replEngine != null?replEngine.GetLocalVariables(repl.ScriptPackSession) : null); }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); return(repl.References != null ? repl.References.Assemblies.Select(x => x.FullName).Union(repl.References.Paths) : null); }
public ReplLogger(LogLevel consoleLogLevel, IRepl repl, ILog log) { if (repl == null) throw new ArgumentNullException("repl"); if (log == null) throw new ArgumentNullException("log"); _consoleLogLevel = consoleLogLevel; _repl = repl; _log = log; }
public object Execute(IRepl repl, object[] args) { if (repl == null) { throw new ArgumentNullException(nameof(repl)); } return(repl.References?.Assemblies.Select(x => x.FullName).Union(repl.References.Paths)); }
public ExecuteReplCommand( string scriptName, string[] scriptArgs, IFileSystem fileSystem, IScriptPackResolver scriptPackResolver, IRepl repl, ILogProvider logProvider, IConsole console, IAssemblyResolver assemblyResolver, IFileSystemMigrator fileSystemMigrator, IScriptLibraryComposer composer) { if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } if (scriptPackResolver == null) { throw new ArgumentNullException(nameof(scriptPackResolver)); } if (repl == null) { throw new ArgumentNullException(nameof(repl)); } if (logProvider == null) { throw new ArgumentNullException(nameof(logProvider)); } if (console == null) { throw new ArgumentNullException(nameof(console)); } if (assemblyResolver == null) { throw new ArgumentNullException(nameof(assemblyResolver)); } if (fileSystemMigrator == null) { throw new ArgumentNullException(nameof(fileSystemMigrator)); } if (composer == null) { throw new ArgumentNullException(nameof(composer)); } _scriptName = scriptName; _scriptArgs = scriptArgs; _fileSystem = fileSystem; _scriptPackResolver = scriptPackResolver; _repl = repl; _logger = logProvider.ForCurrentType(); _console = console; _assemblyResolver = assemblyResolver; _fileSystemMigrator = fileSystemMigrator; _composer = composer; }
public object Execute(IRepl repl, object[] args) { if (repl == null) { throw new ArgumentNullException(nameof(repl)); } repl.Reset(); return(null); }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); var namespaces = repl.Namespaces; if (repl.ScriptPackSession == null || repl.ScriptPackSession.Namespaces == null || !repl.ScriptPackSession.Namespaces.Any()) return namespaces; return namespaces.Union(repl.ScriptPackSession.Namespaces).OrderBy(x => x); }
public object Execute(IRepl repl, object[] args) { if (repl == null) { throw new ArgumentNullException(nameof(repl)); } var replEngine = repl.ScriptEngine as IReplEngine; return(replEngine?.GetLocalVariables(repl.ScriptPackSession)); }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); _console.WriteLine("The following commands are available in the REPL:"); foreach (var command in repl.Commands.Values.OrderBy(x => x.CommandName)) { _console.WriteLine(string.Format(":{0,-15}{1,10}", command.CommandName, command.Description)); } return null; }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); _console.WriteLine("The following commands are available in the REPL:"); foreach (var command in repl.Commands.Values.OrderBy(x => x.CommandName)) { _console.WriteLine(string.Format(":{0,-15}{1,10}", command.CommandName, command.Description)); } return(null); }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); var namespaces = repl.Namespaces; if (repl.ScriptPackSession == null || repl.ScriptPackSession.Namespaces == null || !repl.ScriptPackSession.Namespaces.Any()) { return(namespaces); } return(namespaces.Union(repl.ScriptPackSession.Namespaces).OrderBy(x => x)); }
public object Execute(IRepl repl, object[] args) { if (PlatformID != PlatformID.Win32NT) { _console.WriteLine("Requires Windows 8 or later to run"); return null; } var fs = repl.FileSystem; var launcher = _writer.WriteSolution(fs, (string) args[0], new VisualStudioSolution()); _console.WriteLine("Opening Visual Studio"); LaunchSolution(launcher); return null; }
public object Execute(IRepl repl, object[] args) { if (PlatformID != PlatformID.Win32NT) { _console.WriteLine("Requires Windows 8 or later to run"); return(null); } var fs = repl.FileSystem; var launcher = _writer.WriteSolution(fs, (string)args[0], new VisualStudioSolution()); _console.WriteLine("Opening Visual Studio"); LaunchSolution(launcher); return(null); }
public object Execute(IRepl repl, object[] args) { if (repl == null) { throw new ArgumentNullException(nameof(repl)); } _console.WriteLine("The following commands are available in the REPL:"); foreach (var command in repl.Commands.OrderBy(x => x.Key)) { _console.WriteLine(string.Format(":{0,-15}{1,10}", command.Key, command.Value.Description)); } return(null); }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); if (args == null || args.Length == 0) { return null; } var path = args[0].ToString(); repl.FileSystem.CurrentDirectory = Path.GetFullPath(Path.Combine(repl.FileSystem.CurrentDirectory, path)); return null; }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); if (args == null || args.Length == 0) { return(null); } var path = args[0].ToString(); repl.FileSystem.CurrentDirectory = Path.GetFullPath(Path.Combine(repl.FileSystem.CurrentDirectory, path)); return(null); }
public object Execute(IRepl repl, object[] args) { if (repl == null) { throw new ArgumentNullException(nameof(repl)); } var namespaces = repl.Namespaces; if (repl.ScriptPackSession == null || repl.ScriptPackSession.Namespaces == null || !repl.ScriptPackSession.Namespaces.Any()) { return(namespaces); } return(namespaces.Union(repl.ScriptPackSession.Namespaces).OrderBy(x => x)); }
public object Execute(IRepl repl, object[] args) { if (repl == null || args == null || args.Length == 0) { return null; } var gistId = args[0].ToString(); var files = _Downloader.DownloadGistFiles(gistId); foreach (var script in files.Select(File.ReadAllText)) { repl.Execute(script, null); } return null; }
public object Execute(IRepl repl, object[] args) { if (repl == null) { throw new ArgumentNullException(nameof(repl)); } if (args == null || args.Length == 0) { return(null); } var path = args[0].ToString(); repl.FileSystem.CurrentDirectory = Path.GetFullPath(Path.Combine(repl.FileSystem.CurrentDirectory, path)); return(null); }
public void Initialize(Type replType) { Contract.ThrowIfNull(replType); _repl = (IRepl)Activator.CreateInstance(replType); _objectFormatter = _repl.CreateObjectFormatter(); _hostObject = new InteractiveHostObject(); _options = _options .WithBaseDirectory(Environment.CurrentDirectory) .AddReferences(_hostObject.GetType().Assembly); _hostObject.ReferencePaths.AddRange(_options.SearchPaths); _hostObject.SourcePaths.AddRange(_sourceSearchPaths); Console.OutputEncoding = Encoding.UTF8; }
public void Initialize(Type replType) { Contract.ThrowIfNull(replType); _repl = (IRepl)Activator.CreateInstance(replType); _objectFormatter = _repl.CreateObjectFormatter(); _hostObject = new InteractiveHostObject(); _options = _options .WithBaseDirectory(Directory.GetCurrentDirectory()) .AddReferences(_hostObject.GetType().Assembly); _hostObject.ReferencePaths.AddRange(_options.SearchPaths); _hostObject.SourcePaths.AddRange(_sourceSearchPaths); Console.OutputEncoding = Encoding.UTF8; }
public object Execute(IRepl repl, object[] args) { var response = string.Empty; var responseIsValid = false; while (!responseIsValid) { _console.Write("Are you sure you wish to exit? (y/n): "); response = (_console.ReadLine() ?? string.Empty).ToLowerInvariant(); responseIsValid = response == "y" || response == "n"; } if (response == "y") { repl.Terminate(); } return(null); }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); var dir = repl.FileSystem.CurrentDirectory; var originalColor = _console.ForegroundColor; _console.ForegroundColor = ConsoleColor.Yellow; try { _console.WriteLine(dir); } finally { _console.ForegroundColor = originalColor; } return null; }
public object Execute(IRepl repl, object[] args) { var response = string.Empty; var responseIsValid = false; while (!responseIsValid) { _console.Write("Are you sure you wish to exit? (y/n): "); response = (_console.ReadLine() ?? string.Empty).ToLowerInvariant(); responseIsValid = response == "y" || response == "n"; } if (response == "y") { repl.Terminate(); } return null; }
public object Execute(IRepl repl, object[] args) { if (repl == null) { throw new ArgumentNullException(nameof(repl)); } if (args == null || args.Length != 2) { _console.WriteLine("You must specifiy the command name and alias, e.g. :alias \"clear\" \"cls\""); return(null); } var commandName = args[0].ToString(); var alias = args[1].ToString(); if (repl.Commands.Any(x => string.Equals(x.Key, alias, StringComparison.OrdinalIgnoreCase))) { var message = string.Format( CultureInfo.InvariantCulture, "\"{0}\" cannot be used as an alias since it is the name of an existing command.", alias); _console.WriteLine(message); return(null); } IReplCommand command; if (!repl.Commands.TryGetValue(commandName, out command)) { var message = string.Format( CultureInfo.InvariantCulture, "There is no command named or aliased \"{0}\".", alias); _console.WriteLine(message); return(null); } repl.Commands[alias] = command; _console.WriteLine(string.Format("Aliased \"{0}\" as \"{1}\".", commandName, alias)); return(null); }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); var dir = repl.FileSystem.CurrentDirectory; var originalColor = _console.ForegroundColor; _console.ForegroundColor = ConsoleColor.Yellow; try { _console.WriteLine(dir); } finally { _console.ForegroundColor = originalColor; } return(null); }
private static bool ExecuteLine(IRepl repl) { Console.Write(string.IsNullOrWhiteSpace(repl.Buffer) ? "> " : "* "); try { var line = Console.ReadLine(); if (!string.IsNullOrWhiteSpace(line)) { repl.Execute(line); } return true; } catch { return false; } }
public ReplExecutor( IRepl repl, IObjectSerializer serializer, IFileSystem fileSystem, IFilePreProcessor filePreProcessor, IScriptEngine scriptEngine, ILog logger, IEnumerable<IReplCommand> replCommands) : base(fileSystem, filePreProcessor, scriptEngine, logger) { this.repl = repl; this.serializer = serializer; this.replCommands = replCommands; replCompletion = new CSharpCompletion(true); replCompletion.AddReferences(GetReferencesAsPaths()); //since it's quite expensive to initialize the "System." references we clone the REPL code completion documentCompletion = replCompletion.Clone(); }
private bool ExecuteLine(IRepl repl) { _console.Write(string.IsNullOrWhiteSpace(repl.Buffer) ? "> " : "* "); try { var line = _console.ReadLine(); if (!string.IsNullOrWhiteSpace(line)) { repl.Execute(line); } return(true); } catch { return(false); } }
public ExecuteReplCommand( string scriptName, string[] scriptArgs, IFileSystem fileSystem, IScriptPackResolver scriptPackResolver, IRepl repl, ILog logger, IConsole console, IAssemblyResolver assemblyResolver) { Guard.AgainstNullArgument("repl", repl); _scriptName = scriptName; _scriptArgs = scriptArgs; _fileSystem = fileSystem; _scriptPackResolver = scriptPackResolver; _repl = repl; _logger = logger; _console = console; _assemblyResolver = assemblyResolver; }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); if (args == null || args.Length == 0) { return(null); } string version = null; if (args.Length >= 2) { version = args[1].ToString(); } var allowPre = args.Length >= 3 && args[2].ToString().ToUpperInvariant() == "PRE"; _logger.InfoFormat("Installing {0}", args[0]); _installationProvider.Initialize(); var packageRef = new PackageReference( args[0].ToString(), new FrameworkName(".NETFramework,Version=v4.0"), version); _packageInstaller.InstallPackages(new[] { packageRef }, allowPre); _packageAssemblyResolver.SavePackages(); var dlls = _packageAssemblyResolver.GetAssemblyNames(repl.FileSystem.CurrentDirectory) .Except(repl.References.Paths).ToArray(); repl.AddReferences(dlls); foreach (var dll in dlls) { _logger.InfoFormat("Added reference to {0}", dll); } return(null); }
public ReplExecutor( IRepl repl, IObjectSerializer serializer, IFileSystem fileSystem, IFilePreProcessor filePreProcessor, IScriptEngine scriptEngine, IPackageInstaller packageInstaller, IPackageAssemblyResolver resolver, ILog logger) : base(fileSystem, filePreProcessor, scriptEngine, logger) { this.repl = repl; this.serializer = serializer; this.packageInstaller = packageInstaller; this.resolver = resolver; replCompletion = new CSharpCompletion(true); replCompletion.AddReferences(GetReferencesAsPaths()); //since it's quite expensive to initialize the "System." references we clone the REPL code completion documentCompletion = replCompletion.Clone(); }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); if (args == null || args.Length != 2) { _console.WriteLine("You must specifiy the command name and alias, e.g. :alias \"clear\" \"cls\""); return null; } var commandName = args[0].ToString(); var alias = args[1].ToString(); if (repl.Commands.Any(x => string.Equals(x.Key, alias, StringComparison.InvariantCultureIgnoreCase))) { var message = string.Format( CultureInfo.InvariantCulture, "\"{0}\" cannot be used as an alias since it is the name of an existing command.", alias); _console.WriteLine(message); return null; } IReplCommand command; if (!repl.Commands.TryGetValue(commandName, out command)) { var message = string.Format( CultureInfo.InvariantCulture, "There is no command named or aliased \"{0}\".", alias); _console.WriteLine(message); return null; } repl.Commands[alias] = command; _console.WriteLine(string.Format("Aliased \"{0}\" as \"{1}\".", commandName, alias)); return null; }
public ScriptServices( IFileSystem fileSystem, IPackageAssemblyResolver packageAssemblyResolver, IScriptExecutor executor, IRepl repl, IScriptEngine engine, IFilePreProcessor filePreProcessor, IScriptPackResolver scriptPackResolver, IPackageInstaller packageInstaller, IObjectSerializer objectSerializer, ILogProvider logProvider, IAssemblyResolver assemblyResolver, IEnumerable <IReplCommand> replCommands, IFileSystemMigrator fileSystemMigrator, IConsole console = null, IInstallationProvider installationProvider = null, IScriptLibraryComposer scriptLibraryComposer = null ) { FileSystem = fileSystem; PackageAssemblyResolver = packageAssemblyResolver; Executor = executor; Repl = repl; Engine = engine; FilePreProcessor = filePreProcessor; ScriptPackResolver = scriptPackResolver; PackageInstaller = packageInstaller; ObjectSerializer = objectSerializer; LogProvider = logProvider; #pragma warning disable 618 Logger = new ScriptCsLogger(logProvider.ForCurrentType()); #pragma warning restore 618 Console = console; AssemblyResolver = assemblyResolver; InstallationProvider = installationProvider; ReplCommands = replCommands; FileSystemMigrator = fileSystemMigrator; ScriptLibraryComposer = scriptLibraryComposer; }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); if (args == null || args.Length == 0) { return null; } string version = null; if (args.Length >= 2) { version = args[1].ToString(); } var allowPre = args.Length >= 3 && args[2].ToString().ToUpperInvariant() == "PRE"; _logger.InfoFormat("Installing {0}", args[0]); _installationProvider.Initialize(); var packageRef = new PackageReference( args[0].ToString(), new FrameworkName(".NETFramework,Version=v4.0"), version); _packageInstaller.InstallPackages(new[] { packageRef }, allowPre); _packageAssemblyResolver.SavePackages(); var dlls = _packageAssemblyResolver.GetAssemblyNames(repl.FileSystem.CurrentDirectory) .Except(repl.References.Paths).ToArray(); repl.AddReferences(dlls); foreach (var dll in dlls) { _logger.InfoFormat("Added reference to {0}", dll); } return null; }
public ScriptServices( IFileSystem fileSystem, IPackageAssemblyResolver packageAssemblyResolver, IScriptExecutor executor, IRepl repl, IScriptEngine engine, IFilePreProcessor filePreProcessor, IScriptPackResolver scriptPackResolver, IPackageInstaller packageInstaller, IObjectSerializer objectSerializer, ILogProvider logProvider, IAssemblyResolver assemblyResolver, IEnumerable<IReplCommand> replCommands, IFileSystemMigrator fileSystemMigrator, IConsole console = null, IInstallationProvider installationProvider = null, IScriptLibraryComposer scriptLibraryComposer = null ) { FileSystem = fileSystem; PackageAssemblyResolver = packageAssemblyResolver; Executor = executor; Repl = repl; Engine = engine; FilePreProcessor = filePreProcessor; ScriptPackResolver = scriptPackResolver; PackageInstaller = packageInstaller; ObjectSerializer = objectSerializer; LogProvider = logProvider; #pragma warning disable 618 Logger = new ScriptCsLogger(logProvider.ForCurrentType()); #pragma warning restore 618 Console = console; AssemblyResolver = assemblyResolver; InstallationProvider = installationProvider; ReplCommands = replCommands; FileSystemMigrator = fileSystemMigrator; ScriptLibraryComposer = scriptLibraryComposer; }
public void Initialize(Type replType) { Contract.ThrowIfNull(replType); _repl = (IRepl)Activator.CreateInstance(replType); _objectFormatter = _repl.CreateObjectFormatter(); _hostObject = new InteractiveHostObject(); var options = ScriptOptions.Default .WithSearchPaths(DefaultReferenceSearchPaths) .WithBaseDirectory(Directory.GetCurrentDirectory()) .AddReferences(_hostObject.GetType().Assembly); _sourceSearchPaths = DefaultSourceSearchPaths; _hostObject.ReferencePaths.AddRange(options.SearchPaths); _hostObject.SourcePaths.AddRange(_sourceSearchPaths); _lastTask = Task.FromResult(new TaskResult(options, null)); Console.OutputEncoding = Encoding.UTF8; }
public ScriptServices( IFileSystem fileSystem, IPackageAssemblyResolver packageAssemblyResolver, IScriptExecutor executor, IRepl repl, IScriptEngine engine, IFilePreProcessor filePreProcessor, IScriptPackResolver scriptPackResolver, IPackageInstaller packageInstaller, IObjectSerializer objectSerializer, Common.Logging.ILog logger, IAssemblyResolver assemblyResolver, IEnumerable<IReplCommand> replCommands, IFileSystemMigrator fileSystemMigrator, IConsole console = null, IInstallationProvider installationProvider = null, IScriptLibraryComposer scriptLibraryComposer = null ) : this( fileSystem, packageAssemblyResolver, executor, repl, engine, filePreProcessor, scriptPackResolver, packageInstaller, objectSerializer, new CommonLoggingLogProvider(logger), assemblyResolver, replCommands, fileSystemMigrator, console, installationProvider, scriptLibraryComposer ) { }
public ScriptServices( IFileSystem fileSystem, IPackageAssemblyResolver packageAssemblyResolver, IScriptExecutor executor, IRepl repl, IScriptEngine engine, IFilePreProcessor filePreProcessor, IScriptPackResolver scriptPackResolver, IPackageInstaller packageInstaller, IObjectSerializer objectSerializer, Common.Logging.ILog logger, IAssemblyResolver assemblyResolver, IEnumerable <IReplCommand> replCommands, IFileSystemMigrator fileSystemMigrator, IConsole console = null, IInstallationProvider installationProvider = null, IScriptLibraryComposer scriptLibraryComposer = null ) : this( fileSystem, packageAssemblyResolver, executor, repl, engine, filePreProcessor, scriptPackResolver, packageInstaller, objectSerializer, new CommonLoggingLogProvider(logger), assemblyResolver, replCommands, fileSystemMigrator, console, installationProvider, scriptLibraryComposer ) { }
private bool ExecuteLine(IRepl repl) { var prompt = string.IsNullOrWhiteSpace (repl.Buffer) ? "> " : "* "; try { var line = _console.ReadLine(prompt); if (line == null) return false; if (!string.IsNullOrWhiteSpace(line)) { repl.Execute(line); } return true; } catch { return false; } }
public Workspace(IShell shell, IRepl repl, IReplExecutorFactory replExecutorFactory) { this.repl = repl; this.shell = shell; this.replExecutorFactory = replExecutorFactory; }
protected override void OnViewLoaded(object view) { replView = (IReplView) view; internalRepl = replView.GetRepl(); timer.Start(); base.OnViewLoaded(view); }
public object Execute(IRepl repl, object[] args) { Guard.AgainstNullArgument("repl", repl); return repl.Namespaces; }
public object Execute(IRepl repl, object[] args) { _console.Clear(); return null; }