ViewModelLocator.cs 18 KB

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