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


C# IBuilder.Build方法代码示例

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


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

示例1: DistributorSatellite

        public DistributorSatellite(IBuilder builder, ReadOnlySettings settings)
        {
            disable = !settings.GetOrDefault<bool>("Distributor.Enabled");

            if (disable)
            {
                return;
            }

            messageSender = builder.Build<ISendMessages>();
            workerManager = builder.Build<IWorkerAvailabilityManager>();
            address = MasterNodeConfiguration.GetMasterNodeAddress(settings);
        }
开发者ID:ltines,项目名称:NServiceBus.Distributor.Msmq,代码行数:13,代码来源:DistributorSatellite.cs

示例2: ConvertConfigToRijndaelService

 internal static IEncryptionService ConvertConfigToRijndaelService(IBuilder builder, RijndaelEncryptionServiceConfig section)
 {
     ValidateConfigSection(section);
     var keys = ExtractKeysFromConfigSection(section);
     var decryptionKeys = ExtractDecryptionKeysFromConfigSection(section);
     return BuildRijndaelEncryptionService(
         builder.Build<IBus>(),
         section.KeyIdentifier,
         keys,
         decryptionKeys
         );
 }
开发者ID:ninocrudele,项目名称:NServiceBus,代码行数:12,代码来源:ConfigureRijndaelEncryptionService.cs

示例3: DistributorReadyMessageProcessor

        public DistributorReadyMessageProcessor(IBuilder builder, ReadOnlySettings settings)
        {
            disable = !settings.GetOrDefault<bool>("Distributor.Enabled");

            if (disable)
            {
                return;
            }

            workerAvailabilityManager = builder.Build<IWorkerAvailabilityManager>();
            address = MasterNodeConfiguration.GetMasterNodeAddress(settings).SubScope("distributor.control");
        }
开发者ID:ltines,项目名称:NServiceBus.Distributor.Msmq,代码行数:12,代码来源:DistributorReadyMessageProcessor.cs

示例4: SetupImpersonation

        internal static void SetupImpersonation(IBuilder childBuilder, TransportMessage message)
        {
            if (!Impersonate)
                return;
            var impersonator = childBuilder.Build<ExtractIncomingPrincipal>();

            if (impersonator == null)
                throw new InvalidOperationException("Run handler under incoming principal is configured for this endpoint but no implementation of ExtractIncomingPrincipal has been found. Please register one.");

            var principal = impersonator.GetPrincipal(message);

            if (principal == null)
                return;

            Thread.CurrentPrincipal = principal;
        }
开发者ID:johannesg,项目名称:NServiceBus,代码行数:16,代码来源:ConfigureImpersonation.cs

