private void LayoutChangeProviderOnLayoutChanged(object sender, EventArgs eventArgs) { foreach (var dataPointModel in _dataPointModels) { var codeElementDescriptor = ((CurrentUsersDataPoint)dataPointModel.DataPoint).CodeElementDescriptor; if (dataPointModel.IsDisposed) { _codeElementDescriptorToDataPointString.Remove(codeElementDescriptor); } else { bool shouldRefresh = false; var cmc = new CodeMetricCalculator(); var result = cmc.Calculate(codeElementDescriptor.SyntaxNode); var newText = $"LOC: {result.LineOfCode}, CC: {result.CyclomaticComplexity}, MI: {result.MaintainabilityIndex:###}"; if (dataPointModel.Descriptor != newText || !dataPointModel.IsVisible && !string.IsNullOrEmpty(newText)) { shouldRefresh = true; } if (shouldRefresh && dataPointModel.RefreshCommand.CanExecute(null)) { _codeElementDescriptorToDataPointString[codeElementDescriptor] = newText; dataPointModel.RefreshCommand.Execute(null); } } } }
public Task <string> GetTextForDataPoint(ICodeElementDescriptor codeElementDescriptor) { if (_codeElementDescriptorToDataPointString.ContainsKey(codeElementDescriptor)) { return(Task.FromResult(_codeElementDescriptorToDataPointString[codeElementDescriptor])); } var cmc = new CodeMetricCalculator(); var result = cmc.Calculate(codeElementDescriptor.SyntaxNode); var metricMsg = $"LOC: {result.LineOfCode}, CC: {result.CyclomaticComplexity}, MI: {result.MaintainabilityIndex:###}"; _codeElementDescriptorToDataPointString.Add(codeElementDescriptor, metricMsg); return(Task.FromResult(metricMsg)); }