当前位置: 首页>>代码示例>>C#>>正文


C# Repl.Initialize方法代码示例

本文整理汇总了C#中Repl.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Repl.Initialize方法的具体用法?C# Repl.Initialize怎么用?C# Repl.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Repl的用法示例。


在下文中一共展示了Repl.Initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public CommandResult Execute()
        {
            _console.WriteLine("scriptcs (ctrl-c to exit)" + Environment.NewLine);
            var repl = new Repl(_scriptArgs, _fileSystem, _scriptEngine, _serializer, _logger, _console, _filePreProcessor, _replCommands);

            var workingDirectory = _fileSystem.CurrentDirectory;
            var assemblies = _assemblyResolver.GetAssemblyPaths(workingDirectory);
            var scriptPacks = _scriptPackResolver.GetPacks();

            repl.Initialize(assemblies, scriptPacks, ScriptArgs);

            try
            {
                if (!string.IsNullOrWhiteSpace(_scriptName))
                {
                    _logger.Info(string.Format("Loading script: {0}", _scriptName));
                    repl.Execute(string.Format("#load {0}", _scriptName));
                }

                while (ExecuteLine(repl))
                {
                }

                _console.WriteLine();
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return CommandResult.Error;
            }

            repl.Terminate();
            return CommandResult.Success;
        }
开发者ID:selony,项目名称:scriptcs,代码行数:34,代码来源:ExecuteReplCommand.cs

示例2: Execute

 public CommandResult Execute()
 {
     _console.WriteLine("scriptcs (ctrl-c or blank to exit)\r\n");
     var repl = new Repl(_fileSystem, _scriptEngine, _logger, _console, _filePreProcessor);
     repl.Initialize(GetAssemblyPaths(_fileSystem.CurrentDirectory), _scriptPackResolver.GetPacks());
     try
     {
         while (ExecuteLine(repl))
         {
         }
     }
     catch (Exception ex)
     {
         _logger.Error(ex.Message);
         return CommandResult.Error;
     }
     repl.Terminate();
     return CommandResult.Success;
 }
开发者ID:7sharp9,项目名称:scriptcs,代码行数:19,代码来源:ExecuteReplCommand.cs

示例3: ShouldSetBufferIFLineIsFirstOfMultilineConstruct

            public void ShouldSetBufferIFLineIsFirstOfMultilineConstruct()
            {
                var mocks = new Mocks();
                mocks.ScriptEngine.Setup(
                    x =>
                    x.Execute(It.IsAny<string>(), It.IsAny<string[]>(), It.IsAny<AssemblyReferences>(),
                              It.IsAny<IEnumerable<string>>(), It.IsAny<ScriptPackSession>()))
                     .Returns<ScriptResult>(x => new ScriptResult()
                     {
                         ExpectingClosingChar = ')',
                         IsPendingClosingChar = true
                     });
                mocks.FilePreProcessor.Setup(x => x.ProcessScript(It.IsAny<string>()))
                    .Returns(new FilePreProcessorResult { Code = "var x = 1;" });
                mocks.FileSystem.Setup(i => i.CurrentDirectory).Returns("C:/");
                _repl = GetRepl(mocks);
                _repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>());
                _repl.Execute("var x = 1;");

                _repl.Buffer.ShouldNotBeNull();
            }
开发者ID:Jaydeep7,项目名称:scriptcs,代码行数:21,代码来源:ReplTests.cs

示例4: ShouldResubmitEverytingIfLineIsNoLongerMultilineConstruct

            public void ShouldResubmitEverytingIfLineIsNoLongerMultilineConstruct()
            {
                var mocks = new Mocks();
                mocks.ScriptEngine.Setup(
                    x =>
                    x.Execute(It.Is<string>(i => i == "class test {}"), It.IsAny<string[]>(), It.IsAny<AssemblyReferences>(),
                              It.IsAny<IEnumerable<string>>(), It.IsAny<ScriptPackSession>()))
                     .Returns(new ScriptResult
                     {
                         IsPendingClosingChar = false
                     });
                mocks.FileSystem.Setup(i => i.CurrentDirectory).Returns("C:/");
                _repl = GetRepl(mocks);
                _repl.Buffer = "class test {";
                _repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>());
                _repl.Execute("}");

                mocks.ScriptEngine.Verify();
            }
开发者ID:Jaydeep7,项目名称:scriptcs,代码行数:19,代码来源:ReplTests.cs

