public static TextViewModel GetOrCreateTextViewModel(IWpfTextView wpfTextView, FileModel fileModel) { TextViewModel textViewModel; if (!wpfTextView.Properties.TryGetProperty <TextViewModel>(Constants.TextViewModelKey, out textViewModel)) { wpfTextView.Properties.AddProperty(Constants.TextViewModelKey, textViewModel = fileModel.GetOrAdd(wpfTextView)); } return(textViewModel); }