Esempio n. 1
0
        public override void InitializeSensors()
        {
            var sensors = AssemblyUtils.GetAttributesInModule(typeof(RadeonGpu), typeof(SensorRegisterAttribute));

            foreach (var sensor in sensors)
            {
                AddAvaliableSensor((BaseGpuSensor)Activator.CreateInstance(sensor, this));
            }
        }
Esempio n. 2
0
        public static void Initialize()
        {
            _packetsToTypesMap = new Dictionary <uint, Type>();
            _typesToPacketsMap = new Dictionary <Type, uint>();

            var packets = AssemblyUtils.GetAttributesInModule(typeof(NetworkRemoteControl), typeof(NetPacketRegisterAttribute));

            foreach (var packet in packets)
            {
                var attribute = packet.GetCustomAttribute <NetPacketRegisterAttribute>();
                if (attribute == null)
                {
                    continue;
                }

                if (_packetsToTypesMap.ContainsKey(attribute.PacketId))
                {
                    throw new Exception($"Packet with id '{attribute.PacketId}' already registered!");
                }

                _packetsToTypesMap.Add(attribute.PacketId, packet);
                _typesToPacketsMap.Add(packet, attribute.PacketId);
            }
        }