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 IDataBindingInput <ListEntryOutputType> BindingAt(int index) { IDataBindingInput <ListEntryOutputType> newBinding = (IDataBindingInput <ListEntryOutputType>)entryBindingTemplate.Clone(); PathElement pe = new PathElement(index); newBinding.LocalPath = pe; newBinding.Parent = this; return(newBinding); }
public void AddSubBinding(IDataBindingInput <OutputType> subBinding, PathElement pe) { if (pe.Type != PathElement.PathElementType.Member) { throw new ArgumentException("Field based bindings may only hold children with member typed path elements."); } subBinding.LocalPath = pe; subBinding.ManagingScope = ManagingScope; children[pe.FieldName] = subBinding; }
public FieldBasedBinding <ListEntryOutputType, ListEntryOutputType> BindEntryTemplate() { entryBindingTemplate = new FieldBasedBinding <ListEntryOutputType, ListEntryOutputType>(this); return(entryBindingTemplate as FieldBasedBinding <ListEntryOutputType, ListEntryOutputType>); }
public EntryNode BindEntryTemplate <EntryNode>(EntryNode objectBinding) where EntryNode : IDataBindingInput <ListEntryOutputType> { entryBindingTemplate = objectBinding; return((EntryNode)entryBindingTemplate); }
public ListBasedBinding(ListBasedBinding <ListEntryType, ListEntryOutputType> other) : base(other) { valueGetter = other.valueGetter; valueSetter = other.valueSetter; entryBindingTemplate = other.entryBindingTemplate.Clone() as IDataBindingInput <ListEntryOutputType>; }