예제 #1
0
        /// <summary>
        /// Returns like metadata class used to specify URIs not associated with a specific controller method.
        /// </summary>
        /// <param name="meta">Method delegate passed metadata class used to define like metadata.</param>
        /// <returns>Reference to self for method chaining.</returns>
        public TResourceMeta LinkMeta(Action <ResourceLinkMeta <TResource> > meta)
        {
            if (meta == null)
            {
                throw new ArgumentNullException(nameof(meta), "Metadata delegate not specified.");
            }

            var resourceLinkMeta = new ResourceLinkMeta <TResource>();

            meta(resourceLinkMeta);

            AddLinks(resourceLinkMeta.GetActionLinks());
            return((TResourceMeta)this);
        }
예제 #2
0
        /// <summary>
        /// Returns link metadata class used to specify controller action methods.
        /// </summary>
        /// <typeparam name="TController">The controller type so select action method from.</typeparam>
        /// <param name="meta">Method delegate passed metadata class used to define link metadata.</param>
        /// <returns>Reference to self for method chaining.</returns>
        public TResourceMeta LinkMeta <TController>(Action <ResourceLinkMeta <TController, TResource> > meta)
            where TController : Controller
        {
            if (meta == null)
            {
                throw new ArgumentNullException(nameof(meta), "Metadata delegate not specified.");
            }

            AsertControllerMeetsConstraints(typeof(TController));

            var resourceLinkMeta = new ResourceLinkMeta <TController, TResource>();

            meta(resourceLinkMeta);

            AddLinks(resourceLinkMeta.GetActionLinks());
            return((TResourceMeta)this);
        }