本文整理汇总了C#中Host.Run方法的典型用法代码示例。如果您正苦于以下问题:C# Host.Run方法的具体用法?C# Host.Run怎么用?C# Host.Run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host.Run方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
Host host = new Host();
foreach (var file in Directory.GetFiles(".\\LINQPadQueries", "*.linq"))
{
host.Run<JsonTextSerializer>(file, Console.Out);
}
}
示例2: DoWork
public static void DoWork(
[Optional("config.json")] string configFile)
{
var configuration = JsonConfigurationParser.LoadConfiguration<AppReloadingConfigurationModel>(configFile);
var host = new Host<FileSystemEventArgs>(
new FileSystemWatcherEventProducer(configuration),
new AppReloadingEventConsumer(configuration));
host.Run();
StartCommandLoop();
}
示例3: Index
public ActionResult Index(LINQPadViewModel model, HttpPostedFileBase fileUpload)
{
Host host = new Host();
if (model.References == null)
{
model.References = string.Empty;
}
if (model.Namespaces == null)
{
model.Namespaces = string.Empty;
}
Query query;
if (fileUpload != null)
{
query = host.ParseLinqFile(new StreamReader(fileUpload.InputStream));
ModelState.Clear();
if (query.Reference != null)
model.References = string.Join(Environment.NewLine, query.Reference);
if (query.Namespace != null)
model.Namespaces = string.Join(Environment.NewLine, query.Namespace);
model.Kind = (KindEnum)Enum.Parse(typeof(KindEnum), query.Kind);
model.Code = query.Code;
}
else
{
query = new Query
{
Kind = model.Kind.ToString(),
Reference = model.References.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries),
Namespace = model.Namespaces.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries),
Code = model.Code
};
}
CompilerResults cr = host.CompileLinqQuery(query);
if (cr.Errors != null && cr.Errors.Count > 0)
{
foreach(CompilerError ce in cr.Errors)
{
model.Results += ce + "\r\n";
}
}
else
{
StringWriter sw = new StringWriter();
host.Run<IndentTextSerializer>(cr, sw);
model.Results = sw.ToString();
}
return View(model);
}
示例4: WithDependencies
public void WithDependencies()
{
Host host = new Host(_initializationStrategyFactory);
var config = new FakeConfig(host);
var dependency1 = new FakeDependency("Some Service");
var dependency2 = new FakeDependency("Some Other Service");
config.Dependencies = new List<Dependency>
{
dependency1,
dependency2,
};
CreatesInitializationStrategy();
InitializesTheHost(config);
host.Run(config);
Assert.IsTrue(dependency1.Started);
Assert.IsTrue(dependency2.Started);
}
示例5: WithMultiTenantContainerBuilderAction
public void WithMultiTenantContainerBuilderAction()
{
Host host = new Host(_initializationStrategyFactory);
var config = new FakeConfig(host);
config.WithRegistrations(b => b.Register(c => new Thing()))
.WithMultiTenantContainer((c) => new MultitenantContainer(new DummyTenantIdentificationStrategy(), c));
ContainerProvider.Instance.ApplicationContainer = config.Compile();
CreatesInitializationStrategy();
InitializesTheHost(config);
host.Run(config);
Assert.IsTrue(ContainerProvider.Instance.ApplicationContainer.IsRegistered(typeof(Thing)));
Assert.IsTrue(ContainerProvider.Instance.ApplicationContainer is MultitenantContainer);
}
示例6: WithInstallModeSet
public void WithInstallModeSet()
{
Host host = new Host(_initializationStrategyFactory);
var config = new FakeConfig(host);
config.InstallMode = InstallMode.Uninstall;
CreatesInitializationStrategy();
InitializesTheHost(config);
host.Run(config);
}
示例7: WithRegistrations
public void WithRegistrations()
{
Host host = new Host(_initializationStrategyFactory);
var config = new FakeConfig(host);
config.WithRegistrations(b => b.Register(c => new Thing()));
ContainerProvider.Instance.ApplicationContainer = config.Compile();
CreatesInitializationStrategy();
InitializesTheHost(config);
host.Run(config);
Assert.IsTrue(ContainerProvider.Instance.ApplicationContainer.IsRegistered(typeof(Thing)));
}
示例8: WithNoDependencies
public void WithNoDependencies()
{
Host host = new Host(_initializationStrategyFactory);
var config = new FakeConfig(host);
CreatesInitializationStrategy();
InitializesTheHost(config);
host.Run(config);
}