Пример #1
0
        private static Attribute[] GetAttributes(this FamilyCode code)
        {
            var fi = code.GetType().GetField(code.ToString());

            Attribute[] attributes = (Attribute[])fi.GetCustomAttributes(typeof(Attribute), false);

            return(attributes);
        }
Пример #2
0
        public static Type GetSlaveType(this FamilyCode code)
        {
            Attribute[] attributes = code.GetAttributes();

            SlaveAttribute attr = null;

            for (int i = 0; i < attributes.Length; i++)
            {
                if (attributes[i].GetType() == typeof(SlaveAttribute))
                {
                    attr = (SlaveAttribute)attributes[i];
                    break;
                }
            }

            if (attr == null)
            {
                throw new ArgumentNullException("Slave type not set.");
            }
            else
            {
                return(attr.SlaveType);
            }
        }