private void initialize() { // By default, entries are handled by a simple field based binding var defaultTemplate = new FieldBasedBinding <ListEntryOutputType, ListEntryOutputType>(this); defaultTemplate.SetGetter((value) => value); defaultTemplate.SetSetter((ref ListEntryOutputType current, ListEntryOutputType newValue) => current = newValue); entryBindingTemplate = defaultTemplate; // Capsule entry value properties valueGetter = (boundList) => { List <ListEntryOutputType> list = new List <ListEntryOutputType>(boundList.Count); for (int i = 0; i < boundList.Count; i++) { list.Add(entryValueGetter(boundList[i])); } return(list); }; valueSetter = (ref List <ListEntryType> boundList, List <ListEntryOutputType> newValueList) => { boundList.Clear(); foreach (ListEntryOutputType entry in newValueList) { ListEntryType updatedEntry = default; entryValueSetter(updatedEntry, entry); boundList.Add(updatedEntry); } }; }
public FieldBasedBinding(FieldBasedBinding <InputType, OutputType> other) : base(other) { children = new Dictionary <string, IDataBindingInput <OutputType> >(other.children); foreach (IDataBinding child in children.Values) { child.Parent = this; } }
/// <summary> /// Creates a subbinding to the currently managed one. /// </summary> /// <typeparam name="MemberOutputType">Type that is returned by the subbinding.</typeparam> /// <param name="fieldName">Path of the subbinding.</param> /// <returns></returns> public FieldBasedBindingSetup <OutputType, MemberOutputType> BindMember <MemberOutputType>(string fieldName) { PathElement pe = new PathElement(fieldName); FieldBasedBinding <OutputType, MemberOutputType> memberBinding = new FieldBasedBinding <OutputType, MemberOutputType>(ManagedBinding); ManagedBinding.AddSubBinding(memberBinding, pe); // Start new setup for member object FieldBasedBindingSetup <OutputType, MemberOutputType> memberSetup = new FieldBasedBindingSetup <OutputType, MemberOutputType>(memberBinding); return(memberSetup); }
public FieldBasedBindingSetup(FieldBasedBinding <InputType, OutputType> managedBinding) : base(managedBinding) { this.ManagedBinding = managedBinding; }