public ResolvedRoute ReferenceToRoute(HypermediaObjectReferenceBase reference)
        {
            var lookupType = reference.GetHypermediaType();

            // ExternalReference object is not registered in the RouteRegister and provides its own URI

            if (externalReferenceTypeInfo.IsAssignableFrom(lookupType))
            {
                if (!(reference.GetInstance() is ExternalReference externalReferenceObject))
                {
                    throw new HypermediaRouteException("Can not get instance for ExternalReference.");
                }

                // we assume get here since external references will be links only for now
                return(new ResolvedRoute(externalReferenceObject.ExternalUri.ToString(), HttpMethod.GET, externalReferenceObject.AvailableMediaTypes));
            }

            if (internalReferenceTypeInfo.IsAssignableFrom(lookupType))
            {
                if (!(reference.GetInstance() is InternalReference internalReference))
                {
                    throw new HypermediaRouteException("Can not get instance for InternalReference.");
                }

                // we assume get here since external references will be links only for now
                var routeInfo             = new RouteInfo(internalReference.RouteName, HttpMethod.GET);
                var resolvedInternalRoute = RouteUrl(routeInfo, internalReference.RouteParameters);
                resolvedInternalRoute.AvailableMediaTypes = internalReference.AvailableMediaTypes;
                return(resolvedInternalRoute);
            }

            if (reference is HypermediaExternalObjectReference)
            {
                throw new HypermediaRouteException("Can not get instance for HypermediaExternalObjectReference.");
            }

            var routeKeys = this.routeKeyFactory.GetHypermediaRouteKeys(reference);

            return(this.GetRouteByType(lookupType, routeKeys));
        }
        public ResolvedRoute RouteUrl(RouteInfo routeInfo, object routeKeys = null)
        {
            var urlString = this.urlHelper.RouteUrl(routeInfo.Name, routeKeys, hypermediaUrlConfig.Scheme, hypermediaUrlConfig.Host.ToUriComponent());

            return(new ResolvedRoute(urlString, routeInfo.HttpMethod, acceptableMediaType: routeInfo.AcceptableMediaType));
        }