public void Process(IEngineContext context, IController controller, IControllerContext controllerContext) { InitializeTemplateEngine(); ControllerMetaDescriptor desc = controllerContext.ControllerDescriptor; IDictionary<string, IDynamicAction> dynamicActions = controllerContext.DynamicActions; bool useDefaultLayout = desc.Layout == null; if (desc.Scaffoldings.Count == 1) { ScaffoldingAttribute scaffoldAtt = desc.Scaffoldings[0]; dynamicActions["new"] = new NewAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["create"] = new CreateAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["edit"] = new EditAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["update"] = new UpdateAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["remove"] = new RemoveAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["confirm"] = new ConfirmRemoveAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["list"] = new ListAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); } else { foreach (ScaffoldingAttribute scaffoldAtt in desc.Scaffoldings) { String name = scaffoldAtt.Model.Name; dynamicActions[String.Format("new{0}", name)] = new NewAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("create{0}", name)] = new CreateAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("edit{0}", name)] = new EditAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("update{0}", name)] = new UpdateAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("remove{0}", name)] = new RemoveAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("confirm{0}", name)] = new ConfirmRemoveAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("list{0}", name)] = new ListAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); } } }
public void Process(IEngineContext context, IController controller, IControllerContext controllerContext) { InitializeTemplateEngine(); var desc = controllerContext.ControllerDescriptor; var dynamicActions = controllerContext.DynamicActions; var useDefaultLayout = desc.Layout == null; if (desc.Scaffoldings.Count == 1) { var scaffoldAtt = desc.Scaffoldings[0]; dynamicActions["new"] = new NewAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["create"] = new CreateAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["edit"] = new EditAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["update"] = new UpdateAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["remove"] = new RemoveAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["confirm"] = new ConfirmRemoveAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); dynamicActions["list"] = new ListAction(scaffoldAtt.Model, templateEngine, false, useDefaultLayout); } else { foreach (var scaffoldAtt in desc.Scaffoldings) { var name = scaffoldAtt.Model.Name; dynamicActions[String.Format("new{0}", name)] = new NewAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("create{0}", name)] = new CreateAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("edit{0}", name)] = new EditAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("update{0}", name)] = new UpdateAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("remove{0}", name)] = new RemoveAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("confirm{0}", name)] = new ConfirmRemoveAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); dynamicActions[String.Format("list{0}", name)] = new ListAction(scaffoldAtt.Model, templateEngine, true, useDefaultLayout); } } }