public virtual IEnumerable <uSyncChange> GetChanges(XElement node, SyncSerializerOptions options) { if (serializer.IsEmpty(node)) { return(GetEmptyFileChanges(node).AsEnumerableOfOne()); } if (!serializer.IsValid(node)) { // not valid return(uSyncChange.Error("", "Invalid File", node.Name.LocalName).AsEnumerableOfOne()); } if (serializer.IsCurrent(node) == ChangeType.NoChange) { return(uSyncChange.NoChange("", node.GetAlias()).AsEnumerableOfOne()); } var changes = TrackChanges(); var item = serializer.FindItem(node); if (item != null) { var current = SerializeItem(item, options); if (current.Success) { return(CalculateChanges(changes, current.Item, node, "", "")); } } return(Enumerable.Empty <uSyncChange>()); }
private ChangeType GetFileChange(XElement node, XElement current, SyncSerializerOptions options) { switch (serializer) { case ISyncNodeSerializer <TObject> nodeSerializer: return(nodeSerializer.IsCurrent(node, current, options)); case ISyncOptionsSerializer <TObject> optionSerializer: return(optionSerializer.IsCurrent(node, options)); default: return(serializer.IsCurrent(node)); } }
private ChangeType GetChangeType(XElement target, XElement source, SyncSerializerOptions options) { switch (serializer) { case ISyncNodeSerializer <TObject> nodeSerializer: return(nodeSerializer.IsCurrent(target, source, options)); case ISyncOptionsSerializer <TObject> optionSerializer: return(optionSerializer.IsCurrent(target, options)); default: return(serializer.IsCurrent(target)); } }
public virtual IEnumerable <uSyncChange> GetChanges(XElement node) { if (serializer.IsEmpty(node)) { return(GetEmptyFileChanges(node).AsEnumerableOfOne()); } if (!serializer.IsValid(node)) { // not valid return(new uSyncChange() { Change = ChangeDetailType.Error, Name = "Invalid File", OldValue = node.Name.LocalName }.AsEnumerableOfOne());; } if (serializer.IsCurrent(node) == ChangeType.NoChange) { return(new uSyncChange() { Change = ChangeDetailType.NoChange, Name = node.GetAlias(), }.AsEnumerableOfOne()); } var changes = TrackChanges(); var item = serializer.FindItem(node); if (item != null) { var current = serializer.Serialize(item); if (current.Success) { return(CalculateChanges(changes, current.Item, node, "", "")); } } return(Enumerable.Empty <uSyncChange>()); }
protected uSyncAction ReportItem(string file) { try { var node = syncFileService.LoadXElement(file); try { var change = serializer.IsCurrent(node); var action = uSyncActionHelper <TObject> .ReportAction(change, node.GetAlias()); action.Message = ""; if (action.Change > ChangeType.NoChange) { action.Details = tracker.GetChanges(node); if (action.Details == null || action.Details.Count() == 0) { action.Message = "Change details cannot be calculated"; } action.Message = $"{action.Change.ToString()}"; } return(action); } catch (FormatException fex) { return(uSyncActionHelper <TObject> .ReportActionFail(Path.GetFileName(file), $"format error {fex.Message}")); } } catch (Exception ex) { return(uSyncActionHelper <TObject> .ReportActionFail(Path.GetFileName(file), $"Reporing error {ex.Message}")); } }