コード例 #1
0
        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);
                }
            };
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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;
        }
コード例 #4
0
 public FieldBasedBinding <ListEntryOutputType, ListEntryOutputType> BindEntryTemplate()
 {
     entryBindingTemplate = new FieldBasedBinding <ListEntryOutputType, ListEntryOutputType>(this);
     return(entryBindingTemplate as FieldBasedBinding <ListEntryOutputType, ListEntryOutputType>);
 }
コード例 #5
0
 public EntryNode BindEntryTemplate <EntryNode>(EntryNode objectBinding)
     where EntryNode : IDataBindingInput <ListEntryOutputType>
 {
     entryBindingTemplate = objectBinding;
     return((EntryNode)entryBindingTemplate);
 }
コード例 #6
0
 public ListBasedBinding(ListBasedBinding <ListEntryType, ListEntryOutputType> other) : base(other)
 {
     valueGetter          = other.valueGetter;
     valueSetter          = other.valueSetter;
     entryBindingTemplate = other.entryBindingTemplate.Clone() as IDataBindingInput <ListEntryOutputType>;
 }