using System; using System.Collections.Generic; using System.Text; namespace DirectUSB { public class VariableInformation { #region Declarations private string _variableName; private List _attributes; public enum VarType : ulong { Real = 0x00, List = 0x01, Matrix = 0x02, YVar = 0x03, String = 0x04, Program = 0x05, ProtectedProgram = 0x06, Picture = 0x07, GDB = 0x08, WindowSettings1 = 0x09, Complex = 0x10, ComplexList = 0x11, WindowSettings2 = 0x0F, SavedWindowSettings = 0x10, TableSetup = 0x11, Backup = 0x13, AppVar = 0x15, Group = 0x17, OS = 0x23, FlashApp = 0x24, IDList = 0x26, Certificate = 0x27, Clock = 0x29 }; #endregion #region Constructors / Teardown public VariableInformation(string name, List attributes) { _variableName = name; _attributes = attributes; } #endregion #region Public Properties public string VariableName { get { return _variableName; } } public List Attributes { get { return _attributes; } } public ulong? VariableType { get { ulong? ret = null; foreach (var attrib in _attributes) { if (attrib.Type == DirectUSB.Attributes.Attribute.AttributeType.VariableType) { ret = ((DirectUSB.Attributes.VariableTypeAttribute)attrib).VariableType; break; } } return ret; } } public string TypeDescription { get { string ret; if (!this.VariableType.HasValue) { ret = "Unknown"; } else { if (Enum.IsDefined(typeof(VarType), this.VariableType)) { ret = Enum.GetName(typeof(VarType), this.VariableType); } else { ret = "Unknown: " + this.VariableType.Value.ToString("X2"); } } return ret; } } public ulong? RawVariableType { get { ulong? ret = null; foreach (var attrib in _attributes) { if (attrib.Type == DirectUSB.Attributes.Attribute.AttributeType.VariableType) { ret = ((DirectUSB.Attributes.VariableTypeAttribute)attrib).RawVariableType; break; } } return ret; } } #endregion } }