Example #1
0
        protected void Visit(ExpNode caller, ExpNode node, XmlElement parentNode)
        {
            nodeStack.Push(node);
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node is KeyedResourceInstance && (!(node is AssociationResourceInstance)))
            {
                KeyedResourceInstance e = (KeyedResourceInstance)node;
                CreateEntryElement(e, parentNode);
            }
            else if (node is AssociationResourceInstance)
            {
                AssociationResourceInstance e = (AssociationResourceInstance)node;
                if (caller == null)
                {
                    CreateLinkPayload(e, parentNode);
                }
                else
                {
                    CreateBinding(e, parentNode);
                }
            }
            //Below are two special cases
            else if (caller == null && node is ResourceInstanceSimpleProperty)
            {
                this.VisitResourceInstanceSimpleProperty(node as ResourceInstanceSimpleProperty, parentNode);
            }
            else if (caller == null && node is ResourceInstanceComplexProperty)
            {
                this.VisitResourceInstanceComplexProperty(node as ResourceInstanceComplexProperty, parentNode);
            }
            else if (caller == null && node is ResourceInstanceNavRefProperty)
            {
                ResourceInstanceNavRefProperty navRef = node as ResourceInstanceNavRefProperty;
                AssociationResourceInstance    associationResourceInstance = navRef.TreeNode as AssociationResourceInstance;
                if (associationResourceInstance != null && associationResourceInstance.Operation == AssociationOperation.Remove)
                {
                    this.CreateUnBinding(parentNode);
                }
                else
                {
                    throw new Exception("Unknown node type:" + navRef.TreeNode.GetType());
                }
            }
            else if (caller == null && node is ResourceInstanceCollection)
            {
                ResourceInstanceCollection collection = node as ResourceInstanceCollection;
                CreateLinksElement(collection, null);
            }
            else
            {
                throw new Exception("Unknown node type: " + node.GetType());
            }
            nodeStack.Pop();
        }
Example #2
0
        private void CreateLinksElement(ResourceInstanceCollection collection, XmlElement parentNode)
        {
            XmlElement linksElement = this.CreateDataWebMetadataElement("links");

            if (collection.NodeList.Count == 0)
            {
                Console.WriteLine("got here");
            }
            foreach (ResourceBodyTree tree in collection.NodeList)
            {
                AssociationResourceInstance associationResourceInstance = tree as AssociationResourceInstance;
                if (associationResourceInstance == null)
                {
                    throw new Microsoft.Test.ModuleCore.TestFailedException("Tree should only be Associations, assuming this tree is doing a bind");
                }
                this.CreateLinkPayload(associationResourceInstance, linksElement);
            }
            if (parentNode == null)
            {
                document.AppendChild(linksElement);
            }
        }
Example #3
0
 public ResourceInstanceNavColProperty(string propertyName, params ResourceBodyTree[] updateTrees)
     : base(propertyName)
 {
     TestUtil.CheckArgumentElementsNotNull(updateTrees, "updateTrees");
     _resourceInstanceCollection = new ResourceInstanceCollection(updateTrees);
 }