Beispiel #1
0
        /// <summary>
        /// Data binding method.
        /// </summary>
        /// <typeparam name="TView">View type</typeparam>
        /// <typeparam name="TProperty">Property type</typeparam>
        /// <param name="self">View</param>
        /// <param name="setter">Target value setter</param>
        /// <param name="source">Source property</param>
        /// <returns>Data binding token</returns>
        public static IDisposable SetBinding <TView, TProperty>(
            this TView self,
            Action <TView, TProperty> setter,
            ReadOnlyReactiveProperty <TProperty> source)
            where TView : UIBarItem
        {
            var d = new CompositeDisposable();

            source
            .Subscribe(x => setter(self, x))
            .AddTo(d);

            return(d);
        }
        /// <summary>
        /// Data binding method.
        /// </summary>
        /// <typeparam name="TView">View type</typeparam>
        /// <typeparam name="TProperty">Property type</typeparam>
        /// <param name="self">View</param>
        /// <param name="propertySelector">Target property selector</param>
        /// <param name="source">Source property</param>
        /// <returns>Data binding token</returns>
        public static IDisposable SetBindingTableViewDataSource <TView, TProperty>(
            this TView self,
            Expression <Func <TView, TProperty> > propertySelector,
            ReadOnlyReactiveProperty <TProperty> source)
            where TView : IUITableViewDataSource
        {
            var d = new CompositeDisposable();

            var setter = AccessorCache <TView> .LookupSet(propertySelector, out var propertyName);

            source
            .Subscribe(x => setter(self, x))
            .AddTo(d);
            return(d);
        }
        /// <summary>
        /// Data binding method.
        /// </summary>
        /// <typeparam name="TView">View type</typeparam>
        /// <typeparam name="TProperty">Property type</typeparam>
        /// <param name="self">View</param>
        /// <param name="propertySelector">Target property selector</param>
        /// <param name="source">Source property</param>
        /// <returns>Data binding token</returns>
        public static IDisposable SetBindingGestureRecognizer <TView, TProperty>(
            this TView self,
            Expression <Func <TView, TProperty> > propertySelector,
            ReadOnlyReactiveProperty <TProperty> source)
            where TView : UIGestureRecognizer
        {
            var d = new CompositeDisposable();

            string propertyName;
            var    setter = AccessorCache <TView> .LookupSet(propertySelector, out propertyName);

            source
            .Subscribe(x => setter(self, x))
            .AddTo(d);
            return(d);
        }