public ItemInfo(object dataItem, object destItem) { this.Item = dataItem; this.destItem = destItem; this.Fields = DiffUtility.GetFields(destItem); var dataChildItems = new List <object>(); var destChildItems = new List <object>(); foreach (var item in DiffUtility.GetChilds(dataItem)) { dataChildItems.Add(item); } foreach (var item in DiffUtility.GetChilds(destItem)) { destChildItems.Add(item); } var query = from dataChild in dataChildItems join destChild in destChildItems on $"{DiffUtility.GetListName(dataChild)}{DiffUtility.GetItemKey(dataChild)}" equals $"{DiffUtility.GetListName(destChild)}{DiffUtility.GetItemKey(destChild)}" select new { DataItem = dataChild, DestItem = destChild }; foreach (var item in query) { this.childList.Add(new ItemInfo(item.DataItem, item.DestItem)); } }
private static void GetTextLines(string textA, string textB, TextBinaryDiffArgs args, out IList <string> a, out IList <string> b, IDiffProgress progress) { a = null; b = null; CompareType compareType = args.CompareType; bool isAuto = compareType == CompareType.Auto; if (compareType == CompareType.Xml || isAuto) { a = TryGetXmlLines(DiffUtility.GetXmlTextLinesFromXml, "the left side text", textA, !isAuto, args, progress); // If A failed to parse with Auto, then there's no reason to try B. if (a != null) { b = TryGetXmlLines(DiffUtility.GetXmlTextLinesFromXml, "the right side text", textB, !isAuto, args, progress); } // If we get here and the compare type was XML, then both // inputs parsed correctly, and both lists should be non-null. // If we get here and the compare type was Auto, then one // or both lists may be null, so we'll fallthrough to the text // handling logic. } if (a == null || b == null) { a = DiffUtility.GetStringTextLines(textA, progress); b = DiffUtility.GetStringTextLines(textB, progress); } }
protected override void PrepareContainer(DataGridContext dataGridContext, object item) { if (this.DataContext is INotifyPropertyChanged oldRow) { oldRow.PropertyChanged -= DataRowView_PropertyChanged; } if (item is ICustomTypeDescriptor descriptor) { this.diffFields = new HashSet <string>(DiffUtility.GetDiffFields(item)); } else { this.diffFields = null; } if (item is INotifyPropertyChanged newRow) { newRow.PropertyChanged += DataRowView_PropertyChanged; } this.SetValue(DiffStatePropertyKey, DiffUtility.GetDiffState(item)); this.PropertyChanged -= DiffDataContainer_PropertyChanged; dataGridContext.DataGridControl.SelectionChanged -= DataGridControl_SelectionChanged; base.PrepareContainer(dataGridContext, item); this.SetSelectionProperty(); dataGridContext.DataGridControl.SelectionChanged += DataGridControl_SelectionChanged; this.PropertyChanged += DiffDataContainer_PropertyChanged; }
public CopyFieldAction(object dataItem, object destItem, string fieldName) { this.dataItem = dataItem; this.destItem = destItem; this.fieldName = fieldName; this.oldField = DiffUtility.GetField(destItem, fieldName); }
private void Obj_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == string.Empty) { this.Fields = DiffUtility.GetFields(this.Item); } }
private void DataRowView_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (this.DataContext == null) { return; } if (e.PropertyName == DiffUtility.DiffFieldsKey || e.PropertyName == string.Empty) { this.diffFields = new HashSet <string>(DiffUtility.GetDiffFields(this.DataContext)); } if (e.PropertyName == DiffUtility.DiffStateKey || e.PropertyName == DiffUtility.DiffEnabledKey || e.PropertyName == string.Empty) { this.SetValue(DiffStatePropertyKey, DiffUtility.GetDiffState(this.DataContext)); } if (e.PropertyName == CremaSchema.Index) { this.Dispatcher.InvokeAsync(this.SetSelectionProperty); } if (e.PropertyName == string.Empty) { if (sender is IDataErrorInfo errorInfo) { if (errorInfo.Error == string.Empty && this.HasValidationError == true) { this.Dispatcher.InvokeAsync(() => { this.EndEditCore(); }); } } } this.RefreshError(); }
protected override void OnRedo() { base.OnRedo(); var field = DiffUtility.GetField(this.dataItem, this.fieldName); DiffUtility.SetField(this.destItem, this.fieldName, field); }
/// <summary> /// Do comparison. /// </summary> public override void Execute() { Project project = App.Instance.SalesForceApp.CurrentProject; ISourceFileEditorDocument currentDocument = CurrentDocument; if (project != null && currentDocument != null) { SourceFileContent content = null; using (App.Wait("Comparing files")) content = project.Client.Meta.GetSourceFileContent(currentDocument.File); if (currentDocument.Content == content.ContentValue) { App.MessageUser("The version on the server is identical to your current version.", "Compare", System.Windows.MessageBoxImage.Information, new string[] { "OK" }); } else { string diff = DiffUtility.Diff(content.ContentValue, currentDocument.Content); TextViewDocument document = new TextViewDocument( project, diff, currentDocument.File.Name, "Compare.png", true); App.Instance.Content.OpenDocument(document); } } }
/// <summary> /// Do comparison. /// </summary> public override void Execute() { Project project = App.Instance.SalesForceApp.CurrentProject; ISourceFileEditorDocument currentDocument = CurrentDocument; if (project != null && currentDocument != null) { string olderText = project.Repository.GetContent(currentDocument.File, null); string newerText = currentDocument.Content; if (olderText == currentDocument.Content) { App.MessageUser("The most recent version in source control is identical to your current version.", "Compare", System.Windows.MessageBoxImage.Information, new string[] { "OK" }); } else { string diff = DiffUtility.Diff(olderText, currentDocument.Content); TextViewDocument document = new TextViewDocument( project, diff, currentDocument.File.Name, "Compare.png", true); App.Instance.Content.OpenDocument(document); } } }
/// <summary> /// Do comparison. /// </summary> public override void Execute() { ISourceFileEditorDocument currentDocument = CurrentDocument; if (currentDocument != null) { string extension = System.IO.Path.GetExtension(currentDocument.File.FileName); if (extension.StartsWith(".")) { extension = extension.Substring(1); } OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Select file to compare with"; dlg.Multiselect = false; dlg.Filter = String.Format("{0} Files|*.{1}|All Files|*.*", extension.ToUpper(), extension); bool?result = dlg.ShowDialog(); if (result.HasValue && result.Value) { string diff = DiffUtility.Diff( System.IO.File.ReadAllText(dlg.FileName), currentDocument.Content); TextViewDocument document = new TextViewDocument( App.Instance.SalesForceApp.CurrentProject, diff, currentDocument.File.Name, "Compare.png", true); App.Instance.Content.OpenDocument(document); } } }
public void Undo() { DiffUtility.Copy(this.destItem, this.Fields); foreach (var item in this.childList) { item.Undo(); } }
private static DiffMinimapItemState GetDiffState(object item) { if (DiffUtility.HasDiffState(item) == false) { return(DiffMinimapItemState.Null); } return((DiffMinimapItemState)DiffUtility.GetDiffState(item)); }
public void Redo() { DiffUtility.Empty(this.Item); foreach (var item in this.childList) { item.Redo(); } }
public void Redo() { DiffUtility.Copy(this.Item, this.destItem); foreach (var item in this.childList) { item.Redo(); } }
protected override void PrepareContainer(DataGridContext dataGridContext, object item) { base.PrepareContainer(dataGridContext, item); var columnItem = CremaDataTableItemControl.GetReference(this.ParentColumn); var diffState = columnItem != null?DiffUtility.GetDiffState(columnItem) : DiffState.Unchanged; this.SetValue(DiffStatePropertyKey, diffState); this.SetValue(IsDummyPropertyKey, this.FieldName.StartsWith(DiffUtility.DiffDummyKey)); }
public ItemInfo(object dataItem) { this.dataItem = dataItem; this.fields = DiffUtility.GetFields(dataItem); foreach (var item in DiffUtility.GetChilds(dataItem)) { this.childList.Add(new ItemInfo(item)); } }
public ItemViewModel(DiffDataTable diffTable, DependencyObject parent) { this.diffTable = diffTable; this.parent = parent; this.diffState = DiffUtility.GetDiffState(this.diffTable.SourceItem1) == DiffState.Imaginary ? DiffState.Inserted : DiffUtility.GetDiffState(this.diffTable.SourceItem1); BindingOperations.SetBinding(this, ReadOnlyProperty, new Binding("ReadOnly") { Source = parent, }); }
public override bool Equals(object obj) { MethodWrapper other = (MethodWrapper)obj; if (method.Name != other.method.Name) { return(false); } return(0 == DiffUtility.Compare(method.Parameters, other.method.Parameters)); }
private static void GetFileLines(string fileNameA, string fileNameB, out IList <string> a, out IList <string> b, out int leadingCharactersToIgnore, TextBinaryDiffArgs args, IDiffProgress progress) { a = null; b = null; leadingCharactersToIgnore = 0; CompareType compareType = args.CompareType; if (compareType == CompareType.Binary || (args.IsAuto && (DiffUtility.IsBinaryFile(fileNameA) || DiffUtility.IsBinaryFile(fileNameB)))) { using (FileStream fileA = File.OpenRead(fileNameA)) using (FileStream fileB = File.OpenRead(fileNameB)) { BinaryDiff diff = new BinaryDiff { FootprintLength = args.BinaryFootprintLength }; AddCopyCollection addCopy = diff.Execute(fileA, fileB); BinaryDiffLines lines = new BinaryDiffLines(fileA, addCopy, args.BinaryFootprintLength); a = lines.BaseLines; b = lines.VersionLines; leadingCharactersToIgnore = BinaryDiffLines.PrefixLength; } } if (compareType == CompareType.Xml || (args.IsAuto && (a == null || b == null))) { a = TryGetXmlLines(DiffUtility.GetXmlTextLines, fileNameA, fileNameA, !args.IsAuto, args, progress); // If A failed to parse with Auto, then there's no reason to try B. if (a != null) { b = TryGetXmlLines(DiffUtility.GetXmlTextLines, fileNameB, fileNameB, !args.IsAuto, args, progress); } // If we get here and the compare type was XML, then both // inputs parsed correctly, and both lists should be non-null. // If we get here and the compare type was Auto, then one // or both lists may be null, so we'll fallthrough to the text // handling logic. } if (a == null || b == null) { a = DiffUtility.GetFileTextLines(fileNameA, progress); b = DiffUtility.GetFileTextLines(fileNameB, progress); } }
public void ParameterComparisonTest() { DefaultParameter p1 = new DefaultParameter("a", mscorlib.GetClass("System.String", 0).DefaultReturnType, DomRegion.Empty); DefaultParameter p2 = new DefaultParameter("b", new GetClassReturnType(mscorlib, "System.String", 0), DomRegion.Empty); IList <IParameter> a1 = new List <IParameter>(); IList <IParameter> a2 = new List <IParameter>(); a1.Add(p1); a2.Add(p2); Assert.AreEqual(0, DiffUtility.Compare(a1, a2)); }
static bool InterfaceMemberAlreadyImplementedParametersAreIdentical(IMember a, IMember b) { if (a is IMethodOrProperty && b is IMethodOrProperty) { return(DiffUtility.Compare(((IMethodOrProperty)a).Parameters, ((IMethodOrProperty)b).Parameters) == 0); } else { return(true); } }
public object FindItem(CollectionView items, object key) { if (key != null) { foreach (var item in items) { var key2 = DiffUtility.GetItemKey(item); if (object.Equals(key, key2) == true) { return(item); } } } return(null); }
static bool IsSimilarMemberInternal(IMember member1, IMember member2) { if (member1 == member2) { return(true); } if (member1 == null || member2 == null) { return(false); } if (member1.FullyQualifiedName != member2.FullyQualifiedName) { return(false); } if (member1.IsStatic != member2.IsStatic) { return(false); } if (member1 is IMethod) { if (member2 is IMethod) { if (DiffUtility.Compare(((IMethod)member1).Parameters, ((IMethod)member2).Parameters) != 0) { return(false); } } else { return(false); } } if (member1 is IProperty) { if (member2 is IProperty) { if (DiffUtility.Compare(((IProperty)member1).Parameters, ((IProperty)member2).Parameters) != 0) { return(false); } } else { return(false); } } return(true); }
private void InitializeDetail(DetailConfiguration detail) { var childTable = CremaDataTableItemControl.GetReference(detail) as CremaDataTable; var diffState = DiffUtility.GetDiffState(childTable); detail.Title = new DetailsDescriptor() { Title = childTable.TableName, DiffState = diffState, }; detail.TitleTemplate = this.FindResource("Diff_DetailConfiguration_Title_Template") as DataTemplate; foreach (var item in detail.Columns) { item.PropertyChanged += Column_PropertyChanged; } }
private void SyncSelection(DiffDataGridControl destControl) { using (destControl.preventSelection.Set(true)) { { this.SelectedItemRanges.Clear(); foreach (var item in DataGridControl.GetDataGridContext(this).GetChildContexts()) { item.SelectedItemRanges.Clear(); } } if (destControl.GlobalCurrentItem != null) { var destContext = DataGridControl.GetDataGridContext(destControl); Select(destContext); foreach (var item in destContext.GetChildContexts()) { Select(item); } } } void Select(DataGridContext destContext) { var gridContext = this.FindContext(destContext); var query = from item in destContext.GetSelectedItems() let obj = this.FindItem(gridContext.Items, DiffUtility.GetItemKey(item)) where obj != null select obj; if (query.Count() == destContext.GetSelectedItems().Count()) { var selectionRanges = gridContext.GenerateSelectionRanges(query); foreach (var item in selectionRanges) { gridContext.SelectedItemRanges.Add(item); } } } }
protected override void OnRedo() { base.OnRedo(); if (this.gridContext.Items.SourceCollection is DataGridCollectionView bindingList1) { var newItem = bindingList1.AddNew(); bindingList1.CommitNew(); bindingList1.Refresh(); this.newItem = newItem; } if (this.destContext.Items.SourceCollection is DataGridCollectionView bindingList2) { var newItem = bindingList2.AddNew(); DiffUtility.Copy(dataItem, newItem, true); bindingList2.CommitNew(); bindingList2.Refresh(); this.newDestItem = newItem; } }
private void SyncCurrentItem(DiffDataGridControl destControl) { var destCurrentItem = destControl.GlobalCurrentItem; if (destCurrentItem == null) { return; } var dataContext = this.FindContext(destControl.CurrentContext); if (dataContext == null) { return; } using (destControl.preventEvent.Set(true)) { dataContext.CurrentItem = this.FindItem(dataContext.Items, DiffUtility.GetItemKey(destControl.GlobalCurrentItem)); } }
private DiffBinaryTextResults GetTextLines(string textA, string textB , TextBinaryDiffArgs args , IDiffProgress progress) { FileContentInfo af = null, bf = null; bool isAuto = args.CompareType == CompareType.Auto; if (args.CompareType == CompareType.Xml || isAuto) { af = TryGetXmlText(DiffUtility.GetXmlTextFromXml, "the left side text", textA, !isAuto, args, progress); // If A failed to parse with Auto, then there's no reason to try B. if (af != null) { bf = TryGetXmlText(DiffUtility.GetXmlTextFromXml, "the right side text", textB, !isAuto, args, progress); } // If we get here and the compare type was XML, then both // inputs parsed correctly, and both lists should be non-null. // If we get here and the compare type was Auto, then one // or both lists may be null, so we'll fallthrough to the text // handling logic. } if (af == null || bf == null) { af = new FileContentInfo(); bf = new FileContentInfo(); af.Lines = DiffUtility.GetStringTextLines(textA, progress); bf.Lines = DiffUtility.GetStringTextLines(textB, progress); } af.TextContent = textA; bf.TextContent = textB; DiffBinaryTextResults result = new DiffBinaryTextResults(CompareType.Text, af, bf); return(result); }
private DiffBinaryTextResults GetTextLines(DiffBinaryTextResults src , TextBinaryDiffArgs args , IDiffProgress progress) { IList <string> a = null, b = null; bool isAuto = args.CompareType == CompareType.Auto; if (args.CompareType == CompareType.Xml || isAuto) { a = TryGetXmlText(DiffUtility.GetXmlTextLinesFromXml, "the left side text", src.A.TextContent, !isAuto, args, progress); // If A failed to parse with Auto, then there's no reason to try B. if (a != null) { b = TryGetXmlText(DiffUtility.GetXmlTextLinesFromXml, "the right side text", src.B.TextContent, !isAuto, args, progress); } // If we get here and the compare type was XML, then both // inputs parsed correctly, and both lists should be non-null. // If we get here and the compare type was Auto, then one // or both lists may be null, so we'll fallthrough to the text // handling logic. } if (a == null || b == null) { a = DiffUtility.GetStringTextLines(src.A.TextContent, progress); b = DiffUtility.GetStringTextLines(src.B.TextContent, progress); } else { src.IsComparedAs = CompareType.Xml; } src.A.Lines = a; src.B.Lines = b; return(src); }
public static IMember FindSimilarMember(IClass type, IMember member) { if (member is IMethod) { IMethod parentMethod = (IMethod)member; foreach (IMethod m in type.Methods) { if (string.Equals(parentMethod.Name, m.Name, StringComparison.InvariantCultureIgnoreCase)) { if (m.IsStatic == parentMethod.IsStatic) { if (DiffUtility.Compare(parentMethod.Parameters, m.Parameters) == 0) { return(m); } } } } } else if (member is IProperty) { IProperty parentMethod = (IProperty)member; foreach (IProperty m in type.Properties) { if (string.Equals(parentMethod.Name, m.Name, StringComparison.InvariantCultureIgnoreCase)) { if (m.IsStatic == parentMethod.IsStatic) { if (DiffUtility.Compare(parentMethod.Parameters, m.Parameters) == 0) { return(m); } } } } } return(null); }