public IRecordService <TID> ExecuteAction(IExecutableAction <TID> implementation, bool executeAgainstAggregate = false)
        {
            this.policy.Execute(() =>
            {
                if (executeAgainstAggregate)
                {
                    implementation.Execute(AggregateId);
                }
                else
                {
                    if (!CreatedRecords.Any())
                    {
                        throw new ArgumentException("You must create records before executing an action against them");
                    }
                    implementation.Execute(CreatedRecords.Last().Key);
                }
            });

            return(this);
        }
Beispiel #2
0
		/// <summary>
		/// Identifies if no filter should run for the given action.
		/// </summary>
		/// <param name="action">The action.</param>
		/// <returns></returns>
		protected virtual bool ShouldSkipFilters(IExecutableAction action)
		{
			if (filters == null)
			{
				// No filters, so skip 
				return true;
			}

			return action.ShouldSkipAllFilters;

			//			ActionMetaDescriptor actionMeta = MetaDescriptor.GetAction(method);
			//
			//			if (actionMeta.SkipFilters.Count == 0)
			//			{
			//				// Nothing against filters declared for this action
			//				return false;
			//			}
			//
			//			foreach(SkipFilterAttribute skipfilter in actionMeta.SkipFilters)
			//			{
			//				// SkipAllFilters handling...
			//				if (skipfilter.BlanketSkip)
			//				{
			//					return true;
			//				}
			//
			//				filtersToSkip[skipfilter.FilterType] = String.Empty;
			//			}
			//
			//			return false;
		}
Beispiel #3
0
		private void RunAfterRenderingFilters(IExecutableAction action)
		{
			if (action.ShouldSkipAllFilters)
			{
				return;
			}

			ProcessFilters(action, ExecuteWhen.AfterRendering);
		}
Beispiel #4
0
		private void RunAfterActionFilters(IExecutableAction action, out bool cancel)
		{
			cancel = false;
			if (action == null)
			{
				return;
			}

			if (action.ShouldSkipAllFilters)
			{
				return;
			}

			if (!ProcessFilters(action, ExecuteWhen.AfterAction))
			{
				cancel = true;
				return; // A filter returned false... so we stop
			}
		}
Beispiel #5
0
		/// <summary>
		/// Ensures the action is accessible with current HTTP verb.
		/// </summary>
		/// <param name="action">The action.</param>
		protected virtual void EnsureActionIsAccessibleWithCurrentHttpVerb(IExecutableAction action)
		{
			Verb allowedVerbs = action.AccessibleThroughVerb;

			if (allowedVerbs == Verb.Undefined)
			{
				return;
			}

			string method = engineContext.Request.HttpMethod;

			Verb currentVerb = (Verb) Enum.Parse(typeof(Verb), method, true);

			if ((allowedVerbs & currentVerb) != currentVerb)
			{
				throw new MonoRailException(403, "Forbidden",
				                            string.Format("Access to the action [{0}] " +
				                                          "on controller [{1}] is not allowed to the http verb [{2}].",
				                                          Action, Name, method));
			}
		}
Beispiel #6
0
		/// <summary>
		/// Configures the cache policy.
		/// </summary>
		/// <param name="action">The action.</param>
		protected virtual void ConfigureCachePolicy(IExecutableAction action)
		{
			ICachePolicyConfigurer configurer = action.CachePolicyConfigurer ?? MetaDescriptor.CacheConfigurer;

			configurer.Configure(Response.CachePolicy);
		}
Beispiel #7
0
		/// <summary>
		/// Resolves the layout override for the specified action
		/// </summary>
		/// <param name="action">The action.</param>
		protected virtual void ResolveLayout(IExecutableAction action)
		{
			if (action.LayoutOverride != null && action.LayoutOverride.Length != 0)
			{
				context.LayoutNames = action.LayoutOverride;
			}
		}
 private void ExecuteAction(IExecutableAction action)
 {
     threading.ReentrancyGuard.ExecuteOrQueue(EternalLifetime.Instance, "AgentAction",
                                              () => actionManager.ExecuteActionIfAvailable(action));
 }
