Пример #1
0
 public PremiseCommand(PremiseObject holdingObject, string propertyName) {
     _holdingObject = holdingObject;
     _propertyName = propertyName;
 }
Пример #2
0
 /// <summary>
 /// Send an unsubscribe request to the server.
 /// </summary>
 /// <param name="po"></param>
 /// <param name="propertyName"></param>
 public async Task Unsubscribe(PremiseObject po, string propertyName) {
     try {
         // Find subscription 
         foreach (var subscription in _subscriptions) {
             if (subscription.Value.PropertyName == propertyName &&
                 subscription.Value.Object.Location == po.Location) {
                 _subscriptions.Remove(subscription.Key);
                 string command = "?c?" + subscription.Key;
                 if (FastMode)
                     await SendRequestFastMode(command);
                 else {
                     await SendRequest(command);
                 }
                 return;
             }
         }
     }
     catch (Exception ex) {
         Dispose();
         throw ex;
     }
 }
Пример #3
0
 // Default implementation of method to set an object property's value
 // Assumes same thread.
 public void DispatchSetMember(PremiseObject obj, string propertyName, string value) {
     obj.SetMember(propertyName, value, false);
 }
Пример #4
0
        /// <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;
            }
        }