本文整理汇总了C#中IResolver.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# IResolver.Resolve方法的具体用法?C# IResolver.Resolve怎么用?C# IResolver.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IResolver
的用法示例。
在下文中一共展示了IResolver.Resolve方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LcdpServer
public LcdpServer(ILcdpPacketSerializer lcdpPacketSerializer, IListener listener, IForwarder forwarder, IResolver resolver)
{
this.lcdpPacketSerializer = lcdpPacketSerializer;
this.listener = listener;
this.forwarder = forwarder;
this.messages = new ConcurrentDictionary<string, LcdpMessage>();
this.ChunkExpirationTimeMilliseconds = 5000;
this.compressors = new Dictionary<byte, ICompressor>();
this.serializers = new Dictionary<byte, ISerializer>();
for(byte b = 0; b < byte.MaxValue; ++b)
{
ICompressor compressor = resolver.Resolve<ICompressor>(b.ToString());
if (compressor != null)
{
compressors[b] = compressor;
}
ISerializer serializer = resolver.Resolve<ISerializer>(b.ToString());
if (serializer != null)
{
serializers[b] = serializer;
}
}
}
示例2: ExecuteAsync
public async Task ExecuteAsync(IResolver resolver, CancellationToken cancellationToken)
{
var queryProcessor = resolver.Resolve<IQueryProcessor>();
var updateItineraryService = resolver.Resolve<IUpdateItineraryService>();
var commandBus = resolver.Resolve<ICommandBus>();
var routingService = resolver.Resolve<IRoutingService>();
var cargo = (await queryProcessor.ProcessAsync(new GetCargosQuery(CargoId), cancellationToken).ConfigureAwait(false)).Single();
var updatedItinerary = await updateItineraryService.UpdateItineraryAsync(cargo.Itinerary, cancellationToken).ConfigureAwait(false);
if (cargo.Route.Specification().IsSatisfiedBy(updatedItinerary))
{
await commandBus.PublishAsync(new CargoSetItineraryCommand(cargo.Id, updatedItinerary), cancellationToken).ConfigureAwait(false);
return;
}
var newItineraries = await routingService.CalculateItinerariesAsync(cargo.Route, cancellationToken).ConfigureAwait(false);
var newItinerary = newItineraries.FirstOrDefault();
if (newItinerary == null)
{
// TODO: Tell domain that a new itinerary could not be found
throw DomainError.With("Could not find itinerary");
}
await commandBus.PublishAsync(new CargoSetItineraryCommand(cargo.Id, newItinerary), cancellationToken).ConfigureAwait(false);
}
示例3: Create
public static PublishCommandJob Create(
ICommand command,
IResolver resolver)
{
var commandDefinitionService = resolver.Resolve<ICommandDefinitionService>();
var jsonSerializer = resolver.Resolve<IJsonSerializer>();
return Create(command, commandDefinitionService, jsonSerializer);
}
示例4: ExecuteAsync
public Task ExecuteAsync(IResolver resolver, CancellationToken cancellationToken)
{
var commandDefinitionService = resolver.Resolve<ICommandDefinitionService>();
var jsonSerializer = resolver.Resolve<IJsonSerializer>();
var commandBus = resolver.Resolve<ICommandBus>();
var commandDefinition = commandDefinitionService.GetDefinition(Name, Version);
var command = (ICommand) jsonSerializer.Deserialize(Data, commandDefinition.Type);
return command.PublishAsync(commandBus, cancellationToken);
}
示例5: ExecuteAsync
public async Task ExecuteAsync(IResolver resolver, CancellationToken cancellationToken)
{
// Consideration: Fetching all cargos that are affected by an updated
// schedule could potentially fetch several thousands. Each of these
// potential re-routes would then take a considerable amount of time
// and will thus be required to be executed in parallel
var queryProcessor = resolver.Resolve<IQueryProcessor>();
var jobScheduler = resolver.Resolve<IJobScheduler>();
var cargos = await queryProcessor.ProcessAsync(new GetCargosDependentOnVoyageQuery(VoyageId), cancellationToken).ConfigureAwait(false);
var jobs = cargos.Select(c => new VerifyCargoItineraryJob(c.Id));
await Task.WhenAll(jobs.Select(j => jobScheduler.ScheduleNowAsync(j, cancellationToken))).ConfigureAwait(false);
}
示例6: SetUp
public void SetUp()
{
var codeBase = ReflectionHelper.GetCodeBase(GetType().Assembly);
var filesEventStoreDirectory = Path.GetFullPath(Path.Combine(codeBase, "..", "..", "TestData", "FilesEventStore"));
_resolver = EventFlowOptions.New
.UseFilesEventStore(FilesEventStoreConfiguration.Create(filesEventStoreDirectory))
.AddEvents(EventFlowTestHelpers.Assembly)
.AddCommandHandlers(EventFlowTestHelpers.Assembly)
.CreateResolver();
_commandBus = _resolver.Resolve<ICommandBus>();
_eventStore = _resolver.Resolve<IEventStore>();
}
示例7: AutoDiscover
internal void AutoDiscover(IResolver resolver)
{
var types = _configurator.Assemblies.SelectMany(x => x.GetTypes()).Where(x => x.HasAttribute<MDataAttribute>()).Select(x => x);
foreach (var assembly in _configurator.Assemblies)
{
RegisterAssembly(assembly);
}
foreach (var type in types)
{
RegisterDomainInterface(type, GetLogicClass(type));
resolver.Resolve(type);
}
}
示例8: GetUrl
public string GetUrl(IResolver resolver)
{
string url = resolver.Resolve(this.url);
this.result.ExecutedUrl = url;
return url;
}
示例9: GetPostData
public NameValueCollection GetPostData(IResolver resolver)
{
NameValueCollection postData = new NameValueCollection();
foreach (string key in this.postData.Keys)
{
postData[key] = resolver.Resolve(this.postData[key].ToString());
}
return postData;
}
示例10: AssertResolveCanResolveIEnumerableType
private void AssertResolveCanResolveIEnumerableType(IResolver resolver, string key = null)
{
// Test both generic and non - generic ?
var result = key == null ? resolver.Resolve<IEnumerable<IFoo>>() : resolver.Resolve<IEnumerable<IFoo>>(key);
Assert.IsNotNull(result);
Assert.IsInstanceOfType(result, typeof(IEnumerable<IFoo>));
var collection = result.ToArray();
CollectionAssert.AllItemsAreNotNull(collection);
CollectionAssert.AllItemsAreUnique(collection);
CollectionAssert.AllItemsAreInstancesOfType(collection, typeof(IFoo));
}
示例11: RefreshContent
void RefreshContent(IResolver container, IEnumerable<PostViewModel> posts)
{
var storage = container.Resolve<MarkdownSharpContentStorage>();
foreach (var post in posts)
{
storage.Handle(post);
}
}
示例12: Install
public void Install(DistributedConfiguration distributedConfiguration, string loggerConfiguration)
{
RegisterLogging(loggerConfiguration);
if (distributedConfiguration == null)
{
// use nomad specific installer for that
_windsorContainer.Install(
new NomadEventAggregatorInstaller(),
new NomadServiceLocatorInstaller(),
new ModuleLoaderInstaller()
);
}
else
{
// use nomad specific installer for that
_windsorContainer.Install(
new NomadDistributedDeliverySubsystemsInstaller(distributedConfiguration),
new NomadDistributedEventAggregatorInstaller(),
new NomadServiceLocatorInstaller(),
new ModuleLoaderInstaller()
);
// TODO: make registering resolver with container later
var dea =
(DistributedEventAggregator)
_windsorContainer.Resolve<IEventAggregator>(NomadDistributedEventAggregatorInstaller.ON_SITE_NAME);
_resolver = new ResolverFactory(distributedConfiguration);
dea.RemoteDistributedEventAggregator = _resolver.Resolve();
// run service
RegisterServiceHostDEA(distributedConfiguration);
}
}