本文整理汇总了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);
}
示例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
);
}
示例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");
}
示例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;
}
示例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 () =>
{
//.........这里部分代码省略.........
示例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 };
}
示例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();
}
}
}
示例8: CreateBehavior
internal IBehavior CreateBehavior(IBuilder defaultBuilder)
{
var behavior = factoryMethod != null
? factoryMethod(defaultBuilder)
: (IBehavior) defaultBuilder.Build(BehaviorType);
return behavior;
}
示例9: Build
public string Build(IBuilder builder, string @class, string @namespace)
{
return builder.Build(this, @class, @namespace);
}
示例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;
}
示例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);
}
};
//.........这里部分代码省略.........
示例12: GetFindersFor
IEnumerable<IFinder> GetFindersFor(object message, IBuilder builder)
{
return Configure.GetFindersFor(message).Select(t => builder.Build(t) as IFinder);
}
示例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;
}
}
示例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;
}
示例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>();
}