Esempio n. 1
0
        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>());
        }
Esempio n. 2
0
        public virtual IEnumerable <uSyncChange> GetChanges(XElement node, XElement current, SyncSerializerOptions options)
        {
            if (serializer.IsEmpty(node))
            {
                return(GetEmptyFileChanges(node, current).AsEnumerableOfOne());
            }

            if (!serializer.IsValid(node))
            {
                // not valid
                return(uSyncChange.Error("", "Invalid File", node.Name.LocalName).AsEnumerableOfOne());
            }


            if (GetFileChange(node, current, options) == ChangeType.NoChange)
            {
                return(uSyncChange.NoChange("", node.GetAlias()).AsEnumerableOfOne());
            }

            var changes = TrackChanges();

            if (current != null)
            {
                return(CalculateChanges(changes, current, node, "", ""));
            }

            return(Enumerable.Empty <uSyncChange>());
        }
Esempio n. 3
0
        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>());
        }
Esempio n. 4
0
        public IEnumerable <uSyncChange> GetChanges(XElement target, XElement source, SyncSerializerOptions options)
        {
            if (serializer.IsEmpty(target))
            {
                return(GetEmptyFileChange(target, source).AsEnumerableOfOne());
            }

            if (!serializer.IsValid(target))
            {
                return(uSyncChange.Error("", "Invalid File", target.Name.LocalName).AsEnumerableOfOne());
            }

            var changeType = GetChangeType(target, source, options);

            if (changeType == ChangeType.NoChange)
            {
                return(uSyncChange.NoChange("", target.GetAlias()).AsEnumerableOfOne());
            }

            return(CalculateDiffrences(target, source));
        }