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); }
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); }
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); }