/// <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> /// Dispose(bool disposing) executes in two distinct scenarios. /// If disposing equals true, the method has been called directly /// or indirectly by a user's code. Managed and unmanaged resources /// can be disposed. /// If disposing equals false, the method has been called by the /// runtime from inside the finalizer and you should not reference /// other objects. Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing">If true managed and unmanaged resources can be disposed. If false only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!disposed_) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { if (subscription_ != null) { server_.SubscriptionDisposed(this); subscription_.Dispose(); } } // Release unmanaged resources. If disposing is false, // only the following code is executed. } disposed_ = true; }