private static void ResolveResourceLinks(DomReadWriteResource domReadWriteResource,
                                                 IHypermediaContext hypermediaContext,
                                                 IHypermediaAssembler hypermediaAssembler,
                                                 IResourcePathContext resourcePathContext,
                                                 Type clrResourceType,
                                                 object clrResource)
        {
            var domLinks = (IDomLinks)domReadWriteResource.GetNode(DomNodeType.Links);

            if (domLinks == null || domLinks.IsReadOnly)
            {
                return;
            }

            var domReadWriteLinks = (DomReadWriteLinks)domLinks;

            foreach (var domLink in domReadWriteLinks.Nodes().Cast <IDomLink>())
            {
                ResolveResourceLink(domLink, hypermediaContext, hypermediaAssembler, resourcePathContext, clrResourceType, clrResource, domReadWriteLinks);
            }
        }
        private void ResolveResourceRelationships(DomReadWriteResource domReadWriteResource,
                                                  IHypermediaContext hypermediaContext,
                                                  IHypermediaAssembler hypermediaAssembler,
                                                  IResourcePathContext resourcePathContext,
                                                  Type clrResourceType,
                                                  object clrResource)
        {
            var domRelationships = (IDomRelationships)domReadWriteResource.GetNode(DomNodeType.Relationships);

            if (domRelationships == null || domRelationships.IsReadOnly)
            {
                return;
            }

            var domReadWriteRelationships = (DomReadWriteRelationships)domRelationships;

            foreach (var domRelationship in domReadWriteRelationships.Nodes().Cast <IDomRelationship>())
            {
                this.ResolveResourceRelationship(domRelationship, hypermediaContext, hypermediaAssembler, resourcePathContext, clrResourceType, clrResource, domReadWriteRelationships);
            }
        }
Exemplo n.º 3
0
        // PUBLIC METHODS ///////////////////////////////////////////////////
        #region Assert Methods
        public static void Equal(Resource expected, DomReadWriteResource actual)
        {
            if (expected == null)
            {
                Assert.Null(actual);
                return;
            }
            Assert.NotNull(actual);

            Assert.Equal(DomNodeType.Resource, actual.NodeType);

            // Type
            var domType = actual.GetNode <DomNodeType, DomType>(DomNodeType.Type);

            DomTypeAssert.Equal(expected.Type, domType);

            // Id
            var domId = actual.GetNode <DomNodeType, DomId>(DomNodeType.Id);

            DomIdAssert.Equal(expected.Id, domId);

            // Attributes
            var domAttributes = actual.GetNode <DomNodeType, DomAttributes>(DomNodeType.Attributes);

            DomAttributesAssert.Equal(expected.Attributes, domAttributes);

            // Relationships
            var domRelationships = actual.GetNode(DomNodeType.Relationships);

            DomRelationshipsAssert.Equal(expected.Relationships, domRelationships);

            // Links
            var domLinks = actual.GetNode(DomNodeType.Links);

            DomLinksAssert.Equal(expected.Links, domLinks);

            // Meta
            var domMeta = actual.GetNode(DomNodeType.Meta);

            DomMetaAssert.Equal(expected.Meta, domMeta);
        }