Hardware/SMBIOS/SMBIOSGroup.cs
changeset 9 e5adb0fd4917
parent 8 39067efce486
child 39 654696eeebe8
     1.1 --- a/Hardware/SMBIOS/SMBIOSGroup.cs	Fri Jan 29 19:20:44 2010 +0000
     1.2 +++ b/Hardware/SMBIOS/SMBIOSGroup.cs	Fri Jan 29 20:05:32 2010 +0000
     1.3 @@ -144,6 +144,14 @@
     1.4        private byte[] data;
     1.5        private string[] strings;
     1.6  
     1.7 +      protected string GetString(int offset) {
     1.8 +        if (offset < data.Length && data[offset] > 0 &&
     1.9 +         data[offset] <= strings.Length)
    1.10 +          return strings[data[offset] - 1];
    1.11 +        else
    1.12 +          return "";
    1.13 +      }
    1.14 +
    1.15        public Structure(byte type, ushort handle, byte[] data, string[] strings) 
    1.16        {
    1.17          this.type = type;
    1.18 @@ -159,18 +167,15 @@
    1.19  
    1.20      public class BIOSInformation : Structure {
    1.21  
    1.22 -      private string vendor = "";
    1.23 -      private string version = "";
    1.24 +      private string vendor;
    1.25 +      private string version;
    1.26  
    1.27        public BIOSInformation(byte type, ushort handle, byte[] data,
    1.28          string[] strings)
    1.29          : base(type, handle, data, strings) {
    1.30  
    1.31 -        if (data[0x04] > 0 && data[0x04] <= strings.Length)
    1.32 -          vendor = strings[data[0x04] - 1];
    1.33 -
    1.34 -        if (data[0x05] > 0 && data[0x05] <= strings.Length)
    1.35 -          version = strings[data[0x05] - 1];
    1.36 +        this.vendor = GetString(0x04);
    1.37 +        this.version = GetString(0x05);
    1.38        }
    1.39  
    1.40        public string Vendor { get { return vendor; } }
    1.41 @@ -180,18 +185,15 @@
    1.42  
    1.43      public class BaseBoardInformation : Structure {
    1.44  
    1.45 -      private string manufacturer  = "";
    1.46 -      private string productName = "";
    1.47 +      private string manufacturer;
    1.48 +      private string productName;
    1.49  
    1.50        public BaseBoardInformation(byte type, ushort handle, byte[] data,
    1.51          string[] strings)
    1.52          : base(type, handle, data, strings) {
    1.53  
    1.54 -        if (data[0x04] > 0 && data[0x04] <= strings.Length)
    1.55 -          manufacturer = strings[data[0x04] - 1];
    1.56 -
    1.57 -        if (data[0x05] > 0 && data[0x05] <= strings.Length)
    1.58 -          productName = strings[data[0x05] - 1];
    1.59 +        this.manufacturer = GetString(0x04);
    1.60 +        this.productName = GetString(0x05);
    1.61        }
    1.62  
    1.63        public string Manufacturer { get { return manufacturer; } }