1.1 --- a/Hardware/Mainboard/SMBIOS.cs Tue Sep 21 10:33:28 2010 +0000
1.2 +++ b/Hardware/Mainboard/SMBIOS.cs Tue Sep 21 20:32:36 2010 +0000
1.3 @@ -45,11 +45,11 @@
1.4
1.5 internal class SMBIOS {
1.6
1.7 - private byte[] raw;
1.8 - private Structure[] table;
1.9 + private readonly byte[] raw;
1.10 + private readonly Structure[] table;
1.11
1.12 - private BIOSInformation biosInformation = null;
1.13 - private BaseBoardInformation baseBoardInformation = null;
1.14 + private readonly BIOSInformation biosInformation;
1.15 + private readonly BaseBoardInformation baseBoardInformation;
1.16
1.17 private static string ReadSysFS(string path) {
1.18 try {
1.19 @@ -65,7 +65,7 @@
1.20 }
1.21
1.22 public SMBIOS() {
1.23 - int p = (int)System.Environment.OSVersion.Platform;
1.24 + int p = (int)Environment.OSVersion.Platform;
1.25 if ((p == 4) || (p == 128)) {
1.26 this.raw = null;
1.27 this.table = null;
1.28 @@ -193,11 +193,11 @@
1.29 }
1.30
1.31 public class Structure {
1.32 - private byte type;
1.33 - private ushort handle;
1.34 + private readonly byte type;
1.35 + private readonly ushort handle;
1.36
1.37 - private byte[] data;
1.38 - private string[] strings;
1.39 + private readonly byte[] data;
1.40 + private readonly string[] strings;
1.41
1.42 protected string GetString(int offset) {
1.43 if (offset < data.Length && data[offset] > 0 &&
1.44 @@ -222,8 +222,8 @@
1.45
1.46 public class BIOSInformation : Structure {
1.47
1.48 - private string vendor;
1.49 - private string version;
1.50 + private readonly string vendor;
1.51 + private readonly string version;
1.52
1.53 public BIOSInformation(string vendor, string version)
1.54 : base (0x00, 0, null, null)
1.55 @@ -247,117 +247,115 @@
1.56
1.57 public class BaseBoardInformation : Structure {
1.58
1.59 - private string manufacturerName;
1.60 - private string productName;
1.61 - private string version;
1.62 - private string serialNumber;
1.63 - private Manufacturer manufacturer;
1.64 - private Model model;
1.65 + private readonly string manufacturerName;
1.66 + private readonly string productName;
1.67 + private readonly string version;
1.68 + private readonly string serialNumber;
1.69 + private readonly Manufacturer manufacturer;
1.70 + private readonly Model model;
1.71
1.72 - private void SetManufacturerName(string name) {
1.73 - this.manufacturerName = name;
1.74 -
1.75 + private static Manufacturer GetManufacturer(string name) {
1.76 switch (name) {
1.77 case "ASRock":
1.78 - manufacturer = Manufacturer.ASRock; break;
1.79 + return Manufacturer.ASRock;
1.80 case "ASUSTeK Computer INC.":
1.81 - manufacturer = Manufacturer.ASUS; break;
1.82 + return Manufacturer.ASUS;
1.83 case "Dell Inc.":
1.84 - manufacturer = Manufacturer.Dell; break;
1.85 + return Manufacturer.Dell;
1.86 case "DFI":
1.87 case "DFI Inc.":
1.88 - manufacturer = Manufacturer.DFI; break;
1.89 + return Manufacturer.DFI;
1.90 case "ECS":
1.91 - manufacturer = Manufacturer.ECS; break;
1.92 + return Manufacturer.ECS;
1.93 case "EPoX COMPUTER CO., LTD":
1.94 - manufacturer = Manufacturer.EPoX; break;
1.95 + return Manufacturer.EPoX;
1.96 case "EVGA":
1.97 - manufacturer = Manufacturer.EVGA; break;
1.98 + return Manufacturer.EVGA;
1.99 case "First International Computer, Inc.":
1.100 - manufacturer = Manufacturer.FIC; break;
1.101 + return Manufacturer.FIC;
1.102 case "Gigabyte Technology Co., Ltd.":
1.103 - manufacturer = Manufacturer.Gigabyte; break;
1.104 + return Manufacturer.Gigabyte;
1.105 case "Hewlett-Packard":
1.106 - manufacturer = Manufacturer.HP; break;
1.107 + return Manufacturer.HP;
1.108 case "IBM":
1.109 - manufacturer = Manufacturer.IBM; break;
1.110 + return Manufacturer.IBM;
1.111 case "MICRO-STAR INTERNATIONAL CO., LTD":
1.112 case "MICRO-STAR INTERNATIONAL CO.,LTD":
1.113 - manufacturer = Manufacturer.MSI; break;
1.114 + return Manufacturer.MSI;
1.115 case "XFX":
1.116 - manufacturer = Manufacturer.XFX; break;
1.117 + return Manufacturer.XFX;
1.118 case "To be filled by O.E.M.":
1.119 - manufacturer = Manufacturer.Unknown; break;
1.120 + return Manufacturer.Unknown;
1.121 default:
1.122 - manufacturer = Manufacturer.Unknown; break;
1.123 + return Manufacturer.Unknown;
1.124 }
1.125 }
1.126 -
1.127 - private void SetProductName(string name) {
1.128 - this.productName = name;
1.129 -
1.130 +
1.131 + private static Model GetModel(string name) {
1.132 switch (name) {
1.133 case "880GMH/USB3":
1.134 - model = Model._880GMH_USB3; break;
1.135 + return Model._880GMH_USB3;
1.136 case "Crosshair III Formula":
1.137 - model = Model.Crosshair_III_Formula; break;
1.138 + return Model.Crosshair_III_Formula;
1.139 case "M2N-SLI DELUXE":
1.140 - model = Model.M2N_SLI_DELUXE; break;
1.141 + return Model.M2N_SLI_DELUXE;
1.142 case "M4A79XTD EVO":
1.143 - model = Model.M4A79XTD_EVO; break;
1.144 + return Model.M4A79XTD_EVO;
1.145 case "P5W DH Deluxe":
1.146 - model = Model.P5W_DH_Deluxe; break;
1.147 + return Model.P5W_DH_Deluxe;
1.148 case "P6X58D-E":
1.149 - model = Model.P6X58D_E; break;
1.150 + return Model.P6X58D_E;
1.151 case "Rampage Extreme":
1.152 - model = Model.Rampage_Extreme; break;
1.153 + return Model.Rampage_Extreme;
1.154 case "Rampage II GENE":
1.155 - model = Model.Rampage_II_GENE; break;
1.156 + return Model.Rampage_II_GENE;
1.157 case "LP BI P45-T2RS Elite":
1.158 - model = Model.LP_BI_P45_T2RS_Elite; break;
1.159 + return Model.LP_BI_P45_T2RS_Elite;
1.160 case "LP DK P55-T3eH9":
1.161 - model = Model.LP_DK_P55_T3eH9; break;
1.162 + return Model.LP_DK_P55_T3eH9;
1.163 case "A890GXM-A":
1.164 - model = Model.A890GXM_A; break;
1.165 + return Model.A890GXM_A;
1.166 case "X58 SLI Classified":
1.167 - model = Model.X58_SLI_Classified; break;
1.168 + return Model.X58_SLI_Classified;
1.169 case "965P-S3":
1.170 - model = Model._965P_S3; break;
1.171 + return Model._965P_S3;
1.172 case "EP45-DS3R":
1.173 - model = Model.EP45_DS3R; break;
1.174 + return Model.EP45_DS3R;
1.175 case "EP45-UD3R":
1.176 - model = Model.EP45_UD3R; break;
1.177 + return Model.EP45_UD3R;
1.178 case "EX58-EXTREME":
1.179 - model = Model.EX58_EXTREME; break;
1.180 + return Model.EX58_EXTREME;
1.181 case "GA-MA770T-UD3":
1.182 - model = Model.GA_MA770T_UD3; break;
1.183 + return Model.GA_MA770T_UD3;
1.184 case "GA-MA785GMT-UD2H":
1.185 - model = Model.GA_MA785GMT_UD2H; break;
1.186 + return Model.GA_MA785GMT_UD2H;
1.187 case "P35-DS3":
1.188 - model = Model.P35_DS3; break;
1.189 + return Model.P35_DS3;
1.190 case "P35-DS3L":
1.191 - model = Model.P35_DS3L; break;
1.192 + return Model.P35_DS3L;
1.193 case "P55-UD4":
1.194 - model = Model.P55_UD4; break;
1.195 + return Model.P55_UD4;
1.196 case "P55M-UD4":
1.197 - model = Model.P55M_UD4; break;
1.198 + return Model.P55M_UD4;
1.199 case "X38-DS5":
1.200 - model = Model.X38_DS5; break;
1.201 + return Model.X38_DS5;
1.202 case "X58A-UD3R":
1.203 - model = Model.X58A_UD3R; break;
1.204 + return Model.X58A_UD3R;
1.205 case "To be filled by O.E.M.":
1.206 - model = Model.Unknown; break;
1.207 + return Model.Unknown;
1.208 default:
1.209 - model = Model.Unknown; break;
1.210 + return Model.Unknown;
1.211 }
1.212 }
1.213
1.214 public BaseBoardInformation(string manufacturerName, string productName,
1.215 string version, string serialNumber)
1.216 : base(0x02, 0, null, null)
1.217 - {
1.218 - SetManufacturerName(manufacturerName);
1.219 - SetProductName(productName);
1.220 + {
1.221 + this.manufacturerName = manufacturerName;
1.222 + this.manufacturer = GetManufacturer(manufacturerName);
1.223 + this.productName = productName;
1.224 + this.model = GetModel(productName);
1.225 this.version = version;
1.226 this.serialNumber = serialNumber;
1.227 }
1.228 @@ -366,8 +364,10 @@
1.229 string[] strings)
1.230 : base(type, handle, data, strings) {
1.231
1.232 - SetManufacturerName(GetString(0x04).Trim());
1.233 - SetProductName(GetString(0x05).Trim());
1.234 + this.manufacturerName = GetString(0x04).Trim();
1.235 + this.manufacturer = GetManufacturer(this.manufacturerName);
1.236 + this.productName = GetString(0x05).Trim();
1.237 + this.model = GetModel(this.productName);
1.238 this.version = GetString(0x06).Trim();
1.239 this.serialNumber = GetString(0x07).Trim();
1.240 }