Пример #1
0
 internal MetricsMap(MetricsMap <T> map)
 {
     _properties        = map._properties;
     _groupByAttributes = map._groupByAttributes;
     _groupBySeparators = map._groupBySeparators;
     _retain            = map._retain;
     _accept            = map._accept;
     _reject            = map._reject;
     _subMaps           = map._subMaps;
 }
Пример #2
0
 public MetricsMap <T> .Entry getEntry(MetricsMap <T> map)
 {
     foreach (MetricsMap <T> .Entry e in _objects)
     {
         if (e.getMap() == map)
         {
             return(e);
         }
     }
     return(null);
 }
Пример #3
0
        public O getObserver(MetricsHelper <T> helper, object observer)
        {
            lock (this)
            {
                List <MetricsMap <T> .Entry> metricsObjects = null;
                O old = null;
                try
                {
                    old = (O)observer;
                }
                catch (InvalidCastException)
                {
                }
                foreach (MetricsMap <T> m in _maps)
                {
                    MetricsMap <T> .Entry e = m.getMatching(helper, old != null ? old.getEntry(m) : null);
                    if (e != null)
                    {
                        if (metricsObjects == null)
                        {
                            metricsObjects = new List <MetricsMap <T> .Entry>(_maps.Count);
                        }
                        metricsObjects.Add(e);
                    }
                }

                if (metricsObjects == null)
                {
                    if (old != null)
                    {
                        old.detach();
                    }
                    return(null);
                }

                O obsv;
                try
                {
                    obsv = new O();
                }
                catch (Exception)
                {
                    Debug.Assert(false);
                    return(null);
                }
                obsv.init(helper, metricsObjects, old);
                return(obsv);
            }
        }
Пример #4
0
        public ObserverImpl getObserver <S, ObserverImpl>(string mapName, MetricsHelper <S> helper)
            where S : Metrics, new()
            where ObserverImpl : Observer <S>, new()
        {
            List <MetricsMap <S> .Entry> metricsObjects = null;

            foreach (MetricsMap <T> .Entry entry in _objects)
            {
                MetricsMap <S> .Entry e = entry.getMatching(mapName, helper);
                if (e != null)
                {
                    if (metricsObjects == null)
                    {
                        metricsObjects = new List <MetricsMap <S> .Entry>(_objects.Count);
                    }
                    metricsObjects.Add(e);
                }
            }

            if (metricsObjects == null)
            {
                return(null);
            }

            try
            {
                ObserverImpl obsv = new ObserverImpl();
                obsv.init(helper, metricsObjects, null);
                return(obsv);
            }
            catch (Exception)
            {
                Debug.Assert(false);
                return(null);
            }
        }
Пример #5
0
        internal ObserverImpl?GetObserver <S, ObserverImpl>(string mapName, MetricsHelper <S> helper)
            where S : Metrics, new()
            where ObserverImpl : Observer <S>, new()
        {
            List <MetricsMap <S> .Entry>?metricsObjects = null;

            foreach (MetricsMap <T> .Entry entry in _entries !)
            {
                MetricsMap <S> .Entry?e = entry.GetMatching(mapName, helper);
                if (e != null)
                {
                    if (metricsObjects == null)
                    {
                        metricsObjects = new List <MetricsMap <S> .Entry>(_entries.Count);
                    }
                    metricsObjects.Add(e);
                }
            }

            if (metricsObjects == null)
            {
                return(null);
            }

            try
            {
                var obsv = new ObserverImpl();
                obsv.Init(metricsObjects, null);
                return(obsv);
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.ToString());
                return(null);
            }
        }
Пример #6
0
        internal O?GetObserver(MetricsHelper <T> helper, object?observer)
        {
            lock (_mutex)
            {
                List <MetricsMap <T> .Entry>?metricsObjects = null;
                var old = observer as O;

                foreach (MetricsMap <T> m in _maps)
                {
                    MetricsMap <T> .Entry?e = m.GetMatching(helper, old?.GetEntry(m));
                    if (e != null)
                    {
                        metricsObjects ??= new List <MetricsMap <T> .Entry>(_maps.Count);
                        metricsObjects.Add(e);
                    }
                }

                if (metricsObjects == null)
                {
                    old?.Detach();
                    return(null);
                }

                try
                {
                    var obsv = new O();
                    obsv.Init(metricsObjects, old);
                    return(obsv);
                }
                catch (Exception ex)
                {
                    Debug.Assert(false, ex.ToString());
                    return(null);
                }
            }
        }
Пример #7
0
 internal Entry(MetricsMap <T> map, T obj)
 {
     _map    = map;
     _object = obj;
 }
Пример #8
0
 internal MetricsMap <T> .Entry?GetEntry(MetricsMap <T> map) => _entries !.FirstOrDefault(entry => entry.Map == map);