Exemple #1
0
        public static IExpressionBuilder <TModel> RegisterCollection <TModel>(this IHateoasContainer container, Expression <Func <TModel, object> > relation, params Expression <Func <TModel, object> >[] identityDefinition)
        {
            var registration = new HateoasRegistration <TModel>(((MemberExpression)relation.Body).Member.Name, null, container, true, true);
            var builder      = HateoasExpressionFactory.CreateBuilder(registration);

            container.Add(registration);
            return(builder);
        }
Exemple #2
0
        public static IExpressionBuilder <TModel> Register <TModel>(this IHateoasContainer container, Expression <Func <TModel, object> > relation, params Expression <Func <TModel, object> >[] identityDefinition)
        {
            if (typeof(TModel).GetInterfaces().Contains(typeof(IEnumerable)))
            {
                throw new ArgumentException("Cannot register collections; use .RegisterCollection<TModel>(\"name\") instead");
            }

            var registration = new HateoasRegistration <TModel>(((MemberExpression)relation.Body).Member.Name, identityDefinition, container, false, true);
            var builder      = HateoasExpressionFactory.CreateBuilder(registration);

            container.Add(registration);
            return(builder);
        }
Exemple #3
0
        public static IExpressionBuilder <TModel> Register <TModel>(this IHateoasContainer container, string relation, params Expression <Func <TModel, object> >[] identityDefinition)
        {
            if (typeof(TModel).GetInterfaces().Contains(typeof(IEnumerable)))
            {
                throw new ArgumentException("Cannot register collections; use .RegisterCollection<TModel>(\"name\") instead");
            }

            // TODO The relation between (container,) registration and expression builder feels weird
            var registration = new HateoasRegistration <TModel>(relation, identityDefinition, container);
            var builder      = HateoasExpressionFactory.CreateBuilder(registration);

            container.Add(registration);
            return(builder);
        }