Beispiel #1
0
        internal static SourceState GetSourceState(string fullyQualifiedReference)
        {
            SourceState sourceState = GetSourceStateFromCache(fullyQualifiedReference);

            if (sourceState == null)
            {
                // Create the source.

                sourceState = CreateSourceState(fullyQualifiedReference);

                // Cache it so that next time it is available.

                Lock.AcquireWriterLock(Timeout.Infinite);
                try
                {
                    SourceStates[fullyQualifiedReference] = sourceState;
                }
                finally
                {
                    Lock.ReleaseWriterLock();
                }
            }

            return(sourceState);
        }
Beispiel #2
0
        internal static void SourceDeleted(string fullyQualifiedReference)
        {
            SourceState sourceState = GetSourceStateFromCache(fullyQualifiedReference);

            if (sourceState == null)
            {
                return;                 // Not cached, so nothing to update.
            }
            // Set the cached SourceState properties to the default values.

            sourceState.SetMessageHandler(CreateMessageHandler(fullyQualifiedReference));
            sourceState.SetEventStatus(_defaultEventStatus);
        }
Beispiel #3
0
        internal static void SourceCreated(string fullyQualifiedReference)
        {
            SourceState sourceState = GetSourceStateFromCache(fullyQualifiedReference);

            if (sourceState == null)
            {
                return;                 // Not cached, so nothing to update.
            }
            // Update the cached SourceState properties from the catalogue (do not create a new SourceState
            // object, since user code may already hold references to it via EventSources).

            Source source = _catalogue.GetSearcher().GetSource(fullyQualifiedReference);

            if (source == null)
            {
                return;                 // Strange - the Source must have been created and immediately deleted.
            }
            // Update the Message Handler and event status.

            sourceState.SetMessageHandler(CreateMessageHandler(fullyQualifiedReference));
            sourceState.SetEventStatus(CreateEventStatus(source.GetEffectiveEnabledEvents()));
        }
Beispiel #4
0
        internal static void UpdateSource(string fullyQualifiedReference)
        {
            Debug.Assert(!string.IsNullOrEmpty(fullyQualifiedReference),
                         "fullyQualifiedReference != null && fullyQualifiedReference.Length > 0");

            // Find the SourceState object for this Source. The existing object must be updated (it cannot be
            // overwritten), because user code may already hold a reference to it via an EventSource.

            SourceState sourceState = GetSourceStateFromCache(fullyQualifiedReference);

            if (sourceState == null)
            {
                return;                 // This Source hasn't been created - nothing to update.
            }
            // Find the Source in the Catalogue.

            var source = _catalogue.GetSearcher().GetSource(fullyQualifiedReference);

            BitArray eventStatus = source == null ? _defaultEventStatus : CreateEventStatus(source.GetEffectiveEnabledEvents());

            sourceState.SetEventStatus(eventStatus);
        }