/// <summary> /// Initializes a new instance of the <see cref="DataRecord{TResult}"/> class. /// </summary> /// <param name="tunerDataRecord">The tuner data record.</param> /// <param name="adapterDataRecord">The adapter data record.</param> public DataRecord(TunerDataRecord <TResult> tunerDataRecord, AdapterDataRecord <TResult> adapterDataRecord) { this.TunerDataRecord = tunerDataRecord; this.AdapterDataRecord = adapterDataRecord; this.IsCancelledByGrayBoxDuringGrayBoxSimulation = false; }
/// <inheritdoc /> public bool TryConvert(string[] value, out AdapterDataRecord <TResult> result) { result = null; if (value.Length != AdapterDataRecord <TResult> .OtherHeader.Length + this._adapterFeaturesHeader.Length + this._numberOfResultColumns) { return(false); } var targetAlgorithmName = value[0]; if (!Enum.TryParse(value[1], true, out TargetAlgorithmStatus targetAlgorithmStatus)) { return(false); } if (!int.TryParse(value[2], NumberStyles.Any, CultureInfo.InvariantCulture, out var cpuTime)) { return(false); } if (!int.TryParse(value[3], NumberStyles.Any, CultureInfo.InvariantCulture, out var wallClockTime)) { return(false); } if (!DateTime.TryParseExact(value[4], "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.None, out var timeStamp)) { return(false); } // Try to read adapter features. double[] adapterFeatures; try { adapterFeatures = value[new Range( AdapterDataRecord <TResult> .OtherHeader.Length, AdapterDataRecord <TResult> .OtherHeader.Length + this._adapterFeaturesHeader.Length)].Select(double.Parse).ToArray(); } catch { return(false); } // Try to read current gray box result. var currentGrayBoxResultString = value[new Range( AdapterDataRecord <TResult> .OtherHeader.Length + this._adapterFeaturesHeader.Length, AdapterDataRecord <TResult> .OtherHeader.Length + this._adapterFeaturesHeader.Length + this._numberOfResultColumns)]; if (!this._targetAlgorithmFactory.TryToGetResultFromStringArray(currentGrayBoxResultString, out var currentGrayBoxResult)) { return(false); } result = new AdapterDataRecord <TResult>( targetAlgorithmName, targetAlgorithmStatus, TimeSpan.FromMilliseconds(cpuTime), TimeSpan.FromMilliseconds(wallClockTime), timeStamp, this._adapterFeaturesHeader, adapterFeatures, currentGrayBoxResult); return(true); }