/// <summary> /// Configures the builder to set a property with the informed value. /// </summary> public FluentBuilder <T> With <TProperty>(Expression <Func <T, TProperty> > expression, TProperty newValue) { var propertyName = GetMemberQuery.GetMemberNameFor(expression); _commands[propertyName] = new SetPropertyCommand(_newObject, propertyName, newValue); return(this); }
internal SetFieldCollectionCommand(object @object, string collectionName) { ValidateArguments(@object, collectionName); _object = @object; _collectionName = collectionName; _fieldInfo = GetMemberQuery.GetFieldInfoFor(_object.GetType(), _collectionName); ValidateField(); }
/// <summary> /// Configures the builder to add an element to a collection one by one. /// </summary> public FluentBuilder <T> AddingTo <TCollectionProperty, TElement>(Expression <Func <T, TCollectionProperty> > expression, TElement newElement) where TCollectionProperty : IEnumerable <TElement> { var fieldName = GetMemberQuery.GetMemberNameFor(expression); var setFieldCollectionCommand = GetCommandFor(fieldName); setFieldCollectionCommand.Add(newElement); return(this); }
/// <summary> /// Configures the builder to set a collection passing all elements at once /// </summary> public FluentBuilder <T> WithCollection <TCollectionProperty, TElement>(Expression <Func <T, TCollectionProperty> > expression, params TElement[] newElements) where TCollectionProperty : IEnumerable <TElement> { var fieldName = GetMemberQuery.GetMemberNameFor(expression); var cmd = new SetFieldCollectionCommand(_newObject, fieldName); foreach (var element in newElements) { cmd.Add(element); } _commands[fieldName] = cmd; return(this); }
public Member GetMember(string email, string password) { var q = new GetMemberQuery(_connectionString, email, password); return(q.Execute()); }
public void Should_get_property_name_for_expression() { var propertyName = GetMemberQuery.GetMemberNameFor <SampleTypeWithFieldAndProperties, int>(sampleType => sampleType.ReadOnlyPropertyWithUnderLyingField); Assert.AreEqual("ReadOnlyPropertyWithUnderLyingField", propertyName); }
public void Should_get_underlying_field_name_for_member(string memberName, string result) { var value = GetMemberQuery.GetFieldNameFor(new SampleTypeWithFieldAndProperties(), memberName); Assert.AreEqual(result, value); }
internal SetFieldCommand(object destinationObject, string fieldName, object newValue) : base(destinationObject, fieldName, newValue) { _fieldInfo = GetMemberQuery.GetFieldInfoFor(destinationObject.GetType(), fieldName); ValidateField(); }