public void AccessingProperties() { PropertyReference prop = PropertyReference.FromLambda <UriBuilder>(s => s.Port); Expression target = pUriBuilder; Expression value = target.ReadProperty(prop); Expression assignment = target.AssignProperty(prop, Expression.Constant(8080)); cx.AddTestExpr(value, pUriBuilder); cx.AddTestExpr(assignment, pUriBuilder); cx.AddTestExpr(target.PropertyCompoundAssign(prop, "+", Expression.Constant(10)), pUriBuilder); check.CheckOutput(cx); }
/// <summary> /// Create an option definition from a setter and getter lambda. /// </summary> /// <param name="name">Name to display in options menu.</param> /// <param name="getter">Method to get the current value of the property.</param> /// <param name="setter">Method to set the value of the property (can be null if read-only)</param> /// <param name="category">Category to display the option in.</param> /// <param name="sortPriority">Sort priority to arrange the option within the category.</param> /// <returns>The created option definition.</returns> public static OptionDefinition Create <T>(string name, Func <T> getter, Action <T> setter = null, string category = "Default", int sortPriority = 0) { return(new OptionDefinition(name, category, sortPriority, PropertyReference.FromLambda(getter, setter))); }