public void Test() { //builds a fluento that has an echo behaviour FluentObject<Void> o = new FluentObject<Void>(); o.WithBehaviour<string, string>("echo") .Does((context, arg) => { return arg; }) .TriggeredWhen((context) => { //trigger an echo when it's tuesday return new FuncCondition( () => { return DateTime.Now.DayOfWeek == DayOfWeek.Tuesday; }); }, (context) => { return "hey! it's tuesday"; }); }
public static void MapPropertyToFluentObject(this PropertyInfo prop, object source, ref FluentObject target) { if (prop == null) return; if (source == null) throw new ArgumentNullException("source", "Parameter 'source' should not be null."); var fluentPropertyAttribute = prop.GetCustomAttributes(typeof(FluentPropertyAttribute), false).SingleOrDefault() as FluentPropertyAttribute; if (fluentPropertyAttribute == null) return; if (fluentPropertyAttribute.IsReadony) return; var condition = prop.ValidateCondition(); if (!condition) return; var dependency = prop.ValidateDependencyCondition(source); if (!dependency) return; prop.SetValue(source, ref target); }
public static T MapFromFluentObject<T>(this FluentObject source) where T : class, new() { return (T)source.MapFromFluentObject(typeof(T)); }