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


C# IocContainer.RegisterFromAssemblyOf方法代码示例

本文整理汇总了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);
        }
开发者ID:SystemDot,项目名称:SystemDotServiceBus,代码行数:35,代码来源:Program.cs

示例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();
        }
开发者ID:SystemDot,项目名称:SystemDotServiceBus,代码行数:53,代码来源:App.xaml.cs

示例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++);
                }
            };
        }
开发者ID:SystemDot,项目名称:SystemDotServiceBus,代码行数:37,代码来源:Activity1.cs

示例4: AutoRegistrations

 static void AutoRegistrations(IocContainer ioc)
 {
     ioc.RegisterFromAssemblyOf<App>();
 }
开发者ID:SystemDot,项目名称:SystemDotServiceBus,代码行数:4,代码来源:MainPage.xaml.cs


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