Exemple #1
0
        /// <summary>
        /// Creates a list binding for the given path.
        /// </summary>
        /// <typeparam name="ListEntryType">Type of the entries of the bound list.</typeparam>
        /// <typeparam name="ListEntryOutputType">Type that the list binding should return for each input list entry.</typeparam>
        /// <param name="list">Bound list.</param>
        /// <param name="fieldName">Name of the databinding that will be used for path creation.</param>
        /// <returns>Created binding's setup class.</returns>
        public ListBasedBindingSetup <ListEntryType, ListEntryOutputType> BindList <ListEntryType, ListEntryOutputType>(List <ListEntryType> list, string fieldName)
        {
            ListBasedBinding <ListEntryType, ListEntryOutputType> listBinding = new ListBasedBinding <ListEntryType, ListEntryOutputType>(list);
            PathElement pe = new PathElement(fieldName);

            listBinding.LocalPath = pe;
            AddBinding(listBinding);
            return(new ListBasedBindingSetup <ListEntryType, ListEntryOutputType>(listBinding));
        }
Exemple #2
0
        /// <summary>
        /// Creates a list binding for the given path. Will automatically create default getter & setter for the entries.
        /// </summary>
        /// /// <remarks>
        /// This is shortcut for the fully type specified version.
        /// </remarks>
        /// <typeparam name="ListEntryType">Type of the bound list's elements. Also type that will be returned for each list element.</typeparam>
        /// <param name="list">Bound list.</param>
        /// <param name="fieldName">Name of the databinding that will be used for path creation.</param>
        /// <returns>Created binding's setup class.</returns>
        public ListBasedBindingSetup <ListEntryType, ListEntryType> BindList <ListEntryType>(List <ListEntryType> list, string fieldName)
        {
            ListBasedBinding <ListEntryType, ListEntryType> listBinding = new ListBasedBinding <ListEntryType, ListEntryType>(list);

            // Automatically create entry getter & setter
            listBinding.SetEntryGetter((entry) => entry);
            listBinding.SetEntrySetter((entry, newValue) => entry = newValue);

            PathElement pe = new PathElement(fieldName);

            listBinding.LocalPath = pe;
            AddBinding(listBinding);
            return(new ListBasedBindingSetup <ListEntryType, ListEntryType>(listBinding));
        }