public static IUriDefinition <T> EntryPointCollection <T>(this IUriDefinition <T> resource, Action <CollectionEntryPointOptions> options = null) { var ienum = typeof(T).GetInterfaces() .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable <>)).ToList(); if (ienum.Count != 1) { throw new ArgumentException("The resource definition implements multiple IEnumerable interfaces"); } var itemType = ienum[0].GenericTypeArguments[0]; var uriModel = resource.Uri.Hydra(); var opts = new CollectionEntryPointOptions(); options?.Invoke(opts); uriModel.CollectionItemType = itemType; uriModel.ResourceType = typeof(T); uriModel.EntryPointUri = opts.Uri ?? resource.Uri.Uri; uriModel.SearchTemplate = opts.Search; return(resource); }
public static IHandlerForResourceWithUriDefinition HandledBy <THandler>( this IUriDefinition definition, Expression <Func <THandler> > factory) { var f = factory.Compile(); return(definition.HandledBy(ContainerTypeSystem <THandler> .Create((_ => f())))); }
public static void ReverseProxyFor(this IUriDefinition uriConfiguration, string uri) { uriConfiguration .HandledBy <ReverseProxyHandler>(); var target = (IResourceTarget)uriConfiguration; target.Resource.ReverseProxyTarget(uri); }
public static IHandlerForResourceWithUriDefinition HandledBy <TArg1, TArg2, THandler>( this IUriDefinition definition, Expression <Func <TArg1, TArg2, THandler> > handlerFactory) where TArg1 : class where TArg2 : class { var f = handlerFactory.Compile(); return(definition.HandledBy(ContainerTypeSystem <THandler> .Create( resolver => f(resolver.Resolve <TArg1>(), resolver.Resolve <TArg2>())))); }
public static IUriDefinition AndAt(this IUriDefinition uriDefinition, string uri) { return(uriDefinition.And.Uri(uri)); }