public override void WriteLine(string message)
        {
            ProbeHistory probeHistory;

            if (!_probeStates.TryGetValue("(Console)", out probeHistory))
            {
                ProbeInfo probeInfo = new ProbeInfo();
                probeInfo.Name = "(Console)";
                if (_probes.Probes == null)
                {
                    _probes.Probes = new List <ProbeInfo>();
                }
                _probes.Probes.Add(probeInfo);

                probeHistory         = new ProbeHistory();
                probeHistory.Name    = "(Console)";
                probeHistory.History = new List <ProbeState>();
                _probeStates.Add(probeHistory.Name, probeHistory);
            }

            ProbeState probeState = new ProbeState();

            probeState.Timestamp = DateTime.Now.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ss");
            probeState.Message   = message;
            AddProbeState(probeState, ref probeHistory);
        }
Exemple #2
0
        public override bool Equals(Object obj)
        {
            ProbeInfo otherProbe = obj as ProbeInfo;

            if (otherProbe == null)
            {
                return(false);
            }

            return(Name == otherProbe.Name);
        }
        void AddProbeState(ProbeState probeState, ref ProbeHistory probeHistory)
        {
            probeHistory.History.Insert(0, probeState);
            probeHistory.History.RemoveAll(delegate(ProbeState state) { return(DateTime.Now.Subtract(DateTime.Parse(state.Timestamp)) > TimeSpan.FromDays(1)); });
            string    name      = probeHistory.Name;
            ProbeInfo probeInfo = _probes.Probes.Find(delegate(ProbeInfo probe) { return(probe.Name == name); });

            if (probeInfo != null)
            {
                probeInfo.UpdateState(probeState);
            }
        }
        public void RegisterProbe(TraceSource probe)
        {
            probe.Listeners.Add(this);

            ProbeInfo probeInfo = new ProbeInfo();

            probeInfo.Name = probe.Name;
            if (_probes.Probes == null)
            {
                _probes.Probes = new List <ProbeInfo>();
            }
            _probes.Probes.Add(probeInfo);

            ProbeHistory probeHistory = new ProbeHistory();

            probeHistory.Name    = probe.Name;
            probeHistory.History = new List <ProbeState>();
            _probeStates.Add(probe.Name, probeHistory);
        }