//****************************************************************************************************** // RegistrationInfo.cs - Gbtc // // Copyright © 2012, Grid Protection Alliance. All Rights Reserved. // // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See // the NOTICE file distributed with this work for additional information regarding copyright ownership. // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may // not use this file except in compliance with the License. You may obtain a copy of the License at: // // http://www.opensource.org/licenses/MIT // // Unless agreed to in writing, the subject software distributed under the License is distributed on an // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the // License for the specific language governing permissions and limitations. // // Code Modification History: // ---------------------------------------------------------------------------------------------------- // 10/19/2010 - Pinal C. Patel // Generated original version of source code. // 02/03/2011 - Pinal C. Patel // Added LatestMessage field to save the very latest message distributed out to subscribers. // 12/20/2012 - Starlynn Danyelle Gilliam // Modified Header. // //****************************************************************************************************** using System; using System.Collections.Generic; using System.Runtime.Serialization; using System.Threading; namespace GSF.ServiceBus { /// /// Represents information about a registration with the to produce/consume s. /// [DataContract] public class RegistrationInfo : IDisposable { #region [ Members ] // Fields private bool m_disposed; /// /// Gets or sets the type for s being produced/consumed. /// [DataMember] public MessageType MessageType; /// /// Gets or sets the name for s being produced/consumed. /// [DataMember] public string MessageName; /// /// Gets or sets the total number of s received. /// [DataMember] public long MessagesReceived; /// /// Gets or sets the total number of s distributed. /// [DataMember] public long MessagesProcessed; /// /// Gets or sets the list of clients producing the s. /// [DataMember] public List Producers; /// /// Gets or sets the list of clients consuming the s. /// [DataMember] public List Consumers; /// /// Gets or sets the latest distributed to the subscribers. /// public Message LatestMessage; /// /// Gets the to be used for synchronized access to . /// public readonly ReaderWriterLockSlim ProducersLock; /// /// Gets the to be used for synchronized access to . /// public readonly ReaderWriterLockSlim ConsumersLock; #endregion #region [ Constructors ] /// /// Initializes a new instance of the class. /// /// An object. internal RegistrationInfo(RegistrationRequest request) { MessageType = request.MessageType; MessageName = request.MessageName; Producers = new List(); Consumers = new List(); ProducersLock = new ReaderWriterLockSlim(); ConsumersLock = new ReaderWriterLockSlim(); } /// /// Releases the unmanaged resources before the object is reclaimed by . /// ~RegistrationInfo() { Dispose(false); } #endregion #region [ Properties ] #endregion #region [ Methods ] /// /// Releases all the resources used by the object. /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } /// /// Releases the unmanaged resources used by the object and optionally releases the managed resources. /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. protected virtual void Dispose(bool disposing) { if (!m_disposed) { try { // This will be done regardless of whether the object is finalized or disposed. if (disposing) { // This will be done only when the object is disposed by calling Dispose(). if (ProducersLock != null) ProducersLock.Dispose(); if (ConsumersLock != null) ConsumersLock.Dispose(); } } finally { m_disposed = true; // Prevent duplicate dispose. } } } #endregion } }