示例#1
0
 internal HypermediaActionResult(IHypermediaResource resource)
 {
     if (resource == null)
     {
         throw new ArgumentNullException(nameof(resource));
     }
     _resource = resource;
 }
        /// <summary>
        /// Given an entity and its matching json schema, generate links from templates defined in the schema
        /// using properties of the entity.
        /// </summary>
        /// <param name="schema">The schema json in string form</param>
        /// <param name="entity">The entity for which the utility generates links for</param>
        /// <returns></returns>
        public IEnumerable <Link> GetLinks(string schema, IHypermediaResource entity)
        {
            var parsedSchema = JsonSchema.Parse(schema);

            entity.Validate(parsedSchema, Serializer);
            var links = GetLinksFromSchema(schema);

            EnrichLinksWithData(entity, links);
            return(links);
        }
        public void SetUp()
        {
            var helper    = new FileHelper();
            var rawSchema = helper.GetResourceTextFile("person-schema.json");

            personSchema = JsonSchema.Parse(rawSchema);
            resource     = new Person()
            {
                FamilyName      = "Doe",
                GivenName       = "John",
                HonorificPrefix = "Mr.",
                HonorificSuffix = "III",
                Id = "12345",
            };
        }
 internal HypermediaActionResult(IHypermediaResource resource)
 {
     if (resource == null) throw new ArgumentNullException(nameof(resource));
     _resource = resource;
 }
 protected internal IList <Link> EnrichLinksWithData(IHypermediaResource entity, IList <Link> links)
 {
     return(EnrichLinksWithData(links, x => Reflection.GetPropertyValue(GetParamName(x), entity)));
 }
示例#6
0
 public PartialResourceAttribute(IHypermediaResource partialResource)
 {
     this.PartialResource = partialResource;
 }