Пример #1
0
        public static ExternalPortTypeFlags ToFlags(this IEnumerable <ExternalPortType> types)
        {
            ExternalPortTypeFlags res = 0;

            foreach (ExternalPortType t in types)
            {
                res |= t.ToFlag();
            }

            return(res);
        }
Пример #2
0
        public static List <ExternalPortType> ToExternalPortTypes(this ExternalPortTypeFlags type)
        {
            var res = new List <ExternalPortType>();

            var possibles = Enum.GetValues(typeof(ExternalPortType)).OfType <ExternalPortType>().ToArray();

            foreach (ExternalPortType e in possibles)
            {
                if ((type & e.ToFlag()) != 0)
                {
                    res.Add(e);
                }
            }

            if (res.Count == 0)
            {
                res.Add(0);
            }
            return(res);
        }