Esempio n. 1
0
        /// <summary>
        /// Method for converting struct BATTERY_INFO to dictionary<string, string>
        /// </summary>
        /// <param name="bi">Struct with battery information for coverting to dictionary</param>
        private void ConvertBATT_INFO_To_Dictionary(BATTERY_INFORMATION bi)
        {
            Type biType = bi.GetType();

            FieldInfo[] fiArr = biType.GetFields();

            foreach (FieldInfo fi in fiArr)
            {
                if (fi.FieldType.IsArray)
                {
                    base.InsertPairToDictionary(fi.Name, (Encoding.UTF8.GetString((byte[])fi.GetValue(bi))).TrimEnd('\0'));
                }
                else
                {
                    base.InsertPairToDictionary(fi.Name, fi.FieldType == typeof(byte)?((byte)fi.GetValue(bi)).ToString():fi.GetValue(bi).ToString());
                }
            }
        }