示例#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");
        }
示例#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");
     }
 }
示例#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");
     }
 }
示例#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++;
     }
 }
示例#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");
     }
 }
示例#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++;
            }
        }
示例#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);
            }
        }
示例#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");
            }
        }
示例#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);
                        }
                    }
                }
            }
        }
示例#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);
                    }
                }
            }
        }
示例#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)
 {
 }
示例#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;
 }
示例#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;
 }
示例#20
0
 // Single event of specified type expected
 public void Verify(XObjectChange expectedEvent)
 {
     Verify(expectedEvent, 1);
 }
示例#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++;
     }
 }
示例#22
0
		public XObjectChangeEventArgs (XObjectChange objectChange)
		{
			this.type = objectChange;
		}
示例#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)
 {
 }
示例#25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XObjectChangeEventArgs"/> class.
 /// </summary>
 public XObjectChangeEventArgs(XObjectChange objectChange)
 {
     _objectChange = objectChange;
 }
示例#26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XObjectChangeEventArgs"/> class.
 /// </summary>
 public XObjectChangeEventArgs(XObjectChange objectChange)
 {
     this.objectChange = objectChange;
 }
示例#27
0
 public EntityChangeEventArgs(EntityChange change, XElement xchanged, XObjectChange xchange)
 {
     EntityChange    = change;
     XChangedElement = xchanged;
     XChange         = xchange;
 }
 public __XObjectChangeEventArgs(XObjectChange xObjectChange)
 {
     this.ObjectChange = xObjectChange;
 }
示例#29
0
 public __XObjectChangeEventArgs(XObjectChange xObjectChange)
 {
     this.ObjectChange = xObjectChange;
 }
示例#30
0
        /// <summary>
        /// Default ctor
        /// </summary>
        /// <param name="change">Type of change</param>
	    public XObjectChangeEventArgs(XObjectChange change)
	    {
	        this.change = change;
	    }
示例#31
0
 // Single event of specified type expected
 public void Verify(XObjectChange expectedEvent)
 {
     Verify(expectedEvent, 1);
 }
示例#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);
                    }
                }
            }
        }
示例#33
0
 public XObjectChangeEventArgs(XObjectChange objectChange);
示例#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);
                    }
                }
            }
        }
示例#35
0
 internal VSXmlChange(XmlModelChange modelChange)
 {
     _node   = modelChange.Node;
     _action = modelChange.Action;
 }
 public SimpleXmlChange(XObject n, XObjectChange a)
 {
     node = n;
     action = a;
 }