//--// public CoreTest(ILogger logger) { if (logger == null) { throw new ArgumentException("Cannot run tests without logging"); } _completed = new AutoResetEvent(false); _logger = logger; _rand = new Random( ); _totalMessagesSent = 0; _totalMessagesToSend = 0; _gatewayQueue = new GatewayQueue <QueuedItem>( ); #if MOCK_SENDER _sender = new MockSender <SensorDataContract>(this); #else IotHubConfig iotHubConfig = Loader.GetIotHubConfig( ); _sender = new MessageSender <SensorDataContract>(iotHubConfig.IotHubConnectionString, _logger); #endif _batchSenderThread = new BatchSenderThread <QueuedItem, SensorDataContract>( _gatewayQueue, _sender, dataTransform: null, serializedData: m => (m == null) ? null : m.JsonData, logger: _logger ); string gatewayIPAddressString = string.Empty; IPAddressHelper.GetIPAddressString(ref gatewayIPAddressString); DataTransformsConfig dataTransformsConfig = Loader.GetDataTransformsConfig( ); if (dataTransformsConfig.AttachIP || dataTransformsConfig.AttachTime) { Func <string, SensorDataContract> transform = (m => DataTransforms.SensorDataContractFromString(m, _logger)); if (dataTransformsConfig.AttachTime) { var transformPrev = transform; transform = (m => DataTransforms.AddTimeCreated(transformPrev(m))); } if (dataTransformsConfig.AttachTime) { var transformPrev = transform; transform = (m => DataTransforms.AddIPToLocation(transformPrev(m), gatewayIPAddressString)); } _gatewayTransform = (m => DataTransforms.QueuedItemFromSensorDataContract(transform(m))); } }
internal static DataTransformsConfig GetDataTransformsConfig( ) { DataTransformsConfigSection section = ConfigurationManager.GetSection("dataTransformsConfig") as DataTransformsConfigSection; DataTransformsConfig configData; if (section != null) { configData = new DataTransformsConfig { AttachTime = section.AttachTime, AttachIP = section.AttachIP }; } else { configData = new DataTransformsConfig { AttachTime = true, AttachIP = false }; } return(configData); }