Exemplo n.º 1
0
        /// <summary>
        /// 添加一个绑定操作
        /// </summary>
        /// <typeparam name="T">绑定对象类型</typeparam>
        /// <param name="action">一个 BindAction 类型的对象,他保存了执行绑定操作所需的数据</param>
        protected void AddAction <T>(HtmlBindingAction <T> action) where T : IHtmlElement
        {
            VerifyAccess();

            if (this != Current)//禁止在非当前上下文操作。
            {
                throw new InvalidOperationException();
            }

            _actionList.Add(action);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 将一个绑定操作放到绑定上下文
        /// </summary>
        /// <param name="element">要执行绑定操作的元素</param>
        /// <param name="action">要对元素执行的绑定操作</param>
        /// <returns>被执行绑定操作的元素</returns>
        public static IHtmlElement BindAction(this IHtmlElement element, Action <IHtmlElement> action)
        {
            var instance = new HtmlBindingAction <IHtmlElement>()
            {
                Target = element,
                Action = action
            };

            BindingContext.Action(instance);

            return(element);
        }
Exemplo n.º 3
0
 public static void Action <T>(HtmlBindingAction <T> action) where T : IHtmlElement
 {
     Current.AddAction(action);
 }