/// <summary> /// Called when a subscription object is disposed. /// </summary> /// <param name="subscription"></param> internal void SubscriptionDisposed(TsCAeSubscription subscription) { if (!disposing_) { subscriptions_.Remove(subscription); } }
/// <summary> /// Returns an unconnected copy of the subscription with the same items. /// </summary> public virtual object Clone() { // do a memberwise clone. TsCAeSubscription clone = (TsCAeSubscription)MemberwiseClone(); /* * // place clone in disconnected state. * clone.server = null; * clone.subscription = null; * clone.state = (SubscriptionState)state.Clone(); * * // clear server handles. * clone.state.ServerHandle = null; * * // always make cloned subscriptions inactive. * clone.state.Active = false; * * // clone items. * if (clone.items != null) * { * ArrayList items = new ArrayList(); * * foreach (Item item in clone.items) * { * items.Add(item.Clone()); * } * * clone.items = (Item[])items.ToArray(typeof(Item)); * } */ // return clone. return(clone); }
/// <summary> /// Adds a subscription to the end of the collection. /// </summary> internal void Add(Ae.TsCAeSubscription subscription) { TsCAeSubscription[] array = new TsCAeSubscription[Count + 1]; Array.CopyTo(array, 0); array[Count] = subscription; Array = array; }
/// <summary> /// Establishes a subscription based on the template provided. /// </summary> private TsCAeSubscription EstablishSubscription(TsCAeSubscription template) { ITsCAeSubscription remoteServer = null; try { // create remote object. remoteServer = ((ITsCAeServer)Server).CreateSubscription(template.State); if (remoteServer == null) { return(null); } // create wrapper. TsCAeSubscription subscription = new TsCAeSubscription(this, remoteServer, template.State); // set filters. subscription.SetFilters(template.Filters); // set attributes. IDictionaryEnumerator enumerator = template.Attributes.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Key != null) { subscription.SelectReturnedAttributes( (int)enumerator.Key, ((TsCAeSubscription.AttributeCollection)enumerator.Value).ToArray()); } } // return new subscription return(subscription); } catch { if (remoteServer != null) { remoteServer.Dispose(); } } // return null. return(null); }
/// <summary> /// Removes a subscription to the from the collection. /// </summary> internal void Remove(Ae.TsCAeSubscription subscription) { TsCAeSubscription[] array = new TsCAeSubscription[Count - 1]; int index = 0; for (int ii = 0; ii < Array.Length; ii++) { TsCAeSubscription element = (TsCAeSubscription)Array.GetValue(ii); if (subscription != element) { array[index++] = element; } } Array = array; }
/// <summary> /// Creates a new event subscription. /// </summary> /// <param name="state">The initial state for the subscription.</param> /// <returns>The new subscription object.</returns> public ITsCAeSubscription CreateSubscription(TsCAeSubscriptionState state) { LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); if (Server == null) { throw new NotConnectedException(); } // create remote object. ITsCAeSubscription subscription = ((ITsCAeServer)Server).CreateSubscription(state); if (subscription != null) { // create wrapper. var wrapper = new TsCAeSubscription(this, subscription, state); subscriptions_.Add(wrapper); return(wrapper); } // should never happen. return(null); }