本文整理汇总了C#中Host.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Host.Start方法的具体用法?C# Host.Start怎么用?C# Host.Start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host.Start方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: should_call_initializer_methods_in_right_order
public void should_call_initializer_methods_in_right_order()
{
var counter = new Counter();
var bus = new TestBus();
bus.Starting += () => counter.Increment();
bus.Started += () => counter.Increment();
bus.Stopping += () => counter.Increment();
bus.Stopped += () => counter.Increment();
var testHostInitializer = new TestHostInitializer(counter);
var host = new Host();
var container = host.ContainerFactory.Invoke();
host.ContainerFactory = () =>
{
container.Configure(x =>
{
x.ForSingletonOf<IBus>().Use(bus);
x.ForSingletonOf<HostInitializer>().Add(testHostInitializer);
});
return container;
};
host.Start();
host.Stop();
testHostInitializer.CapturedContainer.ShouldEqual(container);
testHostInitializer.ConfigureContainerCounterValue.ShouldEqual(0);
testHostInitializer.BeforeStartCounterValue.ShouldEqual(0);
testHostInitializer.AfterStartCounterValue.ShouldEqual(2);
testHostInitializer.BeforeStopCounterValue.ShouldEqual(2);
testHostInitializer.AfterStopCounterValue.ShouldEqual(4);
}
示例2: Main
static void Main()
{
CSScript.GlobalSettings = new Settings(); //create default settings instance instead of using the one initialized from CS-Script installation (if present)
Host host = new Host();
host.Start();
}
示例3: When
protected override void When()
{
FakeMessageChannel.Reset();
LogManager.Configure(new TraceLoggerFactory(), LogLevel.All);
var objectFactory = ObjectFactoryResolver.GetObjectFactory();
objectFactory.Register<ISubscriptionStorage, InMemorySubscriptionStorage>(LifeCycle.Unique);
var hostConfig = new HostConfig();
var host = new Host(hostConfig);
host.Start();
}
示例4: CrashOnRunTest
public void CrashOnRunTest()
{
using (Host test = new Host())
{
PayloadDescription desc = new PayloadDescription();
string assembly = typeof(TestService.TestService).Assembly.CodeBase;
desc.AssemblyFullName = assembly;
desc.Class = typeof(TestService.TestService).FullName;
desc.Parameter = "AsyncRaiseOnRun";
Assert.IsTrue(test.Initialize(desc), "Initialize must succeed");
using (TestTracer tracer = TestTracer.FromDomain(test.Domain))
{
test.Start();
Thread.Sleep(500);
Assert.AreEqual("StartWithParam", tracer.Pop(), "TestMethod.Start should have been called");
Assert.AreEqual("Default", tracer.Pop(), "Bad test parameter");
Assert.AreEqual("RaisedException", tracer.Pop(), "Should have raised an exception");
test.Stop();
Assert.AreEqual("Stop", tracer.Pop(), "Should have raised an exception");
Assert.IsTrue(tracer.IsEmpty, "No other events should have occured");
}
}
}
示例5: AlternateTest
public void AlternateTest()
{
using (Host test = new Host())
{
PayloadDescription desc = new PayloadDescription();
string assembly = typeof(TestService.TestService).Assembly.CodeBase;
desc.AssemblyFullName = assembly;
desc.Class = typeof(TestService.TestService).FullName;
desc.ConfigurationFile = "AltShon.TestService.config";
Assert.IsTrue(test.Initialize(desc), "Initialize must succeed");
using (TestTracer tracer = TestTracer.FromDomain(test.Domain))
{
test.Start();
Assert.AreEqual("Start", tracer.Pop(), "TestMethod.Start should have been called");
Assert.AreEqual("Alt", tracer.Pop(), "Bad test parameter");
test.Stop();
Assert.AreEqual("Stop", tracer.Pop(), "TestMethod.Stop should have been called");
Assert.IsTrue(tracer.IsEmpty, "No other events should have occured");
}
}
}
示例6: Main
static void Main()
{
Host host = new Host();
host.Start();
}
示例7: Start
public static void Start()
{
host = new HostFactory().Build();
host.Start();
}
示例8: RunAsConsole
private static void RunAsConsole()
{
string title = string.Format(CultureInfo.CurrentCulture, "StealFocus Forecast Console. Version {0}", typeof(Program).Assembly.GetName().Version);
OutputVersionAndCopyrightMessage(title);
Host host = new Host();
host.Start();
// Write with the console (and not via the logger) to guarantee this message
// is displayed to the user (in case the logger is misconfigured).
System.Console.WriteLine("Press return to stop the workers.");
System.Console.ReadLine();
host.Stop();
host.WaitForWorkersToStop();
}