Пример #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);
                }
            };
        }