コード例 #1
0
 public HypermediaTypeSerializer(UnResolvedLinkResolver resolver)
 {
     if (resolver == null) {
         throw new ArgumentNullException(nameof(resolver));
     }
     _resolver = resolver;
 }
コード例 #2
0
 public HypermediaTypeSerializer(UnResolvedLinkResolver resolver)
 {
     if (resolver == null)
     {
         throw new ArgumentNullException(nameof(resolver));
     }
     _resolver = resolver;
 }
コード例 #3
0
        public override void ExecuteResult(ControllerContext context)
        {
            var resolver = new ControllerActionUrlResolver(
                new UrlHelper(context.RequestContext),
                context.HttpContext.Request.Url.Scheme,
                context.Controller.ControllerContext.RouteData.Values["controller"].ToString());

            // Todo add a way to register ILinkFilter
            var filters = new List<ILinkFilter>();
            var untypedLinksResolver = new UnResolvedLinkResolver(resolver, filters);
            var serializer = new HypermediaTypeSerializer(untypedLinksResolver);
            var instance = serializer.Serialize(_resource);

            var response = context.HttpContext.Response;
            response.ContentType = _resource.MediaType;
            response.Write(instance.ToString());
        }
コード例 #4
0
        public override void ExecuteResult(ControllerContext context)
        {
            var resolver = new ControllerActionUrlResolver(
                new UrlHelper(context.RequestContext),
                context.HttpContext.Request.Url.Scheme,
                context.Controller.ControllerContext.RouteData.Values["controller"].ToString());

            // Todo add a way to register ILinkFilter
            var filters = new List <ILinkFilter>();
            var untypedLinksResolver = new UnResolvedLinkResolver(resolver, filters);
            var serializer           = new HypermediaTypeSerializer(untypedLinksResolver);
            var instance             = serializer.Serialize(_resource);

            var response = context.HttpContext.Response;

            response.ContentType = _resource.MediaType;
            response.Write(instance.ToString());
        }