本文整理汇总了C#中System.IocContainer.RegisterFromAssemblyOf方法的典型用法代码示例。如果您正苦于以下问题:C# IocContainer.RegisterFromAssemblyOf方法的具体用法?C# IocContainer.RegisterFromAssemblyOf怎么用?C# IocContainer.RegisterFromAssemblyOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IocContainer
的用法示例。
在下文中一共展示了IocContainer.RegisterFromAssemblyOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var container = new IocContainer();
container.RegisterFromAssemblyOf<Program>();
Configure.Messaging()
.LoggingWith(new ConsoleLoggingMechanism { ShowDebug = false })
.ResolveReferencesWith(container)
.RegisterHandlersFromContainer().BasedOn<IMessageHandler>()
.UsingHttpTransport()
.AsAServer("OtherSenderServer")
.AuthenticateToServer("ReceiverServer")
.WithRequest<AuthenticationRequest>()
.OnExpiry(s => Console.WriteLine("Session expired: {0}", s))
.OpenChannel("OtherTestRequest")
.ForRequestReplySendingTo("[email protected]")
.WithDurability()
.Initialise();
Console.WriteLine("I am the sender. Whats the password? (its 'Hello')");
string password = Console.ReadLine();
Bus.SendDirect(new AuthenticationRequest { Password = password }, new AuthenticationHandler(), exception => { });
do
{
Console.WriteLine("I am the sender. Press enter to send messages..");
Console.ReadLine();
Console.WriteLine("Sending messages");
Bus.Send(new TestMessage("Hello"));
} while (true);
}
示例2: OnLaunched
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used when the application is launched to open a specific file, to display
/// search results, and so forth.
/// </summary>
/// <param server="args">Details about the launch request and process.</param>
protected async override void OnLaunched(LaunchActivatedEventArgs args)
{
var container = new IocContainer();
container.RegisterInstance(() => new ObservableLoggingMechanism(new MainThreadDispatcher()) { ShowInfo = true, ShowDebug = true });
container.RegisterFromAssemblyOf<ResponseHandler>();
Configure.Messaging()
.LoggingWith(container.Resolve<ObservableLoggingMechanism>())
.ResolveReferencesWith(container)
.RegisterHandlersFromContainer().BasedOn<IMessageConsumer>()
.UsingFilePersistence()
.UsingHttpTransport()
.AsAServerUsingAProxy("SenderServer")
.OpenChannel("TestMetroRequest")
.ForRequestReplySendingTo("[email protected]")
.HandleRepliesOnMainThread()
.WithDurability()
.Sequenced()
.Initialise();
ViewModelLocator.SetContainer(container);
// Do not repeat app initialization when already running, just ensure that
// the window is active
if (args.PreviousExecutionState == ApplicationExecutionState.Running)
{
Window.Current.Activate();
return;
}
if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Create a Frame to act navigation context and navigate to the first page
var rootFrame = new Frame();
if (!rootFrame.Navigate(typeof(MainPage)))
{
throw new Exception("Failed to create initial page");
}
// Place the frame in the current Window and ensure that it is active
Window.Current.Content = rootFrame;
Window.Current.Activate();
}
示例3: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var container = new IocContainer();
container.RegisterFromAssemblyOf<Activity1>();
MainActivityLocator.Set(this);
Configure.Messaging()
.LoggingWith(new ConsoleLoggingMechanism { ShowInfo = true, ShowDebug = false })
.UsingSqlitePersistence()
.ResolveReferencesWith(container)
.UsingHttpTransport()
.AsAServerUsingAProxy("SenderServer")
.OpenChannel("TestAndroidRequest")
.ForRequestReplySendingTo("[email protected]")
.HandleRepliesOnMainThread()
.WithDurability()
.Initialise();
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += delegate
{
for (int i = 0; i < 20; i++)
{
Bus.Send(new TestMessage { Text = string.Format("Message {0}", count) });
button.Text = string.Format("{0} messages sent!", count++);
}
};
}
示例4: AutoRegistrations
static void AutoRegistrations(IocContainer ioc)
{
ioc.RegisterFromAssemblyOf<App>();
}