示例5: GetDispatcher

        /// <summary>
        /// Get Dispatcher
        /// </summary>
        /// <param name="messageHandlerType">Type of the message Handler</param>
        /// <param name="builder">Builder</param>
        /// <param name="message">Message</param>
        /// <returns>Saga Dispatcher</returns>
        public IEnumerable<Action> GetDispatcher(Type messageHandlerType, IBuilder builder, object message)
        {
            var entitiesHandled = new List<IContainSagaData>();
            var sagaTypesHandled = new List<Type>();

            foreach (var finder in GetFindersFor(message, builder))
            {
                bool sagaEntityIsPersistent = true;
                IContainSagaData sagaEntity = UseFinderToFindSaga(finder, message);
                Type sagaType;

                if (sagaEntity == null)
                {
                    sagaType = Features.Sagas.GetSagaTypeToStartIfMessageNotFoundByFinder(message, finder);
                    if (sagaType == null)
                        continue;

                    if (sagaTypesHandled.Contains(sagaType))
                        continue; // don't create the same saga type twice for the same message

                    sagaEntity = CreateNewSagaEntity(sagaType);

                    sagaEntityIsPersistent = false;
                }
                else
                {
                    if (entitiesHandled.Contains(sagaEntity))
                        continue; // don't call the same saga twice

                    sagaType = Features.Sagas.GetSagaTypeForSagaEntityType(sagaEntity.GetType());
                }

                if (messageHandlerType.IsAssignableFrom(sagaType))
                    yield return () =>
                                     {
                                         var saga = (ISaga)builder.Build(sagaType);

                                         saga.Entity = sagaEntity;

                                         try
                                         {
                                             SagaContext.Current = saga;

                                             if (IsTimeoutMessage(message))
                                             {
                                                 HandlerInvocationCache.InvokeTimeout(saga, message);
                                             }
                                             else
                                             {
                                                 HandlerInvocationCache.InvokeHandle(saga, message);
                                             }

                                             if (!saga.Completed)
                                             {
                                                 if (!sagaEntityIsPersistent)
                                                 {
                                                     Persister.Save(saga.Entity);
                                                 }
                                                 else
                                                 {
                                                     Persister.Update(saga.Entity);
                                                 }
                                             }
                                             else
                                             {
                                                 if (sagaEntityIsPersistent)
                                                 {
                                                     Persister.Complete(saga.Entity);
                                                 }

                                                 if (saga.Entity.Id != Guid.Empty)
                                                 {
                                                     NotifyTimeoutManagerThatSagaHasCompleted(saga);
                                                 }
                                             }

                                             LogIfSagaIsFinished(saga);

                                         }
                                         finally
                                         {
                                             SagaContext.Current = null;
                                         }

                                     };

                sagaTypesHandled.Add(sagaType);
                entitiesHandled.Add(sagaEntity);
            }

            if (entitiesHandled.Count == 0)
                yield return () =>
                                 {
//.........这里部分代码省略.........
开发者ID:afyles,项目名称:NServiceBus,代码行数:101,代码来源:SagaDispatcherFactory.cs

示例6: GetFindersFor

        IEnumerable<IFinder> GetFindersFor(object message, IBuilder builder)
        {
            var sagaId = Headers.GetMessageHeader(message, Headers.SagaId);
            var sagaEntityType = GetSagaEntityType(message);

            if (sagaEntityType == null || string.IsNullOrEmpty(sagaId))
            {
                var finders = Features.Sagas.GetFindersFor(message).Select(t => builder.Build(t) as IFinder).ToList();

                if (logger.IsDebugEnabled)
                    logger.DebugFormat("The following finders:{0} was allocated to message of type {1}", string.Join(";", finders.Select(t => t.GetType().Name)), message.GetType());

                return finders;
            }

            logger.DebugFormat("Message contains a saga type and saga id. Going to use the saga id finder. Type:{0}, Id:{1}", sagaEntityType, sagaId);

            return new List<IFinder> { builder.Build(typeof(HeaderSagaIdFinder<>).MakeGenericType(sagaEntityType)) as IFinder };
        }
开发者ID:afyles,项目名称:NServiceBus,代码行数:19,代码来源:SagaDispatcherFactory.cs

示例7: StopFeatures

        public void StopFeatures(IBuilder builder)
        {
            foreach (var feature in features.Where(f => f.Feature.IsActive))
            {
                foreach (var taskType in feature.Feature.StartupTasks)
                {
                    var task = (FeatureStartupTask) builder.Build(taskType);

                    task.PerformStop();
                }
            }
        }
开发者ID:xqfgbc,项目名称:NServiceBus,代码行数:12,代码来源:FeatureActivator.cs

示例8: CreateBehavior

        internal IBehavior CreateBehavior(IBuilder defaultBuilder)
        {
            var behavior = factoryMethod != null
                ? factoryMethod(defaultBuilder)
                : (IBehavior) defaultBuilder.Build(BehaviorType);

            return behavior;
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:8,代码来源:RegisterStep.cs

示例9: Build

 public string Build(IBuilder builder, string @class, string @namespace)
 {
     return builder.Build(this, @class, @namespace);
 }
开发者ID:sys27,项目名称:Edge,代码行数:4,代码来源:SyntaxTree.cs

示例10: GetFindersFor

        IEnumerable<IFinder> GetFindersFor(object message, IBuilder builder)
        {
            var finders = Features.Sagas.GetFindersFor(message).Select(t => builder.Build(t) as IFinder).ToList();

            if (logger.IsDebugEnabled)
                logger.DebugFormat("The following finders:{0} was allocated to message of type {1}", string.Join(";", finders.Select(t => t.GetType().Name)), message.GetType());

            return finders;
        }
开发者ID:raelyard,项目名称:NServiceBus,代码行数:9,代码来源:SagaDispatcherFactory.cs

示例11: GetDispatcher

        /// <summary>
        /// Get Dispatcher
        /// </summary>
        /// <param name="messageHandlerType">Type of the message Handler</param>
        /// <param name="builder">Builder</param>
        /// <param name="message">Message</param>
        /// <returns>Saga Dispatcher</returns>
        public IEnumerable<Action> GetDispatcher(Type messageHandlerType, IBuilder builder, object message)
        {
            if (message.IsTimeoutMessage() && !message.TimeoutHasExpired())
            {
                yield return () => Bus.HandleCurrentMessageLater();
                yield break;
            }

            var entitiesHandled = new List<ISagaEntity>();
            var sagaTypesHandled = new List<Type>();

            foreach (var finder in GetFindersFor(message, builder))
            {
               bool sagaEntityIsPersistent = true;
                ISagaEntity sagaEntity = UseFinderToFindSaga(finder, message);
                Type sagaType;

                if (sagaEntity == null)
                {
                    sagaType = Configure.GetSagaTypeToStartIfMessageNotFoundByFinder(message, finder);
                    if (sagaType == null)
                        continue;

                    if (sagaTypesHandled.Contains(sagaType))
                        continue; // don't create the same saga type twice for the same message

                    Type sagaEntityType = Configure.GetSagaEntityTypeForSagaType(sagaType);
                    sagaEntity = Activator.CreateInstance(sagaEntityType) as ISagaEntity;

                    if (sagaEntity != null)
                    {
                        if (message is ISagaMessage)
                            sagaEntity.Id = (message as ISagaMessage).SagaId;
                        else
                            sagaEntity.Id = GuidCombGenerator.Generate();

                        sagaEntity.Originator = Bus.CurrentMessageContext.ReplyToAddress.ToString();
                        sagaEntity.OriginalMessageId = Bus.CurrentMessageContext.Id;

                        sagaEntityIsPersistent = false;
                    }
                }
                else
                {
                    if (entitiesHandled.Contains(sagaEntity))
                        continue; // don't call the same saga twice

                    sagaType = Configure.GetSagaTypeForSagaEntityType(sagaEntity.GetType());
                }

                if (messageHandlerType.IsAssignableFrom(sagaType))
                    yield return () =>
                                     {
                                         var saga = (ISaga)builder.Build(sagaType);

                                         saga.Entity = sagaEntity;

                                         HandlerInvocationCache.Invoke(saga, message);

                                         if (!saga.Completed)
                                         {
                                             if (!sagaEntityIsPersistent)
                                                 Persister.Save(saga.Entity);
                                             else
                                                 Persister.Update(saga.Entity);
                                         }
                                         else
                                         {
                                             if (sagaEntityIsPersistent)
                                                 Persister.Complete(saga.Entity);

                                             NotifyTimeoutManagerThatSagaHasCompleted(saga);
                                         }

                                         LogIfSagaIsFinished(saga);

                                     };
                sagaTypesHandled.Add(sagaType);
                entitiesHandled.Add(sagaEntity);
            }

            if (entitiesHandled.Count == 0)
                yield return () =>
                                 {
                                     logger.InfoFormat("Could not find a saga for the message type {0} with id {1}. Going to invoke SagaNotFoundHandlers.", message.GetType().FullName, Bus.CurrentMessageContext.Id);
                                     foreach (var handler in builder.BuildAll<IHandleSagaNotFound>())
                                     {
                                         logger.DebugFormat("Invoking SagaNotFoundHandler: {0}",
                                                            handler.GetType().FullName);
                                         handler.Handle(message);
                                     }

                                 };
//.........这里部分代码省略.........
开发者ID:ollnixon,项目名称:NServiceBus,代码行数:101,代码来源:SagaDispatcherFactory.cs

示例12: GetFindersFor

 IEnumerable<IFinder> GetFindersFor(object message, IBuilder builder)
 {
     return Configure.GetFindersFor(message).Select(t => builder.Build(t) as IFinder);
 }
开发者ID:ollnixon,项目名称:NServiceBus,代码行数:4,代码来源:SagaDispatcherFactory.cs

示例13: Create

        /// <summary>
        /// Creates a new bot instance using the provided builder.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <returns>New Bot instance.</returns>
        public static Bot Create(IBuilder builder)
        {
            try
            {
                builder.RegisterComponents();
                builder.LoadModuleComponents();

                return builder.Build<Bot>();
            }
            catch (Exception ex)
            {
                Exception e = new Exception("Error initializing required bot components. Unable to initialize bot.", ex);
                throw e;
            }
        }
开发者ID:JonHaywood,项目名称:Oberon,代码行数:20,代码来源:Bot.cs

示例14: GetDispatcherFactoryFor

        IMessageDispatcherFactory GetDispatcherFactoryFor(Type messageHandlerTypeToInvoke, IBuilder builder)
        {
            Type factoryType;

            //todo: Move the dispatcher mappings here (also obsolete the feature)
            builder.Build<UnicastBus>().MessageDispatcherMappings.TryGetValue(messageHandlerTypeToInvoke, out factoryType);

            if (factoryType == null)
                return null;

            var factory = builder.Build(factoryType) as IMessageDispatcherFactory;

            if (factory == null)
                throw new InvalidOperationException(string.Format("Registered dispatcher factory {0} for type {1} does not implement IMessageDispatcherFactory", factoryType, messageHandlerTypeToInvoke));

            return factory;
        }
开发者ID:ranji,项目名称:NServiceBus,代码行数:17,代码来源:InvokeHandlersBehavior.cs

示例15: Initialize

        public static void Initialize(IBuilder builder)
        {
            // start a thread which will handle the UI
            var thread = new Thread(() =>
            {
                var iconStream = Assembly.GetExecutingAssembly()
                    .GetManifestResourceStream("Oberon.SystemTray.Icon.ico");

                NotifyIcon trayIcon = new NotifyIcon();
                trayIcon.Text = "Oberon";
                trayIcon.Icon = new Icon(iconStream, 40, 40);

                ContextMenu trayMenu = new ContextMenu();
                trayMenu.MenuItems.Add("Actions", new [] {
                    new MenuItem("Version Info", About_Click),
                    new MenuItem("Check for Updates", MenuItem_Click),
                    new MenuItem("Manage Plugins", ManagePlugins_Click),
                    new MenuItem("Show Chat Interface", ShowChatInterface_Click)
                });
                trayMenu.MenuItems.Add("Restart Bot", Restart_Click);
                trayMenu.MenuItems.Add("Shutdown Bot", Exit_Click);
                trayMenu.MenuItems.Add(new MenuItem("Help", Help_Click) { BarBreak = true });

                trayIcon.ContextMenu = trayMenu;
                trayIcon.Visible = true;

                // start the messaging loop so the menu responds to events
                Application.Run();
            });
            thread.SetApartmentState(ApartmentState.STA);
            thread.IsBackground = true;
            thread.Start();

            // get a reference to the plugin handler
            pluginHandler = builder.Build<IPluginHandler>();

            // get a reference to the listener
            listener = builder.Build<IListener>();
        }
开发者ID:JonHaywood,项目名称:Oberon,代码行数:39,代码来源:Module.cs


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