コード例 #1
0
        /// <summary>
        /// Collector initialize
        /// </summary>
        public void Initialize()
        {
            macAddress = NetworkInterface
                         .GetAllNetworkInterfaces()
                         .Where(nic => nic.OperationalStatus == OperationalStatus.Up && nic.NetworkInterfaceType != NetworkInterfaceType.Loopback)
                         .Select(nic => nic.GetPhysicalAddress().ToString())
                         .FirstOrDefault();

            name             = Dns.GetHostName();
            location         = _configuration["Location"];
            description      = _configuration["Description"];
            readingFrequency = int.Parse(_configuration["ReadingFrequency"]);

            // Read sensors definition from config file
            var configSensors = _configuration.GetSection("Sensors");
            var sensorFactory = new SensorFactory(_logger);

            foreach (IConfigurationSection section in configSensors.GetChildren())
            {
                sensors.Add(sensorFactory.Get(section));
            }
        }