Skip to content

Instantly share code, notes, and snippets.

View msciborski's full-sized avatar

Michał Ściborski msciborski

View GitHub Profile
[ClientMetadata("email")]
public class EmailSender : ISender
{
public Task Send(string message)
{
// Sending message to client
return Task.CompletedTask;
}
}
builder.Register<SenderFactory>(c =>
{
var context = c.Resolve<IComponentContext>();
return (client) =>
{
var sender = context.Resolve<IEnumerable<ISender>>()
.Select(s => new
{
Metadata = (ClientMetadataAttribute) Attribute.GetCustomAttribute(s.GetType(),
[Route("api/[controller]")]
[ApiController]
public class TestController : ControllerBase
{
private readonly SenderFactory _senderFactory;
public TestController(SenderFactory senderFactory)
{
_senderFactory = senderFactory;
}
builder.Register<SenderFactory>(c =>
{
var context = c.Resolve<IComponentContext>();
return (client) =>
{
var sender = context.Resolve<IEnumerable<Meta<ISender>>>()
.First(x => (string) x.Metadata["Client"] == client).Value;
return sender;
builder.Register<SenderFactory>(c =>
{
var context = c.Resolve<IComponentContext>();
return (client) =>
{
var sender = context.Resolve<IEnumerable<Meta<ISender>>>()
.First(x => (string) x.Metadata["Client"] == client).Value;
return sender;
public class ApplicationModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder
.RegisterModule<AttributedMetadataModule>();
builder.Register<SenderFactory>(c =>
{
var context = c.Resolve<IComponentContext>();
public delegate ISender SenderFactory(string client);
[HttpGet()]
public async Task<IActionResult> SendMessage(string senderType)
{
return Ok();
}
1>------ Rebuild All started: Project: Utils, Configuration: Debug Any CPU ------
2>------ Rebuild All started: Project: Validation, Configuration: Debug Any CPU ------
1>CQRS\GenericUpdateDeleteQuery.cs(12,31,12,38): warning CS0649: Field 'GenericUpdateDeleteQuery<TResult, TPayload>._userId' is never assigned to, and will always have its default value
1>Utils -> D:\VSI\VsiManagerCore\Shared\Infrastructure\Utils\bin\Debug\netcoreapp3.1\Utils.dll
1>Done building project "Utils.csproj".
3>------ Rebuild All started: Project: UploadCommunicationModule, Configuration: Debug Any CPU ------
4>------ Rebuild All started: Project: PatientCommunicationModule, Configuration: Debug Any CPU ------
2>BaselineValidator.cs(23,30,23,33): warning CS0168: The variable 'err' is declared but never used
2>BaselineValidator.cs(37,30,37,33): warning CS0168: The variable 'err' is declared but never used
2>Validation -> D:\VSI\VsiManagerCore\Shared\Infrastructure\Validation\bin\Debug\netcoreapp3.1\Validation.dll
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Hl7v2MLLP
{