Пример #1
0
        /// <summary>
        /// Modify a property mapping in place.
        /// </summary>
        /// <typeparam name="TVirtualView">The cross-platform type.</typeparam>
        /// <typeparam name="TViewHandler">The handler type.</typeparam>
        /// <param name="propertyMapper">The property mapper in which to change the mapping.</param>
        /// <param name="key">The name of the property.</param>
        /// <param name="method">The modified method to call when the property is updated.</param>
        public static void ModifyMapping <TVirtualView, TViewHandler>(this IPropertyMapper <TVirtualView, TViewHandler> propertyMapper,
                                                                      string key, Action <TViewHandler, TVirtualView, Action <IElementHandler, IElement>?> method)
            where TVirtualView : IElement where TViewHandler : IElementHandler
        {
            var previousMethod = propertyMapper.GetProperty(key);

            void newMethod(TViewHandler handler, TVirtualView view)
            {
                method(handler, view, previousMethod);
            }

            propertyMapper.Add(key, newMethod);
        }
        public static void AppendToMapping <TVirtualView, TViewHandler>(this IPropertyMapper <TVirtualView, TViewHandler> propertyMapper,
                                                                        string key, Action <TViewHandler, TVirtualView> method)
            where TVirtualView : IElement where TViewHandler : IElementHandler
        {
            var previousMethod = propertyMapper.GetProperty(key);

            void newMethod(TViewHandler handler, TVirtualView view)
            {
                previousMethod?.Invoke(handler, view);
                method(handler, view);
            }

            propertyMapper.Add(key, newMethod);
        }