Esempio n. 1
0
 void IEventsVisitor.Visit(ParentChildRelationChange parentChildRelationChange)
 {
     CreateElement(SC.Elt_ParentChildRelationChange, parentChildRelationChange.Trigger,
                   new XAttribute(SC.Attr_ObjectId, parentChildRelationChange.ObjectId),
                   MakeNullableAttr(SC.Attr_NewParentObjectId, parentChildRelationChange.NewParentObjectId),
                   parentChildRelationChange.IsWeak ? new XAttribute(SC.Attr_IsWeak, "1") : null,
                   MakeTagsAttr(parentChildRelationChange)
                   );
 }
Esempio n. 2
0
        public bool TryDeserialize(XElement elt, out Event ret)
        {
            ret = null;
            switch (elt.Name.LocalName)
            {
            case SC.Elt_ObjectCreation:
                ret = new ObjectCreation(
                    MakeTrigger(elt),
                    objectIdsPool.Intern(Attr(elt, SC.Attr_ObjectId)),
                    objectInfoPool.Intern(new ObjectTypeInfo(
                                              Attr(elt, SC.Attr_ObjectType),
                                              Attr(elt, SC.Attr_CommentPropertyName),
                                              Attr(elt, SC.Attr_PrimaryPropertyName),
                                              (Attr(elt, SC.Attr_IsTimeless) ?? "0") == "1"
                                              )),
                    isWeak: (Attr(elt, SC.Attr_IsWeak) ?? "0") == "1",
                    displayName: Attr(elt, SC.Attr_DisplayNamePropertyName)
                    );
                break;

            case SC.Elt_ObjectDeletion:
                ret = new ObjectDeletion(MakeTrigger(elt), objectIdsPool.Intern(Attr(elt, SC.Attr_ObjectId)), null);
                break;

            case SC.Elt_PropertyChange:
                ret = new PropertyChange(MakeTrigger(elt),
                                         objectIdsPool.Intern(Attr(elt, SC.Attr_ObjectId)),
                                         null,
                                         propertyName: propNamesPool.Intern(Attr(elt, SC.Attr_PropertyName)),
                                         value: Attr(elt, SC.Attr_Value),
                                         oldValue: Attr(elt, SC.Attr_OldValue),
                                         valueType: ToValueType(Attr(elt, SC.Attr_ValueType)));
                break;

            case SC.Elt_ParentChildRelationChange:
                ret = new ParentChildRelationChange(
                    MakeTrigger(elt),
                    objectIdsPool.Intern(Attr(elt, SC.Attr_ObjectId)),
                    null,
                    newParentObjectId: objectIdsPool.Intern(Attr(elt, SC.Attr_NewParentObjectId)),
                    isWeak: (Attr(elt, SC.Attr_IsWeak) ?? "0") == "1");
                break;
            }
            if (ret != null)
            {
                ret.Tags = tagsPool.Intern(
                    new HashSet <string>((Attr(elt, SC.Attr_Tags) ?? "").Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)));
            }
            return(ret != null);
        }
Esempio n. 3
0
        void IEventsVisitor.Visit(ParentChildRelationChange parentChildEvt)
        {
            var obj    = GetObject(parentChildEvt.ObjectId);
            var parent = GetObject(parentChildEvt.NewParentObjectId);

            if (obj.Parent != null)
            {
                if (parentChildEvt.IsWeak)
                {
                    return;
                }
                else
                {
                    obj.Parent.RemoveChild(obj);
                }
            }
            obj.SetParent(parent);
            if (obj.Parent != null)
            {
                parent.AddChild(obj);
            }
        }
Esempio n. 4
0
 void IEventsVisitor.Visit(ParentChildRelationChange parentChildRelationChange)
 {
     Output.AppendFormat("ParentChildRelationChange: {0} became a child of {1}",
                         parentChildRelationChange.ObjectId, parentChildRelationChange.NewParentObjectId);
 }