Ejemplo n.º 1
0
        public FileMonitoringProvider(IProviderSettings settings)
        {
            settings.ThrowIfNull(nameof(settings));

            var fileSettings = settings as IFileMonitoringProviderSettings;

            Debug.Assert(
                fileSettings != null,
                "The FileMonitoringProvider class expects configuration information "
                + "to be of IFileMonitoringProviderSettings type");

            ProviderSettings    = fileSettings;
            FileName            = fileSettings.FileName;
            Information         = settings.Info;
            refreshInterval     = fileSettings.RefreshPeriod;
            loadExistingContent = fileSettings.LoadExistingContent;
            patternMatching     = new Regex(fileSettings.MessageDecoder, RegexOptions.Singleline | RegexOptions.Compiled);

            PredetermineGroupNames(fileSettings.MessageDecoder);

            // Chain up callbacks to the workers.
            Worker.DoWork             += DoWork;
            Worker.RunWorkerCompleted += DoWorkComplete;
            PurgeWorker.DoWork        += PurgeWorkerDoWork;
        }
Ejemplo n.º 2
0
        public MsBuildProvider(IProviderSettings settings)
        {
            settings.ThrowIfNull(nameof(settings));

            Settings = settings as IMsBuildListenerSettings;
            Settings.ThrowIfNull(nameof(Settings));

            ProviderSettings = settings;
        }
Ejemplo n.º 3
0
        public NLogViewerProvider(IProviderSettings settings)
        {
            settings.ThrowIfNull(nameof(settings));

            networkSettings = settings as INLogAppenderSettings;
            networkSettings.ThrowIfNull(nameof(networkSettings));

            Information      = ProviderRegistrationInformation.Info;
            ProviderSettings = networkSettings;
        }
Ejemplo n.º 4
0
        public Log4NetProvider(IProviderSettings settings)
        {
            settings.ThrowIfNull(nameof(settings));

            udpSettings = settings as IUdpAppenderListenerSettings;
            udpSettings.ThrowIfNull(nameof(udpSettings));

            Information      = ProviderRegistrationInformation.Info;
            ProviderSettings = udpSettings;
        }
        public ILogProvider Create(Guid providerGuid, IProviderSettings settings)
        {
            settings.ThrowIfNull(nameof(settings));

            // Make sure we don't have any instances of that providerGuid.
            if (providerInstances.Any(p => p.Key == settings.Name && p.Value.Information.Identifier == providerGuid))
            {
                throw new ArgumentException(
                          "Already an instance of that ILoggerProvider with that name specified",
                          nameof(settings));
            }

            // Make sure that the type is supported.))
            if (providers.All(p => p.Identifier != providerGuid))
            {
                Trace.WriteLine("No provider with the identifier " + providerGuid + " is registered");
                return(null);
            }

            // Get an instance.
            var record = providers.FirstOrDefault(p => p.Identifier == providerGuid);

            if (record != null)
            {
                Debug.Assert(record.Implementer != null, "Need to know the implementing type for the provider");

                try
                {
                    var provider = (ILogProvider)Activator.CreateInstance(record.Implementer, settings);
                    providerInstances.Add(new KeyValuePair <string, ILogProvider>(settings.Name, provider));
                    return(provider);
                }
                catch (Exception e)
                {
                    Trace.TraceError(e.ToString());
                    Debugger.Break();
                }
            }

            return(null);
        }