本文整理汇总了C#中Subscription.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Subscription.GetHashCode方法的具体用法?C# Subscription.GetHashCode怎么用?C# Subscription.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription.GetHashCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Subscribe
/// <summary>
/// Send a subscription request to the server.
/// </summary>
/// <param name="po">The object with the property to subscribe.</param>
/// <param name="propertyName">Name of the property to subscribe.</param>
public async Task Subscribe(PremiseObject po, string propertyName) {
try {
_readCts.Token.ThrowIfCancellationRequested();
// Ignore multiple subscripitons
if (_subscriptions.Any(subscription => subscription.Value.PropertyName == propertyName &&
subscription.Value.Object.Location == po.Location)) {
return;
}
var sub = new Subscription {Object = po, PropertyName = propertyName};
_subscriptions.Add(sub.GetHashCode(), sub);
await SendSubscriptionRequest(sub);
}
catch (Exception ex) {
Debug.WriteLine("Subscribe: " + ex.ToString());
Error = true;
LastError = ex.GetType().ToString();
LastErrorContent = ex.Message;
Dispose();
throw ex;
}
}
示例2: SendSubscriptionRequest
private async Task SendSubscriptionRequest(Subscription sub) {
try {
_readCts.Token.ThrowIfCancellationRequested();
if (String.IsNullOrEmpty(sub.Object.Location)) return;
// We send as <object>?a?<hashcode>??<property>?<hashcode>?
//
// It may not be necessary to set the <subid> (2nd to last param)
// but we do anyway.
var command = String.Format("{0}?a?{1}??{2}?{3}?",
sub.Object.Location, sub.GetHashCode(), sub.PropertyName,
sub.GetHashCode());
if (FastMode)
await SendRequestFastMode(command, "");
else {
await SendRequest(command, "");
}
sub.Active = true;
}
catch (Exception ex) {
Dispose();
throw ex;
}
}
示例3: Subscribe
/// <summary>
/// Send a subscription request to the server.
/// </summary>
/// <param name="po">The object with the property to subscribe.</param>
/// <param name="propertyName">Name of the property to subscribe.</param>
public async Task Subscribe(PremiseObject po, string propertyName) {
try {
Debug.Assert(_subscriptionClient != null);
// Ignore multiple subscripitons
foreach (var subscription in _subscriptions) {
if (subscription.Value.PropertyName == propertyName &&
subscription.Value.Object.Location == po.Location)
return;
}
Subscription sub = new Subscription {Object = po, PropertyName = propertyName};
_subscriptions.Add(sub.GetHashCode(), sub);
await SendSubscriptionRequest(sub);
}
catch (Exception ex) {
Dispose();
throw ex;
}
}