/// <summary>
        /// This method adds a new resource statistic unless is already exists, in which case it returns the existing one.
        /// </summary>
        /// <param name="profile">The resource profile to return.</param>
        /// <returns>Returns the associated Resource Statistic.</returns>
        protected ResourceStatistics ResourceStatisticsCreateOrGet(ResourceProfile profile)
        {
            ResourceStatistics stats = mResources.GetOrAdd(profile.Id, new ResourceStatistics(signal: ResourceStatisticsSignal)
            {
                Name = profile.Id
            });

            return(stats);
        }
        /// <summary>
        /// This method is used to signal a Resource state change and publish this to the DataCollector..
        /// </summary>
        /// <param name="type">The resource event type.</param>
        /// <param name="stats">The current statistics.</param>
        private void ResourceStatisticsSignal(ResourceStatisticsEventType type, ResourceStatistics stats)
        {
            switch (type)
            {
            case ResourceStatisticsEventType.Created:
                Collector?.Write(new ResourceEvent()
                {
                    Type = type, Name = stats.Name
                });
                break;

            case ResourceStatisticsEventType.KeepAlive:
                var re = new ResourceEvent()
                {
                    Type = type, Name = stats.Name
                };
                Collector?.Write(re);
                break;
            }
        }
 /// <summary>
 /// This is the default constructor.
 /// </summary>
 /// <param name="resource">The resource.</param>
 /// <param name="name">The reference name.</param>
 public ResourceConsumer(ResourceStatistics resource, string name)
 {
     Name      = name;
     mResource = resource;
 }