Beispiel #9
0
		/// <summary>
		/// Creates the controller level resources.
		/// </summary>
		/// <param name="action">The action.</param>
		protected virtual void CreateActionLevelResources(IExecutableAction action)
		{
			CreateResources(action.Resources);
		}
		private IEnumerable<FilterDescriptor> GetActionLevelFilters(IExecutableAction action)
		{
			return action.ActionLevelFilters.OrderBy(descriptor => descriptor.ExecutionOrder);
		}
		protected virtual bool ProcessFilters(IExecutableAction action, ExecuteWhen when)
		{

			foreach(var desc in filters.Union(GetActionLevelFilters(action)))
			{
				if (action.ShouldSkipFilter(desc.FilterType))
				{
					continue;
				}

				if ((desc.When & when) != 0)
				{
					if (!ProcessFilter(when, desc))
					{
						return false;
					}
				}
			}

			return true;
		}
Beispiel #12
0
        protected override IExecutableAction GetShortcutAction(TextWriter textwriter)
        {
            IExecutableAction jumpToTestFileAction = JumpToTestFileAction.CreateWith(CreateJetPopMenuShowToWriterAction(textwriter));

            return(jumpToTestFileAction);
        }
 public void RemoveHandler(IExecutableAction handler)
 {
     //_handlers.RemoveHandler(handler);
 }
 public void AddHandler(Lifetime lifetime, IExecutableAction handler)
 {
     // _handlers.AddHandler(handler);
 }
Beispiel #15
0
		private bool ProcessFilters(IExecutableAction action, ExecuteWhen when)
		{
			foreach(FilterDescriptor desc in filters)
			{
				if (action.ShouldSkipFilter(desc.FilterType))
				{
					continue;
				}

				if ((desc.When & when) != 0)
				{
					if (!ProcessFilter(when, desc))
					{
						return false;
					}
				}
			}

			return true;
		}
Beispiel #16
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="action"></param>
		protected virtual void CreateTransformsFilters(IExecutableAction action)
		{
			if (action == null)
			{
				return;
			}

			ITransformFilterFactory transformFilterFactory = engineContext.Services.TransformFilterFactory;

			foreach(TransformFilterDescriptor transformFilter in action.TransformFilters)
			{
				ITransformFilter filter = transformFilterFactory.Create(transformFilter.TransformFilterType,
				                                                        engineContext.UnderlyingContext.Response.Filter);
				engineContext.UnderlyingContext.Response.Filter = filter as Stream;
			}
		}
Beispiel #17
0
		/// <summary>
		/// Performs the rescue.
		/// </summary>
		/// <param name="action">The action (can be null in the case of dynamic actions).</param>
		/// <param name="actionException">The exception.</param>
		/// <returns></returns>
		protected virtual bool ProcessRescue(IExecutableAction action, Exception actionException)
		{
			if (action != null && action.ShouldSkipRescues)
			{
				return false;
			}

			Type exceptionType = actionException.GetType();

			RescueDescriptor desc = action != null ? action.GetRescueFor(exceptionType) : null;

			if (desc == null)
			{
				desc = GetControllerRescueFor(exceptionType);
			}

			if (desc != null)
			{
				try
				{
					if (desc.RescueController != null)
					{
						CreateAndProcessRescueController(desc, actionException);
					}
					else
					{
						context.SelectedViewName = Path.Combine("rescues", desc.ViewName);

						ProcessView();
					}

					return true;
				}
				catch(Exception exception)
				{
					// In this situation, the rescue view could not be found
					// So we're back to the default error exibition

					if (logger.IsFatalEnabled)
					{
						logger.Fatal("Failed to process rescue view. View name " +
						                   context.SelectedViewName, exception);
					}
				}
			}

			return false;
		}
 /// <summary>
 /// Execute Action against the id of the last created record
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="implementation"></param>
 /// <returns></returns>
 public IRecordService <TID> ExecuteAction <T>(IExecutableAction <T, TID> implementation)
 {
     implementation.Execute(CreatedRecords.Last().Key);
     return(this);
 }