当前位置: 首页>>代码示例>>C#>>正文


C# Subscription.GetHashCode方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:tig,项目名称:Premise,代码行数:28,代码来源:PremiseServer.cs

示例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;
            }
        }
开发者ID:tig,项目名称:Premise,代码行数:24,代码来源:PremiseServer.cs

示例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;
            }
        }
开发者ID:tig,项目名称:Premise,代码行数:26,代码来源:PremiseServer.cs


注:本文中的Subscription.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。