public static IRoutingBuilder AddProfilesController(this IRoutingBuilder builder, ProfilesRoleConfiguration roles) { builder.AddController <ProfilesController>(controller => { controller.AddRoute("profiles", c => c.Create(From.Body <CreateProfileRequest>())) .HttpPost() .Authorize(); controller.AddRoute("profiles", c => c.Read()) .HttpGet() .Authorize(); controller.AddRoute("{accountId}/profile", c => c.ReadById(From.Route <int>())) .HttpGet() .Authorize(); controller.AddRoute("profiles", c => c.Update(From.Body <UpdateProfileRequest>())) .HttpPut() .Authorize(); controller.AddRoute("profiles", c => c.Delete(From.Any <DeleteProfileRequest>())) .HttpDelete() .Authorize(); controller.AddRoute("admin/profiles", c => c.AdminRead(From.Query <FilterRequest>())) .HttpGet() .Authorize(roles.Admin); controller.AddRoute("admin/profiles/{profileId}", c => c.AdminReadById(From.Route <int>())) .HttpGet() .Authorize(roles.Admin); controller.AddRoute("admin/profiles/{profileId}", c => c.AdminUpdateById(From.Body <AdminUpdateByIdProfileRequest>(), From.Route <int>())) .HttpPut() .Authorize(roles.Admin); controller.AddRoute("admin/profiles/{profileId}", c => c.AdminDeleteById(From.Route <AdminDeleteByIdProfileRequest>())) .HttpDelete() .Authorize(roles.Admin); }); return(builder); }
// Used for Debug only public override string ToString() { var toReturn = "<div>" + Id + " : " + Name + "<br/>" + "Consumable? " + Consumed + Gold; if (Into != null && Into.Any()) { toReturn += "Builds into " + Into.Count() + " items. <br />"; } if (From != null && From.Any()) { toReturn += "Builds from " + From.Count() + " items."; } toReturn += "</div>"; return(toReturn); }
public void FromAny() { services.AddMvcCore() .AddRouting(routing => routing.AddController <TestController>("test", controller => controller.AddRoute("works", c => c.TestMethod(From.Any <string>())))); var provider = services.BuildServiceProvider(); var options = provider.GetRequiredService <IOptions <RoutingOptions> >().Value; var(_, parameterMetadata) = Assert.Single(options.Parameters); Assert.Equal(BindingSource.Custom, parameterMetadata.BindingSource); }