public ConsoleHostOptionsParser(ConsoleHostOptions options, ScriptRuntimeSetup runtimeSetup) { ContractUtils.RequiresNotNull(options, "options"); ContractUtils.RequiresNotNull(runtimeSetup, "runtimeSetup"); _options = options; _runtimeSetup = runtimeSetup; }
public ConsoleHostOptionsParser(ConsoleHostOptions options, ScriptRuntimeSetup runtimeSetup) { ContractUtils.RequiresNotNull(options, nameof(options)); ContractUtils.RequiresNotNull(runtimeSetup, nameof(runtimeSetup)); Options = options; RuntimeSetup = runtimeSetup; }
public virtual int Run(string[] args) { var runtimeSetup = CreateRuntimeSetup(); var options = new ConsoleHostOptions(); _optionsParser = new ConsoleHostOptionsParser(options, runtimeSetup); try { ParseHostOptions(args); } catch (InvalidOptionException e) { Console.Error.WriteLine("Invalid argument: " + e.Message); return(_exitCode = 1); } SetEnvironment(); string provider = GetLanguageProvider(runtimeSetup); LanguageSetup languageSetup = null; foreach (var language in runtimeSetup.LanguageSetups) { if (language.TypeName == provider) { languageSetup = language; } } if (languageSetup == null) { // the language doesn't have a setup -> create a default one: languageSetup = new LanguageSetup(Provider.AssemblyQualifiedName, Provider.Name); runtimeSetup.LanguageSetups.Add(languageSetup); } // inserts search paths for all languages (/paths option): InsertSearchPaths(runtimeSetup.Options, Options.SourceUnitSearchPaths); _languageOptionsParser = CreateOptionsParser(); try { _languageOptionsParser.Parse(Options.IgnoredArgs.ToArray(), runtimeSetup, languageSetup, PlatformAdaptationLayer); } catch (InvalidOptionException e) { Console.Error.WriteLine(e.Message); return(_exitCode = -1); } _runtime = new ScriptRuntime(runtimeSetup); try { _engine = _runtime.GetEngineByTypeName(provider); } catch (Exception e) { Console.Error.WriteLine(e.Message); return(_exitCode = 1); } Execute(); return(_exitCode); }
public PythonObject(string[] args) { ScriptRuntimeSetup runtimeSetup = ScriptRuntimeSetup.ReadConfiguration(); ConsoleHostOptions options = new ConsoleHostOptions(); _optionsParser = new ConsoleHostOptionsParser(options, runtimeSetup); string provider = GetLanguageProvider(runtimeSetup); LanguageSetup languageSetup = null; foreach (LanguageSetup language in runtimeSetup.LanguageSetups) { if (language.TypeName == provider) { languageSetup = language; } } if (languageSetup == null) { // the language doesn't have a setup -> create a default one: languageSetup = new LanguageSetup(Provider.AssemblyQualifiedName, Provider.Name); runtimeSetup.LanguageSetups.Add(languageSetup); } // inserts search paths for all languages (/paths option): InsertSearchPaths(runtimeSetup.Options, Options.SourceUnitSearchPaths); _languageOptionsParser = new OptionsParser<ConsoleOptions>(); try { _languageOptionsParser.Parse(Options.IgnoredArgs.ToArray(), runtimeSetup, languageSetup, PlatformAdaptationLayer.Default); } catch (InvalidOptionException e) { Console.Error.WriteLine(e.Message); } _runtime = new ScriptRuntime(runtimeSetup); try { _engine = _runtime.GetEngineByTypeName(provider); } catch (Exception e) { Console.Error.WriteLine(e.Message); } _runtime.LoadAssembly(System.Reflection.Assembly.GetExecutingAssembly()); _runtime.LoadAssembly(provider.GetType().Assembly); _runtime.LoadAssembly(PythonStringIO.StringIO().GetType().Assembly); _scope= _engine.CreateScope(); RunCommandLine(args); }
public virtual int Run(string[] args) { var runtimeSetup = CreateRuntimeSetup(); var options = new ConsoleHostOptions(); _optionsParser = new ConsoleHostOptionsParser(options, runtimeSetup); try { ParseHostOptions(args); } catch (InvalidOptionException e) { Console.Error.WriteLine("Invalid argument: " + e.Message); return _exitCode = 1; } SetEnvironment(); string provider = GetLanguageProvider(runtimeSetup); LanguageSetup languageSetup = null; foreach (var language in runtimeSetup.LanguageSetups) { if (language.TypeName == provider) { languageSetup = language; } } if (languageSetup == null) { // the language doesn't have a setup -> create a default one: languageSetup = new LanguageSetup(Provider.AssemblyQualifiedName, Provider.Name); runtimeSetup.LanguageSetups.Add(languageSetup); } // inserts search paths for all languages (/paths option): InsertSearchPaths(runtimeSetup.Options, Options.SourceUnitSearchPaths); _consoleOptions = ParseOptions(Options.IgnoredArgs.ToArray(), runtimeSetup, languageSetup); if (_consoleOptions == null) { return _exitCode = 1; } _runtime = new ScriptRuntime(runtimeSetup); try { _engine = _runtime.GetEngineByTypeName(provider); } catch (Exception e) { Console.Error.WriteLine(e.Message); return _exitCode = 1; } Execute(); return _exitCode; }
public virtual int Run(string[] args) { var runtimeSetup = CreateRuntimeSetup(); var options = new ConsoleHostOptions(); _optionsParser = new ConsoleHostOptionsParser(options, runtimeSetup); try { ParseHostOptions(args); } catch (InvalidOptionException e) { Console.Error.WriteLine("Invalid argument: " + e.Message); return _exitCode = 1; } SetEnvironment(); string provider = GetLanguageProvider(runtimeSetup); LanguageSetup languageSetup = null; foreach (var language in runtimeSetup.LanguageSetups) { if (language.TypeName == provider) { languageSetup = language; } } if (languageSetup == null) { // the language doesn't have a setup -> create a default one: languageSetup = new LanguageSetup(Provider.AssemblyQualifiedName, Provider.Name); runtimeSetup.LanguageSetups.Add(languageSetup); } // inserts search paths for all languages (/paths option): InsertSearchPaths(runtimeSetup.Options, Options.SourceUnitSearchPaths); _languageOptionsParser = CreateOptionsParser(); try { _languageOptionsParser.Parse(Options.IgnoredArgs.ToArray(), runtimeSetup, languageSetup, PlatformAdaptationLayer); } catch (InvalidOptionException e) { Console.Error.WriteLine(e.Message); return _exitCode = -1; } #if !SILVERLIGHT if (typeof(DynamicMethod).GetConstructor(new Type[] { typeof(string), typeof(Type), typeof(Type[]), typeof(bool) }) == null) { Console.WriteLine(string.Format("{0} requires .NET 2.0 SP1 or later to run.", languageSetup.DisplayName)); Environment.Exit(1); } #endif _runtime = new ScriptRuntime(runtimeSetup); try { _engine = _runtime.GetEngineByTypeName(provider); } catch (Exception e) { Console.Error.WriteLine(e.Message); return _exitCode = 1; } Execute(); return _exitCode; }
public virtual int Run(string[] args) { var runtimeSetup = CreateRuntimeSetup(); var options = new ConsoleHostOptions(); _optionsParser = new ConsoleHostOptionsParser(options, runtimeSetup); try { ParseHostOptions(args); } catch (InvalidOptionException e) { Console.Error.WriteLine("Invalid argument: " + e.Message); return(_exitCode = 1); } SetEnvironment(); string provider = GetLanguageProvider(runtimeSetup); LanguageSetup languageSetup = null; foreach (var language in runtimeSetup.LanguageSetups) { if (language.TypeName == provider) { languageSetup = language; } } if (languageSetup == null) { // the language doesn't have a setup -> create a default one: languageSetup = new LanguageSetup(Provider.AssemblyQualifiedName, Provider.Name); runtimeSetup.LanguageSetups.Add(languageSetup); } // inserts search paths for all languages (/paths option): InsertSearchPaths(runtimeSetup.Options, Options.SourceUnitSearchPaths); _languageOptionsParser = CreateOptionsParser(); try { _languageOptionsParser.Parse(Options.IgnoredArgs.ToArray(), runtimeSetup, languageSetup, PlatformAdaptationLayer); } catch (InvalidOptionException e) { Console.Error.WriteLine(e.Message); return(_exitCode = -1); } #if !SILVERLIGHT if (typeof(DynamicMethod).GetConstructor(new Type[] { typeof(string), typeof(Type), typeof(Type[]), typeof(bool) }) == null) { Console.WriteLine(string.Format("{0} requires .NET 2.0 SP1 or later to run.", languageSetup.DisplayName)); Environment.Exit(1); } #endif _runtime = new ScriptRuntime(runtimeSetup); try { _engine = _runtime.GetEngineByTypeName(provider); } catch (Exception e) { Console.Error.WriteLine(e.Message); return(_exitCode = 1); } Execute(); return(_exitCode); }