Ejemplo n.º 1
0
        public void T()
        {
            Unit           u   = Unit.FindByName(Unit.Cm);
            TestDeviceData dat = new TestDeviceData();

            PropertyInfo[] pis = dat.GetType().GetProperties();
            foreach (PropertyInfo pi in pis)
            {
                object[] atts = pi.GetCustomAttributes(typeof(DataItemAttribute), false);
                if (atts.Length > 0)
                {
                    //Console.WriteLine(atts[0].ToString());
                    DataItemAttribute att   = (DataItemAttribute)atts[0];
                    object            value = pi.GetValue(dat, null);
                    Console.WriteLine("{0} {1} {2} {3}", att.Name, att.OrderNumber, value, att.Unit.Text);
                }
            }
        }
Ejemplo n.º 2
0
        public void T()
        {
            Unit u = Unit.FindByName(Unit.Cm);
            TestDeviceData dat = new TestDeviceData();
            PropertyInfo[] pis = dat.GetType().GetProperties();
            foreach (PropertyInfo pi in pis)
            {
                object[] atts = pi.GetCustomAttributes(typeof(DataItemAttribute), false);
                if (atts.Length > 0)
                {
                    //Console.WriteLine(atts[0].ToString());
                    DataItemAttribute att = (DataItemAttribute)atts[0];
                    object value = pi.GetValue(dat, null);
                    Console.WriteLine("{0} {1} {2} {3}", att.Name, att.OrderNumber, value, att.Unit.Text);

                }
            }
        }