コード例 #1
0
ファイル: LiveSpyNavPage.xaml.cs プロジェクト: lanicon/Ginger
        /// <summary>
        /// This method is used to get the new LiveSpyPage based on Context and Agent
        /// </summary>
        /// <returns></returns>
        private void LoadLiveSpyPage(Context context)
        {
            this.Dispatcher.Invoke(() =>
            {
                bool isLoaded = false;
                if (mLiveSpyPageDictonary != null && mLiveSpyPageDictonary.Count > 0 && context.Agent != null)
                {
                    AgentPageMappingHelper objHelper = mLiveSpyPageDictonary.Find(x => x.ObjectAgent.DriverType == context.Agent.DriverType &&
                                                                                  x.ObjectAgent.ItemName == context.Agent.ItemName);
                    if (objHelper != null && objHelper.ObjectWindowPage != null)
                    {
                        mCurrentLoadedPage = (LiveSpyPage)objHelper.ObjectWindowPage;
                        isLoaded           = true;
                    }
                }

                if (!isLoaded)
                {
                    ApplicationAgent appAgent = AgentHelper.GetAppAgent(mContext.BusinessFlow.CurrentActivity, mContext.Runner, mContext);
                    if (appAgent != null)
                    {
                        mCurrentLoadedPage = new LiveSpyPage(mContext, mDriver);
                        if (mLiveSpyPageDictonary == null)
                        {
                            mLiveSpyPageDictonary = new List <AgentPageMappingHelper>();
                        }
                        mLiveSpyPageDictonary.Add(new AgentPageMappingHelper(context.Agent, mCurrentLoadedPage));
                    }
                }

                xSelectedItemFrame.Content = mCurrentLoadedPage;
            });
        }