123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Controls;
- namespace NEIntelligentControl2.Models.Pages
- {
- /// <summary>
- /// 页面管理
- /// </summary>
- public class PageManager : IPageAction
- {
- /// <summary>
- /// 获取页面
- /// </summary>
- /// <param name="name">页面名称</param>
- /// <returns>页面</returns>
- public Page this[string name]
- {
- get
- {
- var tp = Type.GetType($"NEIntelligentControl2.Pages.{name}");
- if (tp == null)
- {
- throw new Exception($"未发现{name}页面!");
- }
- var page = App.ServiceProvider.GetService(tp) as Page;
- /*
- * 如果页面未注册,请在App类里的ConfigureServices方法中注册这个页面(将页面添加到依赖注入框架中)
- */
- if (page == null)
- {
- throw new Exception($"{name}页面未注册!");
- }
- return page;
- }
- }
- }
- }
|