Exemplo n.º 1
0
		public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller)
		{
			String className = controller.GetType().FullName.Replace('.', '/');
			
			if (className.StartsWith("SampleSite"))
			{
				className = className.Substring( "SampleSite/".Length );
			}

			controller.PropertyBag.Add("controllerfile", className + ".cs");

			return true;
		}
Exemplo n.º 2
0
		public void IncludeActions(Controller controller)
		{
			Type controllerType = controller.GetType();

			object[] atts = controllerType.GetCustomAttributes(typeof(CrudAttribute), false);

			if (atts.Length == 0)
			{
				throw new Exception("CrudAttribute not used on " + controllerType.Name);
			}

			CrudAttribute crudAtt = (CrudAttribute) atts[0];

			Type arType = crudAtt.ActiveRecordType;
			String prefix = arType.Name.ToLower();

			controller.DynamicActions["list"] = new ListAction(arType);
			controller.DynamicActions["new"] = new NewAction();
			controller.DynamicActions["create"] = new CreateAction(arType, prefix);
			controller.DynamicActions["edit"] = new EditAction(arType, prefix);
			controller.DynamicActions["update"] = new UpdateAction(arType, prefix);
			controller.DynamicActions["confirmdelete"] = new ConfirmDeleteAction(arType, prefix);
			controller.DynamicActions["delete"] = new DeleteAction(arType, prefix);
		}