ViewModelLocator.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. using GalaSoft.MvvmLight.Ioc;
  2. using Microsoft.Practices.ServiceLocation;
  3. using Muchinfo.MTPClient.Account.ViewModels;
  4. using Muchinfo.MTPClient.Account.ViewModels.AllOrderViewModel;
  5. using Muchinfo.MTPClient.Account.ViewModels.OrderViewModel;
  6. using Muchinfo.MTPClient.Analysis.ViewModels;
  7. using Muchinfo.MTPClient.Bank.ViewModels;
  8. using Muchinfo.MTPClient.Delivery.ViewModels;
  9. using Muchinfo.MTPClient.IService;
  10. using Muchinfo.MTPClient.Listing.ViewModel;
  11. using Muchinfo.MTPClient.Quotation.ViewModels;
  12. using Muchinfo.MTPClient.Sale.ViewModels;
  13. using Muchinfo.MTPClient.Service;
  14. using Muchinfo.MTPClient.Trade.ViewModels;
  15. using Muchinfo.MTPClient.Trade.ViewModels.ERMCP;
  16. using Muchinfo.MTPClient.UI.ViewModels;
  17. using Muchinfo.MTPClient.UI.Views;
  18. namespace Muchinfo.MTPClient.UI
  19. {
  20. public class ViewModelLocator
  21. {
  22. public static void Initialize()
  23. {
  24. ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
  25. // 注册服务
  26. RegisterServices();
  27. //注册ViewModel
  28. RegisterViewModels();
  29. RegisterView();
  30. }
  31. private static void RegisterView()
  32. {
  33. SimpleIoc.Default.Register<MainPage>();
  34. }
  35. /// <summary>
  36. /// 注册服务
  37. /// </summary>
  38. private static void RegisterServices()
  39. {
  40. SimpleIoc.Default.Register<ILoginService, LoginService>();
  41. SimpleIoc.Default.Register<IGoodsService, GoodsService>();
  42. SimpleIoc.Default.Register<IOrderService, OrderService>();
  43. SimpleIoc.Default.Register<ISystemService, SystemService>();
  44. SimpleIoc.Default.Register<IFavoriteService, FavoriteService>();
  45. SimpleIoc.Default.Register<IBankService, BankService>();
  46. SimpleIoc.Default.Register<IWarningService, WarningService>();
  47. SimpleIoc.Default.Register<IQuoteDataService, QuoteDataService>();
  48. SimpleIoc.Default.Register<INewsService, NewsService>();
  49. SimpleIoc.Default.Register<IAnnouncementService, AnnouncementService>();
  50. SimpleIoc.Default.Register<IDeliveryService, DeliveryService>();
  51. SimpleIoc.Default.Register<ISaleService, SaleService>();
  52. SimpleIoc.Default.Register<IDBTableMsgService, DBTableMsgService>();
  53. SimpleIoc.Default.Register<IListingService, ListingService>();
  54. SimpleIoc.Default.Register<IDepositService, DepositService>();
  55. SimpleIoc.Default.Register<IAnalysisService, AnalysisService>();//new 2.0
  56. SimpleIoc.Default.Register<ICommonQueryService, CommonQueryService>();//new 2.0
  57. // *************** 风管云平台 ***************
  58. SimpleIoc.Default.Register<IErmcpService, ErmcpService>();
  59. }
  60. /// <summary>
  61. /// 注册ViewModel
  62. /// </summary>
  63. private static void RegisterViewModels()
  64. {
  65. SimpleIoc.Default.Register<HomeViewModel>();
  66. SimpleIoc.Default.Register<StatusBarViewModel>();
  67. //SimpleIoc.Default.Register<OrderDetailListViewModel>();
  68. //SimpleIoc.Default.Register<CloseOrderListViewModel>();
  69. //SimpleIoc.Default.Register<HoldingDetailListViewModel>();
  70. //SimpleIoc.Default.Register<HoldingSummaryListViewModel>();
  71. SimpleIoc.Default.Register<TradeHeaderViewModel>();
  72. SimpleIoc.Default.Register<QuoteListViewModel>();
  73. SimpleIoc.Default.Register<MOrderDetailViewModel>();
  74. SimpleIoc.Default.Register<MOOrderDetailViewModel>();
  75. SimpleIoc.Default.Register<MCloseOrderViewModel>();
  76. SimpleIoc.Default.Register<MOTransactionDetailViewModel>();
  77. SimpleIoc.Default.Register<MHoldDetailViewModel>();
  78. SimpleIoc.Default.Register<MOHoldDetailViewModel>();
  79. SimpleIoc.Default.Register<MHoldSummaryViewModel>();
  80. SimpleIoc.Default.Register<MOHoldSummaryViewModel>();
  81. SimpleIoc.Default.Register<MAccountInfoViewModel>();
  82. SimpleIoc.Default.Register<MOpenCompleteViewModel>();
  83. SimpleIoc.Default.Register<MOSPSLListViewModel>();
  84. SimpleIoc.Default.Register<AccountManagerViewModel>();
  85. SimpleIoc.Default.Register<QuickOrderViewModel>();
  86. SimpleIoc.Default.Register<MainContentViewModel>();
  87. SimpleIoc.Default.Register<MenuTreeViewModel>();
  88. SimpleIoc.Default.Register<Muchinfo.MTPClient.Bank.ViewModels.AmountQueryViewModel>();
  89. SimpleIoc.Default.Register<QuerySaleGoodsViewModel>();
  90. SimpleIoc.Default.Register<ListingMarketViewModel>();
  91. SimpleIoc.Default.Register <DelistingOrderViewModel>();
  92. //预埋单查询
  93. SimpleIoc.Default.Register<PrePostDetailViewModel>();
  94. //预埋单查询-不区分市场
  95. SimpleIoc.Default.Register<MOPrePostDetailViewModel>();
  96. //配号中签
  97. SimpleIoc.Default.Register<DistributeBallotViewModel>();
  98. SimpleIoc.Default.Register<DeliveryHolderViewModel>();
  99. SimpleIoc.Default.Register<DeliveryEntructViewModel>();
  100. //交割申报
  101. //SimpleIoc.Default.Register<DeliveryOrderViewModel>();
  102. //交割仓单查询
  103. SimpleIoc.Default.Register<DeliveryWarehouseOrderViewModel>();
  104. //交割配对查询
  105. SimpleIoc.Default.Register<DeliveryMatchViewModel>();
  106. //交割-提货-查询
  107. SimpleIoc.Default.Register<TakaDeliveryGoodsQueryViewModel>();
  108. //交割-提货-申请
  109. SimpleIoc.Default.Register<TakaDeliveryGoodsApplyViewModel>();
  110. //交割 成交单
  111. SimpleIoc.Default.Register<DeliveryCompleteViewModel>();
  112. ///资金流水查询
  113. SimpleIoc.Default.Register<TaAmountLogViewModel>();
  114. ////协议平仓
  115. SimpleIoc.Default.Register<DealCloseViewModel>();
  116. SimpleIoc.Default.Register<QueryDepositApplyViewModel>();
  117. ////行情列表
  118. SimpleIoc.Default.Register<QuoteDataGridViewModel>();
  119. ////签约查询
  120. SimpleIoc.Default.Register<BankSignQueryViewModel>();
  121. ////历史单据查询
  122. SimpleIoc.Default.Register<HistoryOrderQueryViewModel>();
  123. ////查询交割商品
  124. SimpleIoc.Default.Register<ListingDeliveryGoodsViewModel>();
  125. SimpleIoc.Default.Register<MyListingOrderViewModel>();
  126. SimpleIoc.Default.Register<MyOrderViewModel>();
  127. ////五档历史
  128. SimpleIoc.Default.Register<HistoryCommissionsListViewModel>();
  129. // *************** 风管云平台 ***************
  130. // 对冲保值
  131. SimpleIoc.Default.Register<HedgingEntrustViewModel>();
  132. }
  133. /// <summary>
  134. /// Cleanups this instance.
  135. /// </summary>
  136. public static void Cleanup()
  137. {
  138. }
  139. #region ViewModels
  140. /// <summary>
  141. /// 对冲保值
  142. /// </summary>
  143. public static HedgingEntrustViewModel HedgingEntrust
  144. {
  145. get
  146. {
  147. return ServiceLocator.Current.GetInstance<HedgingEntrustViewModel>();
  148. }
  149. }
  150. /// <summary>
  151. /// 只有一个实例,在RegisterViewModels()里注册后使用ServiceLocator
  152. /// </summary>
  153. public static HomeViewModel Home
  154. {
  155. get
  156. {
  157. return ServiceLocator.Current.GetInstance<HomeViewModel>();
  158. }
  159. }
  160. /// <summary>
  161. /// 报价牌 ,k线
  162. /// </summary>
  163. public static MainContentViewModel MainContent
  164. {
  165. get
  166. {
  167. return ServiceLocator.Current.GetInstance<MainContentViewModel>();
  168. }
  169. }
  170. /// <summary>
  171. /// 主窗口
  172. /// </summary>
  173. public static MainPage MainPage
  174. {
  175. get
  176. {
  177. return ServiceLocator.Current.GetInstance<MainPage>();
  178. }
  179. }
  180. /// <summary>
  181. /// 交易信息管理
  182. /// </summary>
  183. public static AccountManagerViewModel AccountManager
  184. {
  185. get { return ServiceLocator.Current.GetInstance<AccountManagerViewModel>(); }
  186. }
  187. #region 旧单据查询
  188. /// <summary>
  189. /// 账号信息
  190. /// </summary>
  191. //public static AccountInfoListViewModel AccountInfo
  192. //{
  193. // get
  194. // {
  195. // return ServiceLocator.Current.GetInstance<AccountInfoListViewModel>();
  196. // }
  197. //}
  198. ///// <summary>
  199. ///// 持仓单
  200. ///// </summary>
  201. //public static HoldingDetailListViewModel HoldingReport
  202. //{
  203. // get { return ServiceLocator.Current.GetInstance<HoldingDetailListViewModel>(); }
  204. //}
  205. ///// <summary>
  206. /////平仓单
  207. ///// </summary>
  208. //public static CloseOrderListViewModel CloseOrderList
  209. //{
  210. // get { return ServiceLocator.Current.GetInstance<CloseOrderListViewModel>(); }
  211. //}
  212. ///// <summary>
  213. ///// 持仓汇总
  214. ///// </summary>
  215. //public static HoldingSummaryListViewModel HoldingSummary
  216. //{
  217. // get { return ServiceLocator.Current.GetInstance<HoldingSummaryListViewModel>(); }
  218. //}
  219. ///// <summary>
  220. ///// 成交单
  221. ///// </summary>
  222. //public CompleteOrderViewModel CompleteOrders
  223. //{
  224. // get { return ServiceLocator.Current.GetInstance<CompleteOrderViewModel>(); }
  225. //}
  226. #endregion
  227. #region 新单据查询
  228. /// <summary>
  229. /// 账号信息
  230. /// </summary>
  231. public static MAccountInfoViewModel MAccountInfo
  232. {
  233. get
  234. {
  235. return ServiceLocator.Current.GetInstance<MAccountInfoViewModel>();
  236. }
  237. }
  238. /// <summary>
  239. /// 持仓单
  240. /// </summary>
  241. public static MHoldDetailViewModel MHoldingDetail
  242. {
  243. get { return ServiceLocator.Current.GetInstance<MHoldDetailViewModel>(); }
  244. }
  245. /// <summary>
  246. /// 持仓单-不区分市场
  247. /// </summary>
  248. public static MOHoldDetailViewModel MOHoldingDetail
  249. {
  250. get { return ServiceLocator.Current.GetInstance<MOHoldDetailViewModel>(); }
  251. }
  252. /// <summary>
  253. ///平仓单
  254. /// </summary>
  255. public static MCloseOrderViewModel MCloseOrders
  256. {
  257. get { return ServiceLocator.Current.GetInstance<MCloseOrderViewModel>(); }
  258. }
  259. /// <summary>
  260. ///平仓单[成交明细]-不区分市场
  261. /// </summary>
  262. public static MOTransactionDetailViewModel MOCloseOrders
  263. {
  264. get { return ServiceLocator.Current.GetInstance<MOTransactionDetailViewModel>(); }
  265. }
  266. /// <summary>
  267. /// 持仓汇总
  268. /// </summary>
  269. public static MHoldSummaryViewModel MProsition
  270. {
  271. get { return ServiceLocator.Current.GetInstance<MHoldSummaryViewModel>(); }
  272. }
  273. /// <summary>
  274. /// 持仓汇总-不区分市场
  275. /// </summary>
  276. public static MOHoldSummaryViewModel MOProsition
  277. {
  278. get { return ServiceLocator.Current.GetInstance<MOHoldSummaryViewModel>(); }
  279. }
  280. /// <summary>
  281. ///委托单
  282. /// </summary>
  283. public static MOrderDetailViewModel MOrderDetails
  284. {
  285. get { return ServiceLocator.Current.GetInstance<MOrderDetailViewModel>(); }
  286. }
  287. /// <summary>
  288. ///委托单-不区分市场
  289. /// </summary>
  290. public static MOOrderDetailViewModel MOOrderDetails
  291. {
  292. get { return ServiceLocator.Current.GetInstance<MOOrderDetailViewModel>(); }
  293. }
  294. /// <summary>
  295. /// 建仓单
  296. /// </summary>
  297. public MOpenCompleteViewModel MCompleteOrders
  298. {
  299. get { return ServiceLocator.Current.GetInstance<MOpenCompleteViewModel>(); }
  300. }
  301. /// <summary>
  302. /// 预埋单查询
  303. /// </summary>
  304. public PrePostDetailViewModel PrePostDetail
  305. {
  306. get { return ServiceLocator.Current.GetInstance<PrePostDetailViewModel>(); }
  307. }
  308. /// <summary>
  309. /// 预埋单查询-不区分市场
  310. /// </summary>
  311. public MOPrePostDetailViewModel OPrePostDetail
  312. {
  313. get { return ServiceLocator.Current.GetInstance<MOPrePostDetailViewModel>(); }
  314. }
  315. /// <summary>
  316. /// 配号中签查询
  317. /// </summary>
  318. public DistributeBallotViewModel DistributeBallot
  319. {
  320. get { return ServiceLocator.Current.GetInstance<DistributeBallotViewModel>(); }
  321. }
  322. /// <summary>
  323. /// 交割申报
  324. /// </summary>
  325. public DeliveryOrderViewModel DeliveryOrderView
  326. {
  327. get { return ServiceLocator.Current.GetInstance<DeliveryOrderViewModel>(); }
  328. }
  329. /// <summary>
  330. /// /资金流水查询
  331. /// </summary>
  332. public TaAmountLogViewModel TaAmountLog
  333. {
  334. get { return ServiceLocator.Current.GetInstance<TaAmountLogViewModel>(); }
  335. }
  336. public MOSPSLListViewModel SPSLListViewModel
  337. {
  338. get { return ServiceLocator.Current.GetInstance<MOSPSLListViewModel>(); }
  339. }
  340. #endregion
  341. /// <summary>
  342. /// 快速下单栏
  343. /// </summary>
  344. public QuickOrderViewModel OrderBar
  345. {
  346. get { return ServiceLocator.Current.GetInstance<QuickOrderViewModel>(); }
  347. }
  348. public static StatusBarViewModel StatusBar
  349. {
  350. get { return ServiceLocator.Current.GetInstance<StatusBarViewModel>(); }
  351. }
  352. /// <summary>
  353. /// 菜单树
  354. /// </summary>
  355. public static MenuTreeViewModel MenuTree
  356. {
  357. get { return ServiceLocator.Current.GetInstance<MenuTreeViewModel>(); }
  358. }
  359. /// <summary>
  360. /// 行情列表
  361. /// </summary>
  362. public static QuoteListViewModel QuoteList
  363. {
  364. get { return ServiceLocator.Current.GetInstance<QuoteListViewModel>(); }
  365. }
  366. public static TradeHeaderViewModel TradeHeader
  367. {
  368. get { return ServiceLocator.Current.GetInstance<TradeHeaderViewModel>(); }
  369. }
  370. public static Muchinfo.MTPClient.Bank.ViewModels.AmountQueryViewModel AmountQuery
  371. {
  372. get { return ServiceLocator.Current.GetInstance<Muchinfo.MTPClient.Bank.ViewModels.AmountQueryViewModel>(); }
  373. }
  374. /// <summary>
  375. /// 查询发售商品
  376. /// </summary>
  377. public static QuerySaleGoodsViewModel QuerySaleGoods
  378. {
  379. get { return ServiceLocator.Current.GetInstance<QuerySaleGoodsViewModel>(); }
  380. }
  381. /// <summary>
  382. /// 挂牌市场
  383. /// </summary>
  384. public static ListingMarketViewModel ListingMarket
  385. {
  386. get { return ServiceLocator.Current.GetInstance<ListingMarketViewModel>(); }
  387. }
  388. public static DelistingOrderViewModel DelistingViewModel
  389. {
  390. get { return ServiceLocator.Current.GetInstance<DelistingOrderViewModel>(); }
  391. }
  392. /// <summary>
  393. /// 查询交割单
  394. /// </summary>
  395. public static DeliveryHolderViewModel DeliveryHolder
  396. {
  397. get { return ServiceLocator.Current.GetInstance<DeliveryHolderViewModel>(); }
  398. }
  399. /// <summary>
  400. /// 交割申报单
  401. /// </summary>
  402. public static DeliveryEntructViewModel DeliveryEntruct
  403. {
  404. get { return ServiceLocator.Current.GetInstance<DeliveryEntructViewModel>(); }
  405. }
  406. /// <summary>
  407. /// 交割仓单查询
  408. /// </summary>
  409. public static DeliveryWarehouseOrderViewModel DeliveryWarehouseOrder
  410. {
  411. get { return ServiceLocator.Current.GetInstance<DeliveryWarehouseOrderViewModel>(); }
  412. }
  413. /// <summary>
  414. /// 交割配对仓单查询
  415. /// </summary>
  416. public static DeliveryMatchViewModel DeliveryMatch
  417. {
  418. get { return ServiceLocator.Current.GetInstance<DeliveryMatchViewModel>(); }
  419. }
  420. /// <summary>
  421. /// 交割提货-查询
  422. /// </summary>
  423. public static TakaDeliveryGoodsQueryViewModel TakaDeliveryGoodsQuery
  424. {
  425. get { return ServiceLocator.Current.GetInstance<TakaDeliveryGoodsQueryViewModel>(); }
  426. }
  427. /// <summary>
  428. /// 交割提货-申请
  429. /// </summary>
  430. public static TakaDeliveryGoodsApplyViewModel TakaDeliveryGoodsApply
  431. {
  432. get { return ServiceLocator.Current.GetInstance<TakaDeliveryGoodsApplyViewModel>(); }
  433. }
  434. public static DeliveryCompleteViewModel DlyCompleteViewModel
  435. {
  436. get { return ServiceLocator.Current.GetInstance<DeliveryCompleteViewModel>(); }
  437. }
  438. #endregion
  439. /// <summary>
  440. /// /协议平仓
  441. /// </summary>
  442. public DealCloseViewModel DealClose { get { return ServiceLocator.Current.GetInstance<DealCloseViewModel>(); } }
  443. /// <summary>
  444. /// 托管申请查询
  445. /// </summary>
  446. public QueryDepositApplyViewModel DepositQuery { get { return ServiceLocator.Current.GetInstance<QueryDepositApplyViewModel>(); } }
  447. /// <summary>
  448. /// /签约查询
  449. /// </summary>
  450. public BankSignQueryViewModel BankSignQuery { get { return ServiceLocator.Current.GetInstance<BankSignQueryViewModel>(); } }
  451. /// <summary>
  452. /// 历史单据查询
  453. /// </summary>
  454. public HistoryOrderQueryViewModel HistoryOrder { get { return ServiceLocator.Current.GetInstance<HistoryOrderQueryViewModel>(); } }
  455. /// <summary>
  456. /// 挂牌点价
  457. /// </summary>
  458. public static ListingDeliveryGoodsViewModel ListingDeliveryGoodses
  459. {
  460. get { return ServiceLocator.Current.GetInstance<ListingDeliveryGoodsViewModel>(); }
  461. }
  462. /// <summary>
  463. /// 我的挂牌
  464. /// </summary>
  465. public static MyListingOrderViewModel MyListingOrder
  466. {
  467. get { return ServiceLocator.Current.GetInstance<MyListingOrderViewModel>(); }
  468. }
  469. /// <summary>
  470. /// 五档历史
  471. /// </summary>
  472. public static HistoryCommissionsListViewModel HistoryCommissionsList
  473. {
  474. get { return ServiceLocator.Current.GetInstance<HistoryCommissionsListViewModel>(); }
  475. }
  476. /// <summary>
  477. /// 我的订单
  478. /// </summary>
  479. public static MyOrderViewModel MyOrder
  480. {
  481. get { return ServiceLocator.Current.GetInstance<MyOrderViewModel>(); }
  482. }
  483. }
  484. }