示例5: ShouldRemoveReferenceIfAssemblyIsNotFound

            public void ShouldRemoveReferenceIfAssemblyIsNotFound()
            {
                var mocks = new Mocks();
                mocks.FileSystem.Setup(i => i.CurrentDirectory).Returns("C:/");
                mocks.FileSystem.Setup(i => i.GetFullPath(It.IsAny<string>())).Returns(@"C:/my.dll");
                mocks.FileSystem.Setup(i => i.FileExists(It.IsAny<string>())).Returns(false);
                mocks.FilePreProcessor.Setup(x => x.ProcessScript(It.IsAny<string>()))
                    .Returns(new FilePreProcessorResult { References = new List<string> { "my.dll" } });
                mocks.ScriptEngine.Setup(
                    i =>
                    i.Execute(It.IsAny<string>(), It.IsAny<string[]>(), It.IsAny<AssemblyReferences>(),
                              It.IsAny<IEnumerable<string>>(), It.IsAny<ScriptPackSession>()))
                     .Throws(new FileNotFoundException("error", "my.dll"));

                _repl = GetRepl(mocks);
                _repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>());
                _repl.Execute("#r \"my.dll\"");
                _repl.References.PathReferences.Contains("my.dll").ShouldBeFalse();
            }
开发者ID:Jaydeep7,项目名称:scriptcs,代码行数:19,代码来源:ReplTests.cs

示例6: ShouldReferenceAssemblyIfLineIsAReference

            public void ShouldReferenceAssemblyIfLineIsAReference()
            {
                var mocks = new Mocks();
                mocks.FileSystem.Setup(i => i.CurrentDirectory).Returns("C:/");
                mocks.FileSystem.Setup(i => i.GetFullPath(It.IsAny<string>())).Returns(@"c:/my.dll");
                mocks.FileSystem.Setup(x => x.FileExists("c:/my.dll")).Returns(true);
                mocks.FilePreProcessor.Setup(x => x.ProcessScript(It.IsAny<string>()))
                    .Returns(new FilePreProcessorResult { References = new List<string> { "my.dll" } });

                _repl = GetRepl(mocks);
                _repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>());
                _repl.Execute("#r \"my.dll\"");

                //default references = 6, + 1 we just added
                _repl.References.PathReferences.Count().ShouldEqual(7);
            }
开发者ID:Jaydeep7,项目名称:scriptcs,代码行数:16,代码来源:ReplTests.cs

示例7: ShouldReferenceAssemblyBasedOnNameWithExtensionIfFileDoesNotExistBecauseItLooksInGACThen

            public void ShouldReferenceAssemblyBasedOnNameWithExtensionIfFileDoesNotExistBecauseItLooksInGACThen()
            {
                var mocks = new Mocks();
                mocks.FileSystem.Setup(i => i.CurrentDirectory).Returns("C:/");
                mocks.FileSystem.Setup(i => i.GetFullPath(It.IsAny<string>())).Returns(@"C:/my.dll");
                mocks.FileSystem.Setup(i => i.FileExists(It.IsAny<string>())).Returns(false);
                mocks.FilePreProcessor.Setup(x => x.ProcessScript(It.IsAny<string>()))
                    .Returns(new FilePreProcessorResult { References = new List<string> { "my.dll" } });

                _repl = GetRepl(mocks);
                _repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>());
                _repl.Execute("#r \"my.dll\"");

                _repl.References.PathReferences.Contains("my.dll").ShouldBeTrue();
            }
开发者ID:Jaydeep7,项目名称:scriptcs,代码行数:15,代码来源:ReplTests.cs

示例8: ShouldReferenceAssemblyBasedOnFullPathIfFileExists

            public void ShouldReferenceAssemblyBasedOnFullPathIfFileExists()
            {
                var mocks = new Mocks();
                mocks.FileSystem.Setup(i => i.CurrentDirectory).Returns("C:/");
                mocks.FileSystem.Setup(i => i.GetFullPath(It.IsAny<string>())).Returns(@"C:/my.dll");
                mocks.FilePreProcessor.Setup(x => x.ProcessScript(It.IsAny<string>()))
                    .Returns(new FilePreProcessorResult { References = new List<string> { "my.dll" } });

                _repl = GetRepl(mocks);
                _repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>());
                _repl.Execute("#r \"my.dll\"");

                mocks.FileSystem.Verify(x => x.FileExists("C:/my.dll"), Times.Once());
            }
开发者ID:Jaydeep7,项目名称:scriptcs,代码行数:14,代码来源:ReplTests.cs

示例9: ShouldReferenceAssemblyBasedOnNameIfFileDoesNotExistBecauseItLooksInGACThen

            public void ShouldReferenceAssemblyBasedOnNameIfFileDoesNotExistBecauseItLooksInGACThen()
            {
                var mocks = new Mocks();
                mocks.FileSystem.Setup(i => i.CurrentDirectory).Returns("C:/");
                mocks.FileSystem.Setup(i => i.FileExists(It.IsAny<string>())).Returns(false);

                _repl = GetRepl(mocks);
                _repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>());
                _repl.Execute("#r \"PresentationCore\"");

                _repl.References.Contains("PresentationCore").ShouldBeTrue();
            }
