Esempio n. 1
0
        /// <summary>
        /// See <see cref="IBuilderStrategy.TearDown"/> for more information.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public override object TearDown(IBuilderContext context, object item)
        {
            WorkItem workItem = StrategyUtility.GetWorkItem(context, item);

            if (workItem != null)
            {
                IDataListViewService dataService = workItem.Services.Get <IDataListViewService>();

                if (dataService != null && item is IDataListView)
                {
                    IDataListView handler = item as IDataListView;
                    dataService.UnRegister(handler);
                }
            }

            return(base.TearDown(context, item));
        }
Esempio n. 2
0
        /// <summary>
        /// See <see cref="IBuilderStrategy.BuildUp"/> for more information.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="typeToBuild"></param>
        /// <param name="existing"></param>
        /// <param name="idToBuild"></param>
        /// <returns></returns>
        public override object BuildUp(IBuilderContext context, Type typeToBuild, object existing, string idToBuild)
        {
            WorkItem workItem = StrategyUtility.GetWorkItem(context, existing);

            if (workItem != null)
            {
                IDataListViewService dataService = workItem.Services.Get <IDataListViewService>();

                // 如果视图实现了数据列表服务则在系统中注册它
                if (dataService != null && existing is IDataListView)
                {
                    IDataListView handler = existing as IDataListView;
                    dataService.Register(handler);
                }
            }

            return(base.BuildUp(context, typeToBuild, existing, idToBuild));
        }