private static void MapDomResourceToApiAttributes(ISetAttributes apiSetAttributes, DomReadWriteResource domResource) { Contract.Requires(apiSetAttributes != null); Contract.Requires(domResource != null); var domAttributesNode = domResource.GetNode <DomNodeType, DomAttributes>(DomNodeType.Attributes); if (domAttributesNode == null) { return; } var domAttributeCollection = domAttributesNode.Nodes() .Cast <DomAttribute>() .ToList(); if (!domAttributeCollection.Any()) { return; } var apiObject = CreateApiObjectFromDomAttributeCollection(domAttributeCollection); apiSetAttributes.Attributes = apiObject; }
public static void MapDomResourceToClrAttributes(this IResourceType resourceType, object clrResource, DomReadWriteResource domResource) { Contract.Requires(resourceType != null); Contract.Requires(clrResource != null); Contract.Requires(domResource != null); var domAttributesNode = domResource.GetNode <DomNodeType, DomAttributes>(DomNodeType.Attributes); if (domAttributesNode == null) { return; } var domAttributeNodes = domAttributesNode.Nodes() .Cast <DomAttribute>() .ToList(); foreach (var domAttributeNode in domAttributeNodes) { var clrPropertyName = domAttributeNode.ClrPropertyName; var clrPropertyValue = domAttributeNode.ClrAttribute; var clrAttribute = resourceType.GetClrAttributeInfo(clrPropertyName); clrAttribute.SetClrProperty(clrResource, clrPropertyValue); } }
private static Relationships GetApiResourceRelationships(DomReadWriteResource domResource) { Contract.Requires(domResource != null); var domRelationshipsNode = domResource.GetNode(DomNodeType.Relationships); if (domRelationshipsNode == null) { return(null); } var domRelationships = (IDomRelationships)domRelationshipsNode; var apiRelationships = domRelationships.Relationships; return(apiRelationships); }
private static void MapDomResourceToApiId(ISetResourceIdentity apiSetResourceIdentity, DomReadWriteResource domResource) { Contract.Requires(apiSetResourceIdentity != null); Contract.Requires(domResource != null); var domIdNode = domResource.GetNode <DomNodeType, DomId>(DomNodeType.Id); if (domIdNode == null) { return; } var apiId = domIdNode.ApiId; apiSetResourceIdentity.Id = apiId; }
private static void MapDomResourceToApiType(ISetResourceIdentity apiSetResourceIdentity, DomReadWriteResource domResource) { Contract.Requires(apiSetResourceIdentity != null); Contract.Requires(domResource != null); var domTypeNode = domResource.GetNode <DomNodeType, DomType>(DomNodeType.Type); if (domTypeNode == null) { return; } var apiResourceType = domTypeNode.ApiType; apiSetResourceIdentity.Type = apiResourceType; }
private static Links GetApiResourceLinks(DomReadWriteResource domResource) { Contract.Requires(domResource != null); var domLinksNode = domResource.GetNode(DomNodeType.Links); if (domLinksNode == null) { return(null); } var domLinks = (IDomLinks)domLinksNode; var apiLinks = domLinks.Links; return(apiLinks); }
public static void MapDomResourceToClrId(this IResourceType resourceType, object clrResource, DomReadWriteResource domResource) { Contract.Requires(resourceType != null); Contract.Requires(clrResource != null); Contract.Requires(domResource != null); var domIdNode = domResource.GetNode <DomNodeType, DomId>(DomNodeType.Id); if (domIdNode == null) { return; } var clrId = domIdNode.ClrId; resourceType.SetClrId(clrResource, clrId); }
private static void MapDomResourceToApiMeta(ISetMeta apiSetMeta, DomReadWriteResource domResource) { Contract.Requires(apiSetMeta != null); Contract.Requires(domResource != null); var domMetaNode = domResource.GetNode(DomNodeType.Meta); if (domMetaNode == null) { return; } var domMeta = (IDomMeta)domMetaNode; var apiMeta = domMeta.Meta; apiSetMeta.Meta = apiMeta; }
public static void MapDomResourceToClrLinks(this IResourceType resourceType, object clrResource, DomReadWriteResource domResource) { Contract.Requires(resourceType != null); Contract.Requires(clrResource != null); Contract.Requires(domResource != null); var domLinksNode = domResource.GetNode(DomNodeType.Links); if (domLinksNode == null) { return; } var domLinks = (IDomLinks)domLinksNode; var clrLinks = domLinks.Links; resourceType.SetClrLinks(clrResource, clrLinks); }
public static void MapDomResourceToClrMeta(this IResourceType resourceType, object clrResource, DomReadWriteResource domResource) { Contract.Requires(resourceType != null); Contract.Requires(clrResource != null); Contract.Requires(domResource != null); var domMetaNode = domResource.GetNode(DomNodeType.Meta); if (domMetaNode == null) { return; } var domMeta = (IDomMeta)domMetaNode; var clrMeta = domMeta.Meta; resourceType.SetClrMeta(clrResource, clrMeta); }