public void Invoke(AspectContext container, AspectIntercept intercept) { if (intercept == AspectIntercept.Prolog) { var builder = new StringBuilder(); builder.Append(string.Format("{0} with Parameters: ", container.Name)); foreach (var param in container) { builder.Append(string.Format("{0} : {1} | ", param.Name, param.Value)); } Console.WriteLine(builder.ToString()); } if (intercept == AspectIntercept.Epilog) { Console.WriteLine(container.HasReturnValue ? string.Format("{0} returned with value {1}", container.Name, container.ReturnValue) : string.Format("{0} returned", container.Name)); } if (intercept == AspectIntercept.Exception) { Console.WriteLine(string.Format("EXCPETION in {0} with message: {1}", container.Name, container.Exception.Message)); container.IsHandeled = true; } }
/// <summary> /// Initializes a new instance of the <see cref="AspectAttribute"/> class. /// </summary> /// <param name="aspect">The type of the aspect. Needs to implement IAspec if a non manipulating aspect, otherwise IManupulatinAspect</param> /// <param name="behaivor">The behaivor.</param> /// <param name="strategy">The strategy.</param> /// <param name="manupilatesState">if set to <c>true</c> the value of the context can be replaced by this aspect</param> public AspectAttribute(Type aspect, AspectIntercept behaivor, AspectStrategy strategy, bool manupilatesState) { if (aspect.GetInterface(typeof(IAspect).ToString()) == null) throw new ArgumentException(string.Format("{0} does not implement IAspect", aspect)); this.Aspect = aspect; this.Intercept = behaivor; this.Strategy = strategy; }
public void Invoke(AspectContext container, AspectIntercept intercept) { container.Implementation(); }
protected abstract object ManipulateInternal(AspectContext container, AspectIntercept intercept);
protected abstract void InvokeInternal(AspectContext container, AspectIntercept intercept);
public object Manipulate(AspectContext container, AspectIntercept intercept) { var ret = this.ManipulateInternal(container, intercept); container.IsManipulated = true; return ret; }
public void Invoke(AspectContext container, AspectIntercept intercept) { this.InvokeInternal(container, intercept); }