Пример #1
0
        /// <summary>Adds the counter to the set that the EventSource will report on.</summary>
        /// <remarks>
        /// Must only be invoked once, and only after the instance has been fully initialized.
        /// This should be invoked by a derived type's ctor as the last thing it does.
        /// </remarks>
        private protected void Publish()
        {
            Debug.Assert(_group is null);
            Debug.Assert(Name != null);
            Debug.Assert(EventSource != null);

            _group = CounterGroup.GetCounterGroup(EventSource);
            _group.Add(this);
        }
Пример #2
0
        /// <summary>
        /// All Counters live as long as the EventSource that they are attached to unless they are
        /// explicitly Disposed.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="eventSource">The event source.</param>
        internal DiagnosticCounter(string name, EventSource eventSource)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(Name));
            }

            if (eventSource == null)
            {
                throw new ArgumentNullException(nameof(EventSource));
            }

            _group = CounterGroup.GetCounterGroup(eventSource);
            _group.Add(this);
            Name        = name;
            EventSource = eventSource;
        }
Пример #3
0
        /// <summary>
        /// All Counters live as long as the EventSource that they are attached to unless they are
        /// explicitly Disposed.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="eventSource">The event source.</param>
        public BaseCounter(string name, EventSource eventSource)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(_name));
            }

            if (eventSource == null)
            {
                throw new ArgumentNullException(nameof(eventSource));
            }

            _group = CounterGroup.GetCounterGroup(eventSource);
            _group.Add(this);
            _eventSource = eventSource;
            _name        = name;
            _metaData    = new Dictionary <string, string>();
        }