本文整理汇总了C#中IEndpointInstance类的典型用法代码示例。如果您正苦于以下问题:C# IEndpointInstance类的具体用法?C# IEndpointInstance怎么用?C# IEndpointInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEndpointInstance类属于命名空间,在下文中一共展示了IEndpointInstance类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:25,代码来源:Program.cs
示例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"));
}
}
开发者ID:fivec,项目名称:docs.particular.net,代码行数:29,代码来源:Program.cs
示例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;
}
}
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:26,代码来源:Program.cs
示例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;
}
}
}
}
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:59,代码来源:Runner.cs
示例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;
}
开发者ID:fivec,项目名称:docs.particular.net,代码行数:8,代码来源:Program.cs
示例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");
}
开发者ID:fivec,项目名称:docs.particular.net,代码行数:9,代码来源:CommandSender.cs
示例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
}
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:8,代码来源:Usage.cs
示例8: Subscribe
async Task Subscribe(IEndpointInstance endpoint)
{
#region ExplicitSubscribe
await endpoint.Subscribe<MyEvent>();
await endpoint.Unsubscribe<MyEvent>();
#endregion
}
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:8,代码来源:BasicOperations.cs
示例9: SendMessage
static async Task SendMessage(IEndpointInstance endpointInstance)
{
Message message = new Message();
await endpointInstance.SendLocal(message);
Console.WriteLine();
Console.WriteLine("Message sent");
}
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:8,代码来源:Program.cs
示例10: DefaultAction
Task DefaultAction(IEndpointInstance endpoint)
{
#region DefaultCriticalErrorAction
return endpoint.Stop();
#endregion
}
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:8,代码来源:CriticalErrors.cs
示例11: SetInstance
public static void SetInstance(IEndpointInstance endpoint)
{
if (Endpoint != null)
{
throw new Exception("Endpoint already set.");
}
Endpoint = endpoint;
}
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:8,代码来源:Hosting.cs
示例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");
}
开发者ID:fivec,项目名称:docs.particular.net,代码行数:9,代码来源:Program.cs
示例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");
}
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:11,代码来源:CommandSender.cs
示例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");
}
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:10,代码来源:Program.cs
示例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);
}
开发者ID:fivec,项目名称:docs.particular.net,代码行数:11,代码来源:CommandSender.cs
示例16: SendDelayedMessage
async Task SendDelayedMessage(IEndpointInstance endpoint, IMessageHandlerContext handlerContext)
{
#region delayed-delivery-datetime
SendOptions options = new SendOptions();
options.DoNotDeliverBefore(new DateTime(2016, 12, 25));
await handlerContext.Send(new MessageToBeSentLater(), options);
// OR
await endpoint.Send(new MessageToBeSentLater(), options);
#endregion
}
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:11,代码来源:DeferForDateTime.cs
示例17: Scheduling
Scheduling(IEndpointInstance endpointInstance)
{
#region ScheduleTask
// To send a message every 5 minutes
endpointInstance.ScheduleEvery(TimeSpan.FromMinutes(5), b => b.Send(new CallLegacySystem()));
// Name a schedule task and invoke it every 5 minutes
endpointInstance.ScheduleEvery(TimeSpan.FromMinutes(5), "MyCustomTask", SomeCustomMethod);
#endregion
}
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:11,代码来源:Scheduling.cs
示例18: SendRequest
static async Task SendRequest(IEndpointInstance endpointInstance)
{
Guid requestId = Guid.NewGuid();
await endpointInstance.Send(new Request
{
RequestId = requestId
});
Console.WriteLine("Request sent id: " + requestId);
}
开发者ID:fivec,项目名称:docs.particular.net,代码行数:11,代码来源:CommandSender.cs
示例19: Start
static async Task Start(IEndpointInstance endpointInstance)
{
Console.WriteLine("Press '1' to publish IEvent");
Console.WriteLine("Press '2' to publish EventMessage");
Console.WriteLine("Press '3' to publish AnotherEventMessage");
Console.WriteLine("Press any other key to exit");
#region PublishLoop
while (true)
{
var key = Console.ReadKey();
Console.WriteLine();
var eventId = Guid.NewGuid();
switch (key.Key)
{
case ConsoleKey.D1:
await endpointInstance.Publish<IMyEvent>(m =>
{
m.EventId = eventId;
m.Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null;
m.Duration = TimeSpan.FromSeconds(99999D);
})
.ConfigureAwait(false);
Console.WriteLine($"Published IMyEvent with Id {eventId}.");
continue;
case ConsoleKey.D2:
var eventMessage = new EventMessage
{
EventId = eventId,
Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null,
Duration = TimeSpan.FromSeconds(99999D)
};
await endpointInstance.Publish(eventMessage)
.ConfigureAwait(false);
Console.WriteLine($"Published EventMessage with Id {eventId}.");
continue;
case ConsoleKey.D3:
var anotherEventMessage = new AnotherEventMessage
{
EventId = eventId,
Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null,
Duration = TimeSpan.FromSeconds(99999D)
};
await endpointInstance.Publish(anotherEventMessage)
.ConfigureAwait(false);
Console.WriteLine($"Published AnotherEventMessage with Id {eventId}.");
continue;
default:
return;
}
}
#endregion
}
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:53,代码来源:Program.cs
示例20: SendEnumMessage
static async Task SendEnumMessage(IEndpointInstance endpointInstance)
{
Console.WriteLine("Message sent");
#region SendEnumMessage
EnumMessage message = new EnumMessage();
SendOptions sendOptions = new SendOptions();
sendOptions.SetDestination("Samples.Callbacks.Receiver");
Status status = await endpointInstance.Request<Status>(message, sendOptions);
Console.WriteLine("Callback received with status:" + status);
#endregion
}
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:12,代码来源:Program.cs
注:本文中的IEndpointInstance类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论