Пример #1
0
        public List <Meter> FindByPortTypeAndFlow(
            string portType,
            int flow = -1)
        {
            List <string> portTypes;
            List <Meter>  meters;

            bool isNumeric = MeterAux.GetPortTypes(portType, out portTypes);

            if (isNumeric)
            {
                // portType match and no flow match required
                // OR
                // portType match and flow match
                meters = Meters.FindAll(m => portTypes.Contains(m.Id.ToString()) && ((flow <= -1) || m.Flow.Equals(flow)));
            }
            else
            {
                // portType match and no flow match required
                // OR
                // portType match and flow match
                meters = Meters.FindAll(m => MatchMeterTypes(portTypes, m) && ((flow <= -1) || m.Flow.Equals(flow)));
            }
            return(meters);
        }
Пример #2
0
        public List <string> GetPortTypes(out bool isNumeric)
        {
            List <string> types;

            isNumeric = MeterAux.GetPortTypes(this.Type, out types);

            return(types);
        }
Пример #3
0
        private bool MatchMeterTypes(List <string> mtuMeterTypes, Meter meter) //List<string> meterTypes)
        {
            List <string> meterTypes = new List <string>();

            if (MeterAux.IsStringPortType(meter.Type))
            {
                meterTypes.Add(meter.Type);
            }
            else
            {
                foreach (char c in meter.Type)
                {
                    meterTypes.Add(c.ToString());
                }
            }

            IEnumerable <string> r = mtuMeterTypes.Intersect(meterTypes);
            bool match             = r.Count() > 0;

            return(match);
        }