moel@165: /* moel@165: moel@344: This Source Code Form is subject to the terms of the Mozilla Public moel@344: License, v. 2.0. If a copy of the MPL was not distributed with this moel@344: file, You can obtain one at http://mozilla.org/MPL/2.0/. moel@165: moel@344: Copyright (C) 2009-2011 Michael Möller moel@344: moel@165: */ moel@165: moel@165: using System; moel@165: using System.Collections.Generic; moel@165: moel@165: namespace OpenHardwareMonitor.Hardware { moel@246: internal static class HexStringArray { moel@165: moel@246: public static byte Read(string s, ushort address) { moel@246: string[] lines = s.Split(new[] { '\r', '\n' }, moel@246: StringSplitOptions.RemoveEmptyEntries); moel@165: moel@246: foreach (string line in lines) { moel@277: string[] array = line.Split(new[] { ' ', '\t' }, moel@246: StringSplitOptions.RemoveEmptyEntries); moel@272: if (array.Length == 0) moel@272: continue; moel@246: if (Convert.ToInt32(array[0], 16) == (address & 0xFFF0)) moel@246: return Convert.ToByte(array[(address & 0x0F) + 1], 16); moel@165: } moel@165: moel@246: throw new ArgumentException(); moel@165: } moel@165: } moel@165: }