/// <summary> /// Apply a policy to an entity to create a resource. /// </summary> /// <typeparam name="T">Type of entity being converted.</typeparam> /// <param name="entity">Entity being converted.</param> /// <param name="policy">Policy to apply</param> /// <returns>Resource that was created.</returns> private static Resource <T> ApplyPolicy <T>(T entity, IPolicy policy) where T : class { var resource = new Resource <T>(entity) { Type = policy.ResourceType(entity), Id = policy.ResourceIdentity(entity), Links = (Links)policy.ResourceLinks(entity), Meta = (Meta)policy.ResourceMeta(entity) }; return(resource); }