public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var planItem = value as ExecutionStatisticsPlanItem; return(planItem?.LastMemoryUsedBytes == null ? String.Empty : $"{DataSpaceConverter.PrettyPrint(planItem.LastMemoryUsedBytes.Value)} ({planItem.LastExecutionMethod}, {planItem.WorkAreaSizingPolicy})"); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { var allocatedInMemoryBytes = (long?)values[0]; var storageBytes = (long?)values[1]; var nonPopulatedBytes = (long?)values[2]; var populationStatus = (string)values[3]; if (!allocatedInMemoryBytes.HasValue || !storageBytes.HasValue || !nonPopulatedBytes.HasValue || String.IsNullOrEmpty(populationStatus)) { return(ValueConverterBase.ValueNotAvailable); } var populatedRatio = Math.Round(((decimal)storageBytes.Value - nonPopulatedBytes.Value) / storageBytes.Value * 100, 2); var isPopulating = String.Equals(populationStatus, "STARTED"); var populationStatusLabel = isPopulating ? " - ongoing" : null; var populatedRatioLabel = populatedRatio < 100 || isPopulating ? $"{populatedRatio} %" : null; var populationStatusDetail = populatedRatio == 100 && populationStatusLabel == null ? null : $"({populatedRatioLabel}{populationStatusLabel})"; return($"{DataSpaceConverter.PrettyPrint(allocatedInMemoryBytes.Value)} {populationStatusDetail}"); }