/// <summary> /// Sets behaviour. is fluent /// </summary> /// <typeparam name="TContext"></typeparam> /// <param name="fluentObj"></param> /// <param name="name"></param> /// <param name="behaviour"></param> /// <returns></returns> public static IHasBehaviour <TContext> SetBehaviour <TContext>(this IHasBehaviour <TContext> fluentObj, string name, Delegate behaviour) { if (fluentObj == null) { return(null); } fluentObj.Behaviours[name] = behaviour; return(fluentObj); }
/// <summary> /// invokes a behaviour /// </summary> /// <typeparam name="TContext"></typeparam> /// <param name="fluentObj"></param> /// <param name="name"></param> /// <param name="args"></param> /// <returns></returns> public static object InvokeBehaviour <TContext>(this IHasBehaviour <TContext> fluentObj, string name, params object[] args) { if (fluentObj == null) { return(null); } object returnValue = null; BehaviourDelegate <TContext> beh = null; if (fluentObj.Behaviours.TryGetValue(name, out beh)) { returnValue = beh.Invoke(fluentObj.Context, args); } return(returnValue); }