/// <summary> /// Implements advice logic. /// Usually, advice must invoke context.Proceed() /// </summary> /// <param name="context">The method advice context.</param> void IPropertyAdvice.Advise(PropertyAdviceContext context) { if (context.IsSetter && context.Value == null) { Logging.DebugMessage("Property '{0}' cannot be null on '{1}'{2}Parent object: {2}{3}", context.TargetProperty.Name, context.TargetType.FullName, Environment.NewLine, context.Target == null ? "" : context.Target.ToString()); throw new ArgumentNullException(context.TargetProperty.Name, string.Format("Property '{0}' cannot be null on '{1}'", context.TargetProperty.Name, context.TargetType.FullName)); } context.Proceed(); if (context.IsGetter && CheckOnGet && (!context.HasReturnValue || context.ReturnValue == null)) { Logging.DebugMessage("Property '{0}' cannot be null on '{1}'{2}Parent object: {2}{3}", context.TargetProperty.Name, context.TargetType.FullName, Environment.NewLine, context.Target == null ? "" : context.Target.ToString()); if (ThrowOnGet) throw new ArgumentNullException(context.TargetProperty.Name, string.Format("Property '{0}' cannot be null on '{1}'", context.TargetProperty.Name, context.TargetType.FullName)); } }
void IPropertyAdvice.Advise(PropertyAdviceContext context) { try { context.Proceed(); } catch (NullReferenceException ex) { ex.Log(string.Format("Null reference in {2}.{0}.[{1}]", context.TargetProperty.Name, context.IsGetter ? "get" : "set", context.TargetType.FullName)); throw; } catch (Exception ex) { ex.Log(context.IsGetter ? "Getter" : "Setter"); throw; } }
public void Advise(PropertyAdviceContext context) { using (var t = TracerFactory.StartTracer(context.TargetType, string.Format("{0}_{1}", context.IsGetter ? "get" : "set", context.TargetProperty.Name))) { if (info.ContainsCharacters()) t.SetAdidtionalInformation(info); try { context.Proceed(); } catch (Exception ex) { if (TreatExceptionAsInformational) t.SetException(ex); else t.SetErrorState(ex); throw; } } }
void IPropertyAdvice.Advise(PropertyAdviceContext context) { var ctx = BeforeProcessing(new ActivationContext(context)); if (ctx.ExecuteAlternate) { if (context.IsGetter && ctx.SkipTargetProcess) { var task = AlternateProceed(ctx); context.Value = task; } else AlternateProceed(ctx); } if (!ctx.SkipTargetProcess) { try { context.Proceed(); } catch (Exception ex) { HandleException(ctx,ex); throw; } } ctx = AfterProcesssing(ctx); ctx.Clean(); }
public void Advise(PropertyAdviceContext context) { context.Proceed(); }