开发者ID:7sharp9,项目名称:scriptcs,代码行数:12,代码来源:ReplTests.cs

示例10: TheInitializeMethod

            public TheInitializeMethod()
            {
                _tempPath = Path.GetTempPath();

                _mocks = new Mocks();
                _repl = GetRepl(_mocks);
                _mocks.FileSystem.Setup(x => x.CurrentDirectory).Returns(_tempPath);
                var paths = new[] { Path.Combine(_tempPath, "path") };
                _repl.Initialize(paths, new[] { _mocks.ScriptPack.Object });
            }
开发者ID:AsCloud,项目名称:scriptcs,代码行数:10,代码来源:ReplTests.cs

示例11: ShouldResetBufferIfLineIsNoLongerMultilineConstruct

            public void ShouldResetBufferIfLineIsNoLongerMultilineConstruct()
            {
                var mocks = new Mocks();
                mocks.ScriptEngine.Setup(
                    x =>
                    x.Execute(It.IsAny<string>(), It.IsAny<string[]>(), It.IsAny<AssemblyReferences>(),
                              It.IsAny<IEnumerable<string>>(), It.IsAny<ScriptPackSession>()))
                     .Returns(ScriptResult.Empty);
                mocks.FilePreProcessor.Setup(x => x.ProcessScript(It.IsAny<string>()))
                    .Returns(new FilePreProcessorResult { Code = "}" });
                mocks.FileSystem.Setup(i => i.CurrentDirectory).Returns("C:/");
                _repl = GetRepl(mocks);
                _repl.Buffer = "class test {";
                _repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>());
                _repl.Execute("}");

                _repl.Buffer.ShouldBeNull();
            }
开发者ID:AsCloud,项目名称:scriptcs,代码行数:18,代码来源:ReplTests.cs

示例12: ShouldExecuteLoadedFileIfLineIsALoad

            public void ShouldExecuteLoadedFileIfLineIsALoad()
            {
                var mocks = new Mocks();
                mocks.FilePreProcessor.Setup(x => x.ProcessScript(It.IsAny<string>()))
                     .Returns(new FilePreProcessorResult());
                mocks.FileSystem.Setup(x => x.FileExists("file.csx")).Returns(true);
                _repl = GetRepl(mocks);
                _repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>(), "");
                _repl.Execute("#load \"file.csx\"");

                mocks.ScriptEngine.Verify(
                    i => i.Execute(
                        It.IsAny<string>(),
                        It.IsAny<string[]>(),
                        It.IsAny<AssemblyReferences>(),
                        It.IsAny<IEnumerable<string>>(),
                        It.IsAny<ScriptPackSession>()),
                    Times.Once());
            }
开发者ID:AsCloud,项目名称:scriptcs,代码行数:19,代码来源:ReplTests.cs

示例13: TheExecuteMethod

 public TheExecuteMethod()
 {
     _mocks = new Mocks();
     _mocks.FilePreProcessor.Setup(x => x.ProcessScript("foo"))
         .Returns(new FilePreProcessorResult { Code = "foo" });
     _repl = GetRepl(_mocks);
     _repl.Console.ForegroundColor = ConsoleColor.White;
     _repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>(), String.Empty);
     _repl.Execute("foo");
 }
开发者ID:AsCloud,项目名称:scriptcs,代码行数:10,代码来源:ReplTests.cs

示例14: TheInitializeMethod

 public TheInitializeMethod()
 {
     _mocks = new Mocks();
     _repl = GetRepl(_mocks);
     _mocks.FileSystem.Setup(x => x.CurrentDirectory).Returns(@"c:\");
     var paths = new[] { @"c:\path" };
     _repl.Initialize(paths, new[] { _mocks.ScriptPack.Object });
 }
开发者ID:Jaydeep7,项目名称:scriptcs,代码行数:8,代码来源:ReplTests.cs

示例15: ShouldNotExecuteAnythingIfLineIsAReference

            public void ShouldNotExecuteAnythingIfLineIsAReference()
            {
                var mocks = new Mocks();
                mocks.FileSystem.Setup(i => i.CurrentDirectory).Returns("C:/");
                _repl = GetRepl(mocks);
                _repl.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>());
                _repl.Execute("#r \"my.dll\"");

                mocks.ScriptEngine.Verify(i => i.Execute(It.IsAny<string>(), It.IsAny<string[]>(), It.IsAny<AssemblyReferences>(), It.IsAny<IEnumerable<string>>(), It.IsAny<ScriptPackSession>()), Times.Never());
            }
开发者ID:Jaydeep7,项目名称:scriptcs,代码行数:10,代码来源:ReplTests.cs


注:本文中的Repl.Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。