Esempio n. 1
0
        public void Build()
        {
            if (m_ProInfo.PropertyType != typeof(string))
            {
                m_nValue    = Convert.ToUInt32(m_ProInfo.GetValue(m_CommandHead, null));
                m_nDataType = SGIP_DataTypes.Uint;
                m_nLength   = 4;

                if ((m_ProInfo.PropertyType == typeof(Enum) || m_ProInfo.PropertyType.BaseType == typeof(Enum)) &&
                    m_ProInfo.PropertyType.GetFields() != null && m_ProInfo.PropertyType.GetFields().Length > 0)
                {
                    if (m_ProInfo.PropertyType.GetFields()[0].FieldType == typeof(byte))
                    {
                        m_nLength   = 1;
                        m_nDataType = SGIP_DataTypes.Byte;
                    }
                }
                else if (m_ProInfo.PropertyType == typeof(byte))
                {
                    m_nLength   = 1;
                    m_nDataType = SGIP_DataTypes.Byte;
                }
            }
            else
            {
                m_sValue    = m_ProInfo.GetValue(m_CommandHead, null) as string;
                m_nDataType = SGIP_DataTypes.String;
                m_nLength   = (uint)m_ProAttribute.Length;
            }
        }
Esempio n. 2
0
        public void Build()
        {
            if (m_ProInfo.PropertyType != typeof(string))
            {
                m_nValue = Convert.ToUInt32(m_ProInfo.GetValue(m_CommandHead, null));
                m_nDataType = SGIP_DataTypes.Uint;
                m_nLength = 4;

                if ((m_ProInfo.PropertyType == typeof(Enum) || m_ProInfo.PropertyType.BaseType == typeof(Enum)) &&
                     m_ProInfo.PropertyType.GetFields() != null && m_ProInfo.PropertyType.GetFields().Length > 0)
                {
                    if (m_ProInfo.PropertyType.GetFields()[0].FieldType == typeof(byte))
                    {
                        m_nLength = 1;
                        m_nDataType = SGIP_DataTypes.Byte;
                    }
                }
                else if (m_ProInfo.PropertyType == typeof(byte))
                {
                    m_nLength = 1;
                    m_nDataType = SGIP_DataTypes.Byte;
                }
            }
            else
            {
                m_sValue = m_ProInfo.GetValue(m_CommandHead, null) as string;
                m_nDataType = SGIP_DataTypes.String;
                m_nLength = (uint)m_ProAttribute.Length;
            }
        }