internal Collection <PSTraceSource> ConfigureTraceSource(string[] sourceNames, bool preConfigure, out Collection <PSTraceSource> preconfiguredSources)
        {
            preconfiguredSources = new Collection <PSTraceSource>();
            Collection <string>        notMatched      = null;
            Collection <PSTraceSource> matchingSources = base.GetMatchingTraceSource(sourceNames, false, out notMatched);

            if (preConfigure)
            {
                if (this.optionsSpecified)
                {
                    this.SetFlags(matchingSources);
                }
                this.AddTraceListenersToSources(matchingSources);
                this.SetTraceListenerOptions(matchingSources);
            }
            foreach (string str in notMatched)
            {
                if (!string.IsNullOrEmpty(str) && !WildcardPattern.ContainsWildcardCharacters(str))
                {
                    PSTraceSource item = PSTraceSource.GetNewTraceSource(str, string.Empty, true);
                    preconfiguredSources.Add(item);
                }
            }
            if (preconfiguredSources.Count > 0)
            {
                if (preConfigure)
                {
                    if (this.optionsSpecified)
                    {
                        this.SetFlags(preconfiguredSources);
                    }
                    this.AddTraceListenersToSources(preconfiguredSources);
                    this.SetTraceListenerOptions(preconfiguredSources);
                }
                foreach (PSTraceSource source2 in preconfiguredSources)
                {
                    if (!PSTraceSource.PreConfiguredTraceSource.ContainsKey(source2.Name))
                    {
                        PSTraceSource.PreConfiguredTraceSource.Add(source2.Name, source2);
                    }
                }
            }
            return(matchingSources);
        }
        internal Collection <PSTraceSource> ConfigureTraceSource(
            string[] sourceNames,
            bool preConfigure,
            out Collection <PSTraceSource> preconfiguredSources)
        {
            preconfiguredSources = new Collection <PSTraceSource>();

            // Find the matching and unmatched trace sources.

            Collection <string>        notMatched      = null;
            Collection <PSTraceSource> matchingSources = GetMatchingTraceSource(sourceNames, false, out notMatched);

            if (preConfigure)
            {
                // Set the flags if they were specified
                if (optionsSpecified)
                {
                    SetFlags(matchingSources);
                }

                AddTraceListenersToSources(matchingSources);
                SetTraceListenerOptions(matchingSources);
            }

            // Now try to preset options for sources which have not yet been
            // constructed.

            foreach (string notMatchedName in notMatched)
            {
                if (string.IsNullOrEmpty(notMatchedName))
                {
                    continue;
                }

                if (WildcardPattern.ContainsWildcardCharacters(notMatchedName))
                {
                    continue;
                }

                PSTraceSource newTraceSource =
                    PSTraceSource.GetNewTraceSource(
                        notMatchedName,
                        string.Empty,
                        true);

                preconfiguredSources.Add(newTraceSource);
            }

            // Preconfigure any trace sources that were not already present

            if (preconfiguredSources.Count > 0)
            {
                if (preConfigure)
                {
                    // Set the flags if they were specified
                    if (optionsSpecified)
                    {
                        SetFlags(preconfiguredSources);
                    }

                    AddTraceListenersToSources(preconfiguredSources);
                    SetTraceListenerOptions(preconfiguredSources);
                }

                // Add the sources to the preconfigured table so that they are found
                // when the trace source finally gets created by the system.

                foreach (PSTraceSource sourceToPreconfigure in preconfiguredSources)
                {
                    if (!PSTraceSource.PreConfiguredTraceSource.ContainsKey(sourceToPreconfigure.Name))
                    {
                        PSTraceSource.PreConfiguredTraceSource.Add(sourceToPreconfigure.Name, sourceToPreconfigure);
                    }
                }
            }

            return(matchingSources);
        }