本文整理汇总了C#中IEndpointInstance类的典型用法代码示例。如果您正苦于以下问题:C# IEndpointInstance类的具体用法?C# IEndpointInstance怎么用?C# IEndpointInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEndpointInstance类属于命名空间,在下文中一共展示了IEndpointInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
static async Task Run(IEndpointInstance endpointInstance)
{
Console.WriteLine("Press 'F' to send a message with a file stream");
Console.WriteLine("Press 'H' to send a message with a http stream");
Console.WriteLine("Press any key to exit");
while (true)
{
var key = Console.ReadKey();
if (key.Key == ConsoleKey.F)
{
await SendMessageWithFileStream(endpointInstance)
.ConfigureAwait(false);
continue;
}
if (key.Key == ConsoleKey.H)
{
await SendMessageWithHttpStream(endpointInstance)
.ConfigureAwait(false);
continue;
}
break;
}
}
示例2: SendOrder
static async Task SendOrder(IEndpointInstance endpointInstance)
{
Console.WriteLine("Press enter to send a message");
Console.WriteLine("Press any key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
break;
}
Guid id = Guid.NewGuid();
PlaceOrder placeOrder = new PlaceOrder
{
Product = "New shoes",
Id = id
};
await endpointInstance.Send("Samples.StepByStep.Server", placeOrder);
Console.WriteLine("Sent a new PlaceOrder message with id: {0}", id.ToString("N"));
}
}
示例3: Run
static async Task Run(IEndpointInstance endpointInstance)
{
Console.WriteLine("Press 'J' to send a JSON message");
Console.WriteLine("Press 'X' to send a XML message");
Console.WriteLine("Press any key to exit");
while (true)
{
var key = Console.ReadKey();
Console.WriteLine();
if (key.Key == ConsoleKey.X)
{
await SendXmlMessage(endpointInstance)
.ConfigureAwait(false);
continue;
}
if (key.Key == ConsoleKey.J)
{
await SendJsonMessage(endpointInstance)
.ConfigureAwait(false);
continue;
}
break;
}
}
示例4: Run
public static async Task Run(IEndpointInstance endpointInstance)
{
Console.WriteLine("Press 's' to send a valid message");
Console.WriteLine("Press 'e' to send a failed message");
Console.WriteLine("Press any key to exit");
while (true)
{
var key = Console.ReadKey();
Console.WriteLine();
Console.WriteLine();
switch (key.Key)
{
case ConsoleKey.S:
#region SendingSmall
var createProductCommand = new CreateProductCommand
{
ProductId = "XJ128",
ProductName = "Milk",
ListPrice = 4,
// 7MB. MSMQ should throw an exception, but it will not since the buffer will be compressed
// before it reaches MSMQ.
Image = new byte[1024 * 1024 * 7]
};
await endpointInstance.SendLocal(createProductCommand)
.ConfigureAwait(false);
#endregion
break;
case ConsoleKey.E:
try
{
#region SendingLarge
var productCommand = new CreateProductCommand
{
ProductId = "XJ128",
ProductName = "Really long product name",
ListPrice = 15,
// 7MB. MSMQ should throw an exception, but it will not since the buffer will be compressed
// before it reaches MSMQ.
Image = new byte[1024 * 1024 * 7]
};
await endpointInstance.SendLocal(productCommand)
.ConfigureAwait(false);
#endregion
}
catch
{
//so the console keeps on running
}
break;
default:
{
return;
}
}
}
}
示例5: StartWcfHost
static IDisposable StartWcfHost(IEndpointInstance endpointInstance)
{
WcfMapper wcfMapper = new WcfMapper(endpointInstance, "http://localhost:8080");
wcfMapper.StartListening<EnumMessage, Status>();
wcfMapper.StartListening<ObjectMessage, ReplyMessage>();
wcfMapper.StartListening<IntMessage, int>();
return wcfMapper;
}
示例6: Expiration
// Shut down server before sending this message, after 30 seconds, the message will be moved to Transactional dead-letter messages queue.
static async Task Expiration(IEndpointInstance endpointInstance)
{
await endpointInstance.Send(new MessageThatExpires
{
RequestId = new Guid()
});
Console.WriteLine("message with expiration was sent");
}
示例7: Simple
async void Simple(IEndpointInstance endpoint, SendOptions sendOptions, ILog log)
{
#region EnumCallback
Message message = new Message();
Status response = await endpoint.Request<Status>(message, sendOptions);
log.Info("Callback received with response:" + response);
#endregion
}
示例8: Subscribe
async Task Subscribe(IEndpointInstance endpoint)
{
#region ExplicitSubscribe
await endpoint.Subscribe<MyEvent>();
await endpoint.Unsubscribe<MyEvent>();
#endregion
}
示例9: SendMessage
static async Task SendMessage(IEndpointInstance endpointInstance)
{
Message message = new Message();
await endpointInstance.SendLocal(message);
Console.WriteLine();
Console.WriteLine("Message sent");
}
示例10: DefaultAction
Task DefaultAction(IEndpointInstance endpoint)
{
#region DefaultCriticalErrorAction
return endpoint.Stop();
#endregion
}
示例11: SetInstance
public static void SetInstance(IEndpointInstance endpoint)
{
if (Endpoint != null)
{
throw new Exception("Endpoint already set.");
}
Endpoint = endpoint;
}
示例12: SendJsonMessage
static async Task SendJsonMessage(IEndpointInstance endpointInstance)
{
MessageWithJson message = new MessageWithJson
{
SomeProperty = "Some content in a json message",
};
await endpointInstance.Send("Samples.MultiSerializer.Receiver", message);
Console.WriteLine("Json Message sent");
}
示例13: Expiration
// Shut down server before sending this message, after 30 seconds, the message will be moved to Transactional dead-letter messages queue.
static async Task Expiration(IEndpointInstance endpointInstance)
{
var messageThatExpires = new MessageThatExpires
{
RequestId = new Guid()
};
await endpointInstance.Send(messageThatExpires)
.ConfigureAwait(false);
Console.WriteLine("message with expiration was sent");
}
示例14: SendXmlMessage
static async Task SendXmlMessage(IEndpointInstance endpointInstance)
{
var message = new MessageWithXml
{
SomeProperty = "Some content in a Xml message",
};
await endpointInstance.Send("Samples.MultiSerializer.Receiver", message)
.ConfigureAwait(false);
Console.WriteLine("XML message sent");
}
示例15: PublishEvent
static async Task PublishEvent(IEndpointInstance endpointInstance)
{
Guid eventId = Guid.NewGuid();
await endpointInstance.Publish<IMyEvent>(m =>
{
m.EventId = eventId;
});
Console.WriteLine("Event published, id: " + eventId);
}