コード例 #1
0
ファイル: CoreDispatcher.cs プロジェクト: karthi1015/Revit
        /// <summary>
        /// 由Id唤醒方法
        /// </summary>
        /// <param name="commandData"></param>
        /// <param name="message"></param>
        /// <param name="elements"></param>
        /// <param name="strUseId"></param>
        /// <returns></returns>
        private Result InvokeById(ExternalCommandData commandData, ref string message, ElementSet elements, string strUseId)
        {
            //实际处理器
            IExternalCommand tempCommand = null;

            //设置addinId
            DEBUGUtility.SetAddInId(strUseId);

            //缓存判断
            if (!m_useCommandObject.ContainsKey(strUseId))
            {
                //获取命令对象
                var useCommandPacker = m_useCMDDic[strUseId];

                object tempCommandObj = CreatObjByHandlerInfo(useCommandPacker);

                //多态转换
                tempCommand = tempCommandObj as IExternalCommand;

                m_useCommandObject.Add(strUseId, tempCommand);
            }
            else
            {
                tempCommand = m_useCommandObject[strUseId];
            }

            //若是debug模式不单例命令对象
            if (DEBUGUtility.IfDebugModel)
            {
                //清除已缓存命令对象
                m_useCommandObject.Remove(strUseId);
            }

            return(tempCommand.Execute(commandData, ref message, elements));
        }
コード例 #2
0
        public static Result RunCommand <T>() where T : IExternalCommand
        {
            Result           result = Result.Failed;
            Type             type   = typeof(T);
            IExternalCommand icmd   = Activator.CreateInstance(type) as IExternalCommand;

            result = icmd.Execute(Helper.CommandData, ref Helper.Message, Helper.ElementSet);
            return(Result.Succeeded);
        }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiApp = commandData.Application;
            UIDocument    uiDoc = uiApp.ActiveUIDocument;

            s_last_executed_command.Execute(commandData, ref message, elements);

            return(Result.Succeeded);
        }
コード例 #4
0
        Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                AppDomain.CurrentDomain.AssemblyResolve += App.OnAssemblyResolve;

                return(_Command.Execute(commandData, ref message, elements));
            }
            finally
            {
                AppDomain.CurrentDomain.AssemblyResolve -= App.OnAssemblyResolve;
            }
        }