Beispiel #1
0
        // Single event and object
        public void Verify(XObjectChange expectedEvent, Object expectedObject)
        {
            TestLog.Compare(_events.Count, 1, "Mismatch in expected number of events");
            EventItem item = _events.Dequeue();

            TestLog.Compare(item.EventArgs.ObjectChange, expectedEvent, "Event Type Mismatch");
            TestLog.Compare(item.Sender, (XObject)expectedObject, "Object Mismatch");
        }
Beispiel #2
0
 // Number of events of a certain type are expected to be thrown
 public void Verify(XObjectChange expectedEvent, int expectedCount)
 {
     TestLog.Compare(_events.Count, expectedCount, "Mismatch in expected number of events");
     while (_events.Count > 0)
     {
         EventItem item = _events.Dequeue();
         TestLog.Compare(item.EventArgs.ObjectChange, expectedEvent, "Event Type Mismatch");
     }
 }
Beispiel #3
0
 // Number of events of a certain type are expected to be thrown
 public void Verify(XObjectChange expectedEvent, int expectedCount)
 {
     TestLog.Compare(_events.Count, expectedCount, "Mismatch in expected number of events");
     while (_events.Count > 0)
     {
         EventItem item = _events.Dequeue();
         TestLog.Compare(item.EventArgs.ObjectChange, expectedEvent, "Event Type Mismatch");
     }
 }
Beispiel #4
0
 // Know exactly what events should be thrown and in what order
 public void Verify(XObjectChange[] expectedEvents)
 {
     TestLog.Compare(_events.Count, expectedEvents.Length, "Mismatch in expected number of events");
     int i = 0;
     while (_events.Count > 0)
     {
         EventItem item = _events.Dequeue();
         TestLog.Compare(item.EventArgs.ObjectChange, expectedEvents[i], "Event Type Mismatch");
         i++;
     }
 }
Beispiel #5
0
 private static void WriteElementInfo(string action, XObjectChange change, XObject xobj)
 {
     if (xobj != null)
     {
         Console.WriteLine($"XObject: <{xobj.NodeType.ToString()}> " +
                           $"{action} {change} with value {xobj}");
     }
     else
     {
         Console.WriteLine($"XObject: <{xobj.NodeType.ToString()}> " +
                           $"{action} {change} with null value");
     }
 }
Beispiel #6
0
        // Same event for many different objects
        public void Verify(XObjectChange expectedEvent, Object[] expectedObjects)
        {
            TestLog.Compare(_events.Count, expectedObjects.Length, "Mismatch in expected number of events");
            int i = 0;

            while (_events.Count > 0)
            {
                EventItem item = _events.Dequeue();
                TestLog.Compare(item.EventArgs.ObjectChange, expectedEvent, "Event Type Mismatch");
                TestLog.Compare(item.Sender, (XObject)expectedObjects[i], "Object Mismatch");
                i++;
            }
        }
Beispiel #7
0
        private EntityChange XChangeToEntityChange(XObjectChange xchange)
        {
            switch (xchange)
            {
            case XObjectChange.Add: return(EntityChange.Add);

            case XObjectChange.Remove: return(EntityChange.Remove);

            case XObjectChange.Value: return(EntityChange.Modified);

            case XObjectChange.Name: throw new InvalidOperationException("Changing the name of an XObject is not supported in the model.");

            default: throw new NotImplementedException("Unhandled XObjectChage: " + xchange);
            }
        }
Beispiel #8
0
        // One event for one object
        public void Verify(XObjectChange expectedEvent, XObject expectedObject)
        {
            TestLog.Compare(_events.Count, 1, "Mismatch in expected number of events");
            EventItem item = _events.Dequeue();

            TestLog.Compare(item.EventArgs.ObjectChange, expectedEvent, "Event Type Mismatch");
            if (item.Sender is XAttribute)
            {
                TestLog.Compare(_attributeComparer.Equals((XAttribute)item.Sender, (XAttribute)expectedObject), "Attribute Mismatch");
            }
            else
            {
                TestLog.Compare(_nodeComparer.Equals((XNode)item.Sender, expectedObject), "Node Mismatch");
            }
        }
Beispiel #9
0
        private static void InjectInheritanceConnectorCommand(
            CommandProcessorContext commandProcessorContext, HashSet <ShapeChangeInformation> shapeChangeInfoSet,
            Diagram diagram, EntityTypeBaseType baseType, XObjectChange changeAction)
        {
            // First check to see if there is already a change in the original transaction
            // for the InheritanceConnector that matches the one that we're getting
            var shapeChangeInfoToQuery = new ShapeChangeInformation
            {
                ChangeType    = changeAction,
                ModelEFObject = baseType.OwnerEntityType,
                DiagramId     = diagram.Id.Value
            };

            var shapeChangeInfoExists = shapeChangeInfoSet.Contains(shapeChangeInfoToQuery);

            if (changeAction == XObjectChange.Add &&
                shapeChangeInfoExists == false)
            {
                var participatingEntityTypes = new List <EntityType>();

                var derivedEntityType = baseType.Parent as EntityType;
                Debug.Assert(derivedEntityType != null, "Where is the parent EntityType of this BaseType attribute?");

                if (derivedEntityType != null)
                {
                    // The inheritance connector is added if
                    // - the participating entities exists in the diagram.
                    // or
                    // - the participating entities will be added in the current transaction.
                    participatingEntityTypes.Add(derivedEntityType);
                    participatingEntityTypes.Add(((ConceptualEntityType)derivedEntityType).BaseType.Target);

                    foreach (var entityType in participatingEntityTypes)
                    {
                        if (diagram.EntityTypeShapes.Where(ets => ets.EntityType.Target == entityType).Any() ||
                            shapeChangeInfoSet.Where(
                                sc =>
                                sc.DiagramId == diagram.Id.Value && sc.ModelEFObject == entityType && sc.ChangeType == XObjectChange.Add)
                            .Any())
                        {
                            continue;
                        }
                        // If it reach this point, that means that we should not add inheritance connector in the diagram.
                        return;
                    }
                    var cmd = new CreateInheritanceConnectorCommand(diagram, derivedEntityType);
                    CommandProcessor.InvokeSingleCommand(commandProcessorContext, cmd);
                }
            }
            else if (changeAction == XObjectChange.Remove &&
                     shapeChangeInfoExists == false)
            {
                // this is happening before the transaction is taking place so we are free to look up anti-dependencies
                // on this delete
                var owningEntityType = baseType.Parent as EntityType;
                if (owningEntityType != null)
                {
                    foreach (
                        var inheritanceConnector in
                        owningEntityType.GetAntiDependenciesOfType <InheritanceConnector>()
                        .Where(ic => ic.Diagram != null && ic.Diagram.Id == diagram.Id.Value))
                    {
                        if (inheritanceConnector != null)
                        {
                            var deleteInheritanceConnectorCommand = inheritanceConnector.GetDeleteCommand();
                            CommandProcessor.InvokeSingleCommand(commandProcessorContext, deleteInheritanceConnectorCommand);
                        }
                    }
                }
            }
        }
Beispiel #10
0
        private static void InjectEntityTypeShapeCommand(
            CommandProcessorContext commandProcessorContext, HashSet <ShapeChangeInformation> shapeChangeInfoSet, Diagram diagram,
            ConceptualEntityType entityType, XObjectChange changeAction)
        {
            // First check to see if there is already a change in the original transaction
            // for the EntityTypeShape that matches the one that we're getting
            var shapeChangeInfoToQuery = new ShapeChangeInformation
            {
                ChangeType    = changeAction,
                ModelEFObject = entityType,
                DiagramId     = diagram.Id.Value
            };

            var shapeChangeInfoExists = shapeChangeInfoSet.Contains(shapeChangeInfoToQuery);

            // We only want to create model diagram if the transaction is originated from this diagram.
            if (changeAction == XObjectChange.Add)
            {
                // We only want to inject the entity-type-shape if the transaction is originated from the passed in diagram.
                if (commandProcessorContext != null &&
                    commandProcessorContext.EfiTransaction != null)
                {
                    var contextItem =
                        commandProcessorContext.EfiTransaction.GetContextValue <DiagramContextItem>(
                            EfiTransactionOriginator.TransactionOriginatorDiagramId);

                    if (contextItem != null &&
                        contextItem.DiagramId == diagram.Id.Value)
                    {
                        // look in the dictionary for an 'add' to an EntityTypeShape that points to this modelobject.
                        if (shapeChangeInfoExists == false)
                        {
                            var cmd = new CreateEntityTypeShapeCommand(diagram, entityType);
                            CommandProcessor.InvokeSingleCommand(commandProcessorContext, cmd);
                        }

                        // We have the ability to create an EntityType and an Inheritance in one transaction, so we need
                        // to check for it here.
                        if (entityType.BaseType.Target != null)
                        {
                            InjectInheritanceConnectorCommand(
                                commandProcessorContext, shapeChangeInfoSet, diagram, entityType.BaseType, changeAction);
                        }
                    }
                }
            }
            else if (changeAction == XObjectChange.Remove &&
                     shapeChangeInfoExists == false)
            {
                // this is happening before the transaction is taking place so we are free to look up anti-dependencies
                // on this delete
                foreach (
                    var entityTypeShape in
                    entityType.GetAntiDependenciesOfType <EntityTypeShape>()
                    .Where(ets => ets.Diagram != null && ets.Diagram.Id == diagram.Id.Value))
                {
                    if (entityTypeShape != null)
                    {
                        var deleteEntityTypeShapeCommand = entityTypeShape.GetDeleteCommand();
                        CommandProcessor.InvokeSingleCommand(commandProcessorContext, deleteEntityTypeShapeCommand);
                    }
                }
            }
        }
Beispiel #11
0
        private static void InjectInheritanceConnectorCommand(
            CommandProcessorContext commandProcessorContext, HashSet<ShapeChangeInformation> shapeChangeInfoSet,
            Diagram diagram, EntityTypeBaseType baseType, XObjectChange changeAction)
        {
            // First check to see if there is already a change in the original transaction 
            // for the InheritanceConnector that matches the one that we're getting
            var shapeChangeInfoToQuery = new ShapeChangeInformation
                {
                    ChangeType = changeAction,
                    ModelEFObject = baseType.OwnerEntityType,
                    DiagramId = diagram.Id.Value
                };

            var shapeChangeInfoExists = shapeChangeInfoSet.Contains(shapeChangeInfoToQuery);

            if (changeAction == XObjectChange.Add
                && shapeChangeInfoExists == false)
            {
                var participatingEntityTypes = new List<EntityType>();

                var derivedEntityType = baseType.Parent as EntityType;
                Debug.Assert(derivedEntityType != null, "Where is the parent EntityType of this BaseType attribute?");

                if (derivedEntityType != null)
                {
                    // The inheritance connector is added if
                    // - the participating entities exists in the diagram.
                    // or
                    // - the participating entities will be added in the current transaction.
                    participatingEntityTypes.Add(derivedEntityType);
                    participatingEntityTypes.Add(((ConceptualEntityType)derivedEntityType).BaseType.Target);

                    foreach (var entityType in participatingEntityTypes)
                    {
                        if (diagram.EntityTypeShapes.Where(ets => ets.EntityType.Target == entityType).Any()
                            || shapeChangeInfoSet.Where(
                                sc =>
                                sc.DiagramId == diagram.Id.Value && sc.ModelEFObject == entityType && sc.ChangeType == XObjectChange.Add)
                                   .Any())
                        {
                            continue;
                        }
                        // If it reach this point, that means that we should not add inheritance connector in the diagram.
                        return;
                    }
                    var cmd = new CreateInheritanceConnectorCommand(diagram, derivedEntityType);
                    CommandProcessor.InvokeSingleCommand(commandProcessorContext, cmd);
                }
            }
            else if (changeAction == XObjectChange.Remove
                     && shapeChangeInfoExists == false)
            {
                // this is happening before the transaction is taking place so we are free to look up anti-dependencies
                // on this delete
                var owningEntityType = baseType.Parent as EntityType;
                if (owningEntityType != null)
                {
                    foreach (
                        var inheritanceConnector in
                            owningEntityType.GetAntiDependenciesOfType<InheritanceConnector>()
                                .Where(ic => ic.Diagram != null && ic.Diagram.Id == diagram.Id.Value))
                    {
                        if (inheritanceConnector != null)
                        {
                            var deleteInheritanceConnectorCommand = inheritanceConnector.GetDeleteCommand();
                            CommandProcessor.InvokeSingleCommand(commandProcessorContext, deleteInheritanceConnectorCommand);
                        }
                    }
                }
            }
        }
 public AddNodeChange(XObject node, XObjectChange change)
     : base(node, change)
 {
 }
Beispiel #13
0
 // One event for one object
 public void Verify(XObjectChange expectedEvent, XObject expectedObject)
 {
     TestLog.Compare(_events.Count, 1, "Mismatch in expected number of events");
     EventItem item = _events.Dequeue();
     TestLog.Compare(item.EventArgs.ObjectChange, expectedEvent, "Event Type Mismatch");
     if (item.Sender is XAttribute)
         TestLog.Compare(_attributeComparer.Equals((XAttribute)item.Sender, (XAttribute)expectedObject), "Attribute Mismatch");
     else
         TestLog.Compare(_nodeComparer.Equals((XNode)item.Sender, expectedObject), "Node Mismatch");
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XObjectChangeEventArgs"/> class.
 /// </summary>
 public XObjectChangeEventArgs(XObjectChange objectChange)
 {
     _objectChange = objectChange;
 }
 // Summary:
 //     Initializes a new instance of the System.Xml.Linq.XObjectChangeEventArgs
 //     class.
 //
 // Parameters:
 //   objectChange:
 //     An System.Xml.Linq.XObjectChange that contains the event arguments for LINQ
 //     to XML events.
 extern public XObjectChangeEventArgs(XObjectChange objectChange);
 public NodeValueChange(XObject node, XObjectChange change)
     : base(node, change)
 {
 }
 internal VSXmlChange(XmlModelChange modelChange)
 {
     _node = modelChange.Node;
     _action = modelChange.Action;
 }
Beispiel #18
0
 // Single event and object
 public void Verify(XObjectChange expectedEvent, Object expectedObject)
 {
     TestLog.Compare(_events.Count, 1, "Mismatch in expected number of events");
     EventItem item = _events.Dequeue();
     TestLog.Compare(item.EventArgs.ObjectChange, expectedEvent, "Event Type Mismatch");
     TestLog.Compare(item.Sender, (XObject)expectedObject, "Object Mismatch");
 }
 public AddNodeChangeInternal(XObject n, XObjectChange action)
     : base(n, action)
 {
     CompareToObject = n as XNode;
 }
Beispiel #20
0
 // Single event of specified type expected
 public void Verify(XObjectChange expectedEvent)
 {
     Verify(expectedEvent, 1);
 }
Beispiel #21
0
 // Different events for different objects
 public void Verify(XObjectChange[] expectedEvents, XObject[] expectedObjects)
 {
     TestLog.Compare(_events.Count, expectedEvents.Length, "Mismatch in expected number of events");
     int i = 0;
     while (_events.Count > 0)
     {
         EventItem item = _events.Dequeue();
         TestLog.Compare(item.EventArgs.ObjectChange, expectedEvents[i], "Event Type Mismatch");
         if (item.Sender is XAttribute)
             TestLog.Compare(_attributeComparer.Equals((XAttribute)item.Sender, (XAttribute)expectedObjects[i]), "Attribute Mismatch");
         else
             TestLog.Compare(_nodeComparer.Equals((XNode)item.Sender, expectedObjects[i]), "Node Mismatch");
         i++;
     }
 }
Beispiel #22
0
		public XObjectChangeEventArgs (XObjectChange objectChange)
		{
			this.type = objectChange;
		}
Beispiel #23
0
 /// <summary>
 /// Default ctor
 /// </summary>
 /// <param name="change">Type of change</param>
 public XObjectChangeEventArgs(XObjectChange change)
 {
     this.change = change;
 }
 public RemoveNodeChange(XObject node, XObjectChange change)
     : base(node, change)
 {
 }
Beispiel #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XObjectChangeEventArgs"/> class.
 /// </summary>
 public XObjectChangeEventArgs(XObjectChange objectChange)
 {
     _objectChange = objectChange;
 }
Beispiel #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XObjectChangeEventArgs"/> class.
 /// </summary>
 public XObjectChangeEventArgs(XObjectChange objectChange)
 {
     this.objectChange = objectChange;
 }
Beispiel #27
0
 public EntityChangeEventArgs(EntityChange change, XElement xchanged, XObjectChange xchange)
 {
     EntityChange    = change;
     XChangedElement = xchanged;
     XChange         = xchange;
 }
 public __XObjectChangeEventArgs(XObjectChange xObjectChange)
 {
     this.ObjectChange = xObjectChange;
 }
Beispiel #29
0
 public __XObjectChangeEventArgs(XObjectChange xObjectChange)
 {
     this.ObjectChange = xObjectChange;
 }
        /// <summary>
        /// Default ctor
        /// </summary>
        /// <param name="change">Type of change</param>
	    public XObjectChangeEventArgs(XObjectChange change)
	    {
	        this.change = change;
	    }
Beispiel #31
0
 // Single event of specified type expected
 public void Verify(XObjectChange expectedEvent)
 {
     Verify(expectedEvent, 1);
 }
Beispiel #32
0
        private static void InjectEntityTypeShapeCommand(
            CommandProcessorContext commandProcessorContext, HashSet<ShapeChangeInformation> shapeChangeInfoSet, Diagram diagram,
            ConceptualEntityType entityType, XObjectChange changeAction)
        {
            // First check to see if there is already a change in the original transaction 
            // for the EntityTypeShape that matches the one that we're getting
            var shapeChangeInfoToQuery = new ShapeChangeInformation
                {
                    ChangeType = changeAction,
                    ModelEFObject = entityType,
                    DiagramId = diagram.Id.Value
                };

            var shapeChangeInfoExists = shapeChangeInfoSet.Contains(shapeChangeInfoToQuery);

            // We only want to create model diagram if the transaction is originated from this diagram.
            if (changeAction == XObjectChange.Add)
            {
                // We only want to inject the entity-type-shape if the transaction is originated from the passed in diagram.
                if (commandProcessorContext != null
                    && commandProcessorContext.EfiTransaction != null)
                {
                    var contextItem =
                        commandProcessorContext.EfiTransaction.GetContextValue<DiagramContextItem>(
                            EfiTransactionOriginator.TransactionOriginatorDiagramId);

                    if (contextItem != null
                        && contextItem.DiagramId == diagram.Id.Value)
                    {
                        // look in the dictionary for an 'add' to an EntityTypeShape that points to this modelobject.
                        if (shapeChangeInfoExists == false)
                        {
                            var cmd = new CreateEntityTypeShapeCommand(diagram, entityType);
                            CommandProcessor.InvokeSingleCommand(commandProcessorContext, cmd);
                        }

                        // We have the ability to create an EntityType and an Inheritance in one transaction, so we need
                        // to check for it here.
                        if (entityType.BaseType.Target != null)
                        {
                            InjectInheritanceConnectorCommand(
                                commandProcessorContext, shapeChangeInfoSet, diagram, entityType.BaseType, changeAction);
                        }
                    }
                }
            }
            else if (changeAction == XObjectChange.Remove
                     && shapeChangeInfoExists == false)
            {
                // this is happening before the transaction is taking place so we are free to look up anti-dependencies
                // on this delete
                foreach (
                    var entityTypeShape in
                        entityType.GetAntiDependenciesOfType<EntityTypeShape>()
                            .Where(ets => ets.Diagram != null && ets.Diagram.Id == diagram.Id.Value))
                {
                    if (entityTypeShape != null)
                    {
                        var deleteEntityTypeShapeCommand = entityTypeShape.GetDeleteCommand();
                        CommandProcessor.InvokeSingleCommand(commandProcessorContext, deleteEntityTypeShapeCommand);
                    }
                }
            }
        }
Beispiel #33
0
 public XObjectChangeEventArgs(XObjectChange objectChange);
Beispiel #34
0
        private static void InjectAssociationConnectorCommand(
            CommandProcessorContext commandProcessorContext, HashSet<ShapeChangeInformation> shapeChangeInfoSet, Diagram diagram,
            Association association, XObjectChange changeAction)
        {
            // First check to see if there is already a change in the original transaction 
            // for the AssociationConnector that matches the one that we're getting
            var shapeChangeInfoToQuery = new ShapeChangeInformation
                {
                    ChangeType = changeAction,
                    ModelEFObject = association,
                    DiagramId = diagram.Id.Value
                };

            var shapeChangeInfoExists = shapeChangeInfoSet.Contains(shapeChangeInfoToQuery);

            // We only want to create model diagram if the transaction is originated from this diagram.
            if (changeAction == XObjectChange.Add
                && shapeChangeInfoExists == false)
            {
                // The association connector is added if
                // - the participating entities are in the diagram.
                // or
                // - the participating entities will be added in the current transaction.
                foreach (var end in association.AssociationEnds())
                {
                    if (end.Type != null
                        && end.Type.Target != null)
                    {
                        if (diagram.EntityTypeShapes.Where(ets => ets.EntityType.Target == end.Type.Target).Any()
                            || shapeChangeInfoSet.Where(
                                sc =>
                                sc.DiagramId == diagram.Id.Value && sc.ModelEFObject == end.Type.Target
                                && sc.ChangeType == XObjectChange.Add).Any())
                        {
                            continue;
                        }
                    }
                    // If it reach this point, that means that we should not add association connector in the diagram.
                    return;
                }
                var cmd = new CreateAssociationConnectorCommand(diagram, association);
                CommandProcessor.InvokeSingleCommand(commandProcessorContext, cmd);
            }
            else if (changeAction == XObjectChange.Remove
                     && shapeChangeInfoExists == false)
            {
                // this is happening before the transaction is taking place so we are free to look up anti-dependencies on this delete
                foreach (
                    var associationConnector in
                        association.GetAntiDependenciesOfType<AssociationConnector>()
                            .Where(ac => ac.Diagram != null && ac.Diagram.Id == diagram.Id.Value))
                {
                    if (associationConnector != null)
                    {
                        var deleteAssociationConnectorCommand = associationConnector.GetDeleteCommand();
                        CommandProcessor.InvokeSingleCommand(commandProcessorContext, deleteAssociationConnectorCommand);
                    }
                }
            }
        }
 internal VSXmlChange(XmlModelChange modelChange)
 {
     _node   = modelChange.Node;
     _action = modelChange.Action;
 }
 public SimpleXmlChange(XObject n, XObjectChange a)
 {
     node = n;
     action = a;
 }