using System; using System.Collections.Generic; namespace ESPServer { class RegistersContainer { private Dictionary registers; public RegistersContainer() { registers = new Dictionary(); } public int this[int address] { get { lock(registers) { if (registers.ContainsKey(address)) return registers[address]; return 0; } } set { lock (registers) { registers[address] = value; } } } public void SetFloat(int address, float value) { byte[] bytes = BitConverter.GetBytes(value); registers[address + 1] = (int)bytes[0] + (((int)bytes[1]) << 8); registers[address] = (int)bytes[2] + (((int)bytes[3]) << 8); } } }