本文整理汇总了C#中Endpoint类的典型用法代码示例。如果您正苦于以下问题:C# Endpoint类的具体用法?C# Endpoint怎么用?C# Endpoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Endpoint类属于命名空间,在下文中一共展示了Endpoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test
public static void Test(ITransport t, IQueueStrategy strategy,
Endpoint queueEndpoint, Action<Message> send, Func<MessageEnumerator>
enumer)
{
Guid id = Guid.NewGuid();
var serializer = new XmlMessageSerializer(new
DefaultReflection(), new DefaultKernel());
var subscriptionStorage = new MsmqSubscriptionStorage(new
DefaultReflection(),
serializer,
queueEndpoint.Uri,
new
EndpointRouter(),
strategy);
subscriptionStorage.Initialize();
var wait = new ManualResetEvent(false);
subscriptionStorage.SubscriptionChanged += () => wait.Set();
t.AdministrativeMessageArrived +=
subscriptionStorage.HandleAdministrativeMessage;
Message msg = new MessageBuilder
(serializer).GenerateMsmqMessageFromMessageBatch(new
AddInstanceSubscription
{
Endpoint = queueEndpoint.Uri.ToString(),
InstanceSubscriptionKey = id,
Type = typeof (TestMessage2).FullName,
});
send(msg);
wait.WaitOne();
msg = new MessageBuilder
(serializer).GenerateMsmqMessageFromMessageBatch(new
RemoveInstanceSubscription
{
Endpoint = queueEndpoint.Uri.ToString(),
InstanceSubscriptionKey = id,
Type = typeof (TestMessage2).FullName,
});
wait.Reset();
send(msg);
wait.WaitOne();
IEnumerable<Uri> uris = subscriptionStorage
.GetSubscriptionsFor(typeof (TestMessage2));
Assert.Equal(0, uris.Count());
int count = 0;
MessageEnumerator copy = enumer();
while (copy.MoveNext()) count++;
Assert.Equal(0, count);
}
示例2: RemoteServiceInterceptor
/// <summary>
/// 初始化
/// </summary>
/// <param name="endpoint"></param>
public RemoteServiceInterceptor(Endpoint endpoint)
: this(endpoint
, endpoint.Resolve<ILoggerFactory>()
, endpoint.Resolve<ISerializer>()
, endpoint.Resolve<ILoadBalancingHelper>())
{
}
示例3: SendMessageAsync
private async Task SendMessageAsync(Mocks.CloudBlobStorageProviderMock cloudStorage, Mocks.InboxHttpHandlerMock inboxMock, CryptoSettings senderCrypto, OwnEndpoint senderEndpoint, Endpoint receiverEndpoint)
{
Requires.NotNull(cloudStorage, "cloudStorage");
Requires.NotNull(senderCrypto, "senderCrypto");
Requires.NotNull(senderEndpoint, "senderEndpoint");
Requires.NotNull(receiverEndpoint, "receiverEndpoint");
var httpHandler = new Mocks.HttpMessageHandlerMock();
cloudStorage.AddHttpHandler(httpHandler);
inboxMock.Register(httpHandler);
var sentMessage = Valid.Message;
var channel = new Channel()
{
HttpClient = new HttpClient(httpHandler),
CloudBlobStorage = cloudStorage,
CryptoServices = senderCrypto,
Endpoint = senderEndpoint,
Logger = this.logger,
};
await channel.PostAsync(sentMessage, new[] { receiverEndpoint }, Valid.ExpirationUtc);
}
示例4: GetQueuePath
public static QueueInfo GetQueuePath(Endpoint endpoint)
{
var uri = endpoint.Uri;
if (uri.AbsolutePath.IndexOf("/", 1) >= 0)
{
throw new InvalidOperationException(
"Invalid enpoint url : " + uri + Environment.NewLine +
"Queue Endpoints can't have a child folders (including 'public')" + Environment.NewLine +
"Good: 'msmq://machinename/queue_name'." + Environment.NewLine +
" Bad: msmq://machinename/round_file/queue_name"
);
}
string hostName = uri.Host;
string queuePathWithFlatSubQueue =
uri.AbsolutePath.Substring(1);
if (string.IsNullOrEmpty(uri.Fragment) == false && uri.Fragment.Length > 1)
queuePathWithFlatSubQueue += uri.Fragment;
if (string.Compare(hostName, ".") == 0 ||
string.Compare(hostName, Environment.MachineName, true) == 0 ||
string.Compare(hostName, "localhost", true) == 0)
{
return new QueueInfo
{
IsLocal = true,
QueuePath = Environment.MachineName + @"\private$\" + queuePathWithFlatSubQueue,
QueueUri = uri,
Transactional = endpoint.Transactional
};
}
IPAddress address;
if (IPAddress.TryParse(hostName, out address))
{
return new QueueInfo
{
IsLocal = false,
QueuePath = "FormatName:DIRECT=TCP:" + hostName + @"\private$\" + queuePathWithFlatSubQueue,
QueueUri = uri,
Transactional = endpoint.Transactional
};
}
if (guidRegEx.IsMatch(hostName))
{
return new QueueInfo
{
IsLocal = false,
QueuePath = "FormatName:PRIVATE=" + hostName + @"\" + queuePathWithFlatSubQueue,
QueueUri = uri,
Transactional = endpoint.Transactional
};
}
return new QueueInfo
{
IsLocal = false,
QueuePath = "FormatName:DIRECT=OS:" + hostName + @"\private$\" + queuePathWithFlatSubQueue,
QueueUri = uri,
Transactional = endpoint.Transactional
};
}
示例5: EndpointSendAndReceive
public void EndpointSendAndReceive()
{
using (var management = new RabbitMqEndpointManagement(_queue))
{
management.BindQueue(_queue.Name, _exchange.Name, ExchangeType.Fanout, "", null);
}
IMessageSerializer serializer = new XmlMessageSerializer();
var message = new BugsBunny {Food = "Carrot"};
IDuplexTransport transport = _factory.BuildLoopback(new TransportSettings(_exchange));
IOutboundTransport error = _factory.BuildError(new TransportSettings(_error));
var sendEndpoint = new Endpoint(_exchange, serializer, transport, error,
new InMemoryInboundMessageTracker(5));
sendEndpoint.Send(message);
var receiveEndpoint = new Endpoint(_queue, serializer, transport, error,
new InMemoryInboundMessageTracker(5));
receiveEndpoint.Receive(o =>
{
return b =>
{
var bb = (BugsBunny)b;
Console.WriteLine(bb.Food);
};
}, TimeSpan.Zero);
}
示例6: Put
public HttpResponseMessage Put(Endpoint endpoint)
{
try
{
if (endpoint == null)
throw WebException(Constants.ErrorParameterEndpointCannotBeNull, HttpStatusCode.BadRequest);
// Set the username under which the app will store the channel
endpoint.UserId = this.mapUsernameDelegate(this.Request);
if (endpoint.ExpirationTime == null || endpoint.ExpirationTime == DateTime.MinValue)
endpoint.ExpirationTime = DateTime.UtcNow.Add(defaultEndpointExpirationTime);
this.Repository.InsertOrUpdate(endpoint);
return new HttpResponseMessage(HttpStatusCode.Accepted);
}
catch (HttpResponseException)
{
throw;
}
catch (Exception exception)
{
throw WebException(exception.Message, HttpStatusCode.InternalServerError);
}
}
示例7: Run
public void Run()
{
while (true)
{
var url = Console.ReadLine();
if (url == null)
{
break;
}
url = url.Trim();
if (!string.IsNullOrEmpty(url))
{
try
{
var endPoint = new Endpoint(url);
var output = this.dispatcher.DispatchAction(endPoint);
Console.WriteLine(output);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
示例8: Configure
public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
{
var busConfig = config as RhinoServiceBusConfiguration;
if (busConfig == null)
return;
var busElement = config.ConfigurationSection.Bus;
if (busElement == null)
return;
var loadBalancerEndpointAsString = busElement.LoadBalancerEndpoint;
if (string.IsNullOrEmpty(loadBalancerEndpointAsString))
return;
Uri loadBalancerEndpoint;
if (!Uri.TryCreate(loadBalancerEndpointAsString, UriKind.Absolute, out loadBalancerEndpoint))
throw new ConfigurationErrorsException(
"Attribute 'loadBalancerEndpoint' on 'bus' has an invalid value '" + loadBalancerEndpointAsString + "'");
var endpoint = new Endpoint { Uri = loadBalancerEndpoint };
builder.RegisterLoadBalancerEndpoint(endpoint.Uri);
config.AddMessageModule<LoadBalancerMessageModule>();
}
示例9: InitializeQueue
public MessageQueue[] InitializeQueue(Endpoint queueEndpoint, QueueType queueType)
{
var queue = MsmqUtil.GetQueuePath(queueEndpoint).Create();
switch (queueType)
{
case QueueType.Standard:
return new[]
{
queue,
MsmqUtil.OpenOrCreateQueue(GetErrorsQueuePath(), QueueAccessMode.SendAndReceive, queue),
MsmqUtil.OpenOrCreateQueue(GetSubscriptionQueuePath(), QueueAccessMode.SendAndReceive, queue),
MsmqUtil.OpenOrCreateQueue(GetDiscardedQueuePath(), QueueAccessMode.SendAndReceive, queue),
MsmqUtil.OpenOrCreateQueue(GetTimeoutQueuePath(), QueueAccessMode.SendAndReceive, queue),
};
case QueueType.LoadBalancer:
return new[]
{
queue,
MsmqUtil.OpenOrCreateQueue(GetKnownWorkersQueuePath(), QueueAccessMode.SendAndReceive, queue),
MsmqUtil.OpenOrCreateQueue(GetKnownEndpointsQueuePath(), QueueAccessMode.SendAndReceive, queue),
};
case QueueType.Raw:
return new[]
{
queue,
};
default:
throw new ArgumentOutOfRangeException("queueType", "Can't handle queue type: " + queueType);
}
}
示例10: Create
public Binding Create(Endpoint serviceInterface)
{
System.Net.ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate, chain, sslPolicyErrors) => true);
var secureBinding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential)
{
Name = "secure",
TransactionFlow = false,
HostNameComparisonMode = serviceInterface.HostNameComparisonMode.ParseAsEnum(HostNameComparisonMode.StrongWildcard),
MaxBufferPoolSize = serviceInterface.MaxBufferPoolSize,
MaxReceivedMessageSize = serviceInterface.MaxReceivedSize,
MessageEncoding = serviceInterface.MessageFormat.ParseAsEnum(WSMessageEncoding.Text),
TextEncoding = Encoding.UTF8,
ReaderQuotas = XmlDictionaryReaderQuotas.Max,
BypassProxyOnLocal = true,
UseDefaultWebProxy = false
};
if (ConfigurationManagerHelper.GetValueOnKey("stardust.UseDefaultProxy")=="true")
{
secureBinding.BypassProxyOnLocal = false;
secureBinding.UseDefaultWebProxy = true;
}
SetSecuritySettings(serviceInterface, secureBinding);
return secureBinding;
}
示例11: EndpointDetails
private EndpointDetails(Endpoint endpoint)
{
Id = endpoint.Identity.Id;
Address = endpoint.Identity.Address;
MonitorType = endpoint.Identity.MonitorType;
Name = endpoint.Metadata.Name;
Group = endpoint.Metadata.Group;
var health = endpoint.Health;
LastModifiedTime = endpoint.LastModifiedTimeUtc;
if (health != null)
{
Status = health.Status;
LastCheckUtc = health.CheckTimeUtc;
LastResponseTime = health.ResponseTime;
Details = health.Details.ToDictionary(p => p.Key, p => p.Value);
}
else
{
Details = new Dictionary<string, string>();
Status = EndpointStatus.NotRun;
}
Tags = endpoint.Metadata.Tags;
RegisteredOnUtc = endpoint.Metadata.RegisteredOnUtc;
RegistrationUpdatedOnUtc = endpoint.Metadata.RegistrationUpdatedOnUtc;
MonitorTag = endpoint.Metadata.MonitorTag;
}
示例12: DefaultContactCtor
public void DefaultContactCtor() {
var contact = new Endpoint();
Assert.That(contact.MessageReceivingEndpoint, Is.Null);
Assert.That(contact.EncryptionKeyPublicMaterial, Is.Null);
Assert.That(contact.SigningKeyPublicMaterial, Is.Null);
Assert.That(contact.CreatedOnUtc, Is.EqualTo(DateTime.UtcNow).Within(TimeSpan.FromMinutes(1)));
}
示例13: MsmqFlatQueueTestBase
public MsmqFlatQueueTestBase()
{
defaultTestBase = new MsmqTestBase();
testQueueEndPoint = new Endpoint
{
Uri = new Uri("msmq://localhost/test_queue")
};
testQueuePath = MsmqUtil.GetQueuePath(testQueueEndPoint).QueuePath;
transactionalTestQueueEndpoint = new Endpoint
{
Uri = new Uri("msmq://localhost/transactional_test_queue")
};
transactionalTestQueuePath = MsmqUtil.GetQueuePath(transactionalTestQueueEndpoint).QueuePath;
subscriptionsEndpoint = new Endpoint
{
Uri = new Uri(testQueueEndPoint.Uri + "#" + subscriptions)
};
subscriptionQueuePath = MsmqUtil.GetQueuePath(subscriptionsEndpoint).QueuePath;
SetupQueues();
queue = MsmqUtil.GetQueuePath(testQueueEndPoint).Open();
transactionalQueue = MsmqUtil.GetQueuePath(transactionalTestQueueEndpoint).Open();
subscriptions = MsmqUtil.GetQueuePath(subscriptionsEndpoint).Open(QueueAccessMode.SendAndReceive,
new XmlMessageFormatter(new[]
{
typeof (string)
}));
}
示例14: Create
public Binding Create(Endpoint serviceInterface)
{
var binding = new BasicHttpBinding
{
Name = serviceInterface.EndpointName,
AllowCookies = false,
HostNameComparisonMode = serviceInterface.HostNameComparisonMode.ParseAsEnum(HostNameComparisonMode.StrongWildcard),
MaxBufferPoolSize = serviceInterface.MaxBufferPoolSize,
MaxReceivedMessageSize = serviceInterface.MaxReceivedSize,
MessageEncoding = serviceInterface.MessageFormat.ParseAsEnum(WSMessageEncoding.Mtom),
MaxBufferSize = serviceInterface.MaxBufferSize,
TransferMode = TransferMode.Streamed,
TextEncoding = Encoding.UTF8,
ReaderQuotas = XmlDictionaryReaderQuotas.Max,
BypassProxyOnLocal = true,
UseDefaultWebProxy = false,
};
if (ConfigurationManagerHelper.GetValueOnKey("stardust.UseDefaultProxy") == "true")
{
binding.BypassProxyOnLocal = false;
binding.UseDefaultWebProxy = true;
}
return binding;
}
示例15: Main
static void Main(string[] args)
{
LogFactory.BuildLogger = type => new ConsoleWindowLogger(type);
ConsoleWindowLogger.MinimumLogLevel = LogLevel.Info;
var endpoint = new Endpoint();
endpoint.Start();
using (var scope = Settings.RootContainer.BeginLifetimeScope())
{
var dtoCompanyQueryService = scope.GetInstance<DtoCompanyQueryService>();
var dtoEmployeeQueryService = scope.GetInstance<DtoEmployeeQueryService>();
var googlePage = dtoCompanyQueryService
.Query
.Where(c => c.Employees.Any(employee => employee.Name.Contains("Smith")))
.OrderBy(company => company.Name).FetchPage(1, 10);
var firstCompanyDto = dtoCompanyQueryService.Query.First();
var companiesWithMoreThanTwoEmployees = dtoCompanyQueryService.Query.Where(company => company.Employees.Count > 2).ToArray();
var ordered = dtoCompanyQueryService.Query
.OrderByDescending(company => company.Employees.Count)
.ThenByDescending(company => company.Name)
.ToArray();
dtoEmployeeQueryService.Query.FirstOrDefault(employee => employee.Name.Length > 2);
}
}