Ejemplo n.º 1
0
        protected override Task OnInitializeAsync(IActivatedEventArgs args)
        {
            EventAggregator = new EventAggregator();

            Container.RegisterInstance <INavigationService>(NavigationService);
            Container.RegisterInstance <ISessionStateService>(SessionStateService);
            Container.RegisterInstance <IEventAggregator>(EventAggregator);
            Container.RegisterInstance <IResourceLoader>(new ResourceLoaderAdapter(new ResourceLoader()));
            Container.RegisterType <IAccountService, AccountService>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ICredentialStore, RoamingCredentialStore>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ICacheService, TemporaryFolderCacheService>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ISecondaryTileService, SecondaryTileService>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IAlertMessageService, AlertMessageService>(new ContainerControlledLifetimeManager());

            // Register repositories
            Container.RegisterType <IProductCatalogRepository, ProductCatalogRepository>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IShoppingCartRepository, ShoppingCartRepository>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ICheckoutDataRepository, CheckoutDataRepository>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IOrderRepository, OrderRepository>(new ContainerControlledLifetimeManager());

            // Register web service proxies
            Container.RegisterType <IProductCatalogService, ProductCatalogServiceProxy>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IOrderService, OrderServiceProxy>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IShoppingCartService, ShoppingCartServiceProxy>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IShippingMethodService, ShippingMethodServiceProxy>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IIdentityService, IdentityServiceProxy>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ILocationService, LocationServiceProxy>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IAddressService, AddressServiceProxy>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IPaymentMethodService, PaymentMethodServiceProxy>(new ContainerControlledLifetimeManager());

            // Register child view models
            Container.RegisterType <IShippingAddressUserControlViewModel, ShippingAddressUserControlViewModel>();
            Container.RegisterType <IBillingAddressUserControlViewModel, BillingAddressUserControlViewModel>();
            Container.RegisterType <IPaymentMethodUserControlViewModel, PaymentMethodUserControlViewModel>();
            Container.RegisterType <ISignInUserControlViewModel, SignInUserControlViewModel>();

            ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver((viewType) =>
            {
                var viewModelTypeName = string.Format(CultureInfo.InvariantCulture, "AdventureWorks.UILogic.ViewModels.{0}ViewModel, AdventureWorks.UILogic, Version=1.1.0.0, Culture=neutral", viewType.Name);
                var viewModelType     = Type.GetType(viewModelTypeName);
                if (viewModelType == null)
                {
                    viewModelTypeName = string.Format(CultureInfo.InvariantCulture, "AdventureWorks.UILogic.ViewModels.{0}ViewModel, AdventureWorks.UILogic.Windows, Version=1.0.0.0, Culture=neutral", viewType.Name);
                    viewModelType     = Type.GetType(viewModelTypeName);
                }

                return(viewModelType);
            });

            // Documentation on working with tiles can be found at http://go.microsoft.com/fwlink/?LinkID=288821&clcid=0x409
            _tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            _tileUpdater.StartPeriodicUpdate(new Uri(Constants.ServerAddress + "/api/TileNotification"), PeriodicUpdateRecurrence.HalfHour);
            var resourceLoader = Container.Resolve <IResourceLoader>();

            return(base.OnInitializeAsync(args));
        }
Ejemplo n.º 2
0
        // 启动一个“轮询服务端获取数据,然后更新 Tile 通知”的任务
        private void btnStartPeriodicUpdate_Click(object sender, RoutedEventArgs e)
        {
            // 启动一个循环更新 Tile 通知的任务,并指定 Tile 通知的数据源和轮询周期
            TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(TILEID);

            tileUpdater.EnableNotificationQueue(true); // 启用 tile 的队列功能(最多可容纳 5 个 tile)

            // 马上请求服务端获取数据,然后 45 分钟之后再次获取数据,最后再每半个小时获取一次数据
            tileUpdater.StartPeriodicUpdate(new Uri("http://localhost:44914/api/TileContent", UriKind.Absolute), DateTimeOffset.UtcNow.AddMinutes(45), PeriodicUpdateRecurrence.HalfHour);

            // Tile 通知的数据源示例请参见 WebApi/Controllers/TileContentController.cs
        }
Ejemplo n.º 3
0
        protected override Task OnInitializeAsync(IActivatedEventArgs args)
        {
            EventAggregator = new EventAggregator();

            Container.RegisterInstance <ISessionStateService>(SessionStateService);
            Container.RegisterInstance <IEventAggregator>(EventAggregator);
            Container.RegisterInstance <IResourceLoader>(new ResourceLoaderAdapter(new ResourceLoader()));
            Container.RegisterType <IAccountService, AccountService>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IAppService, AppService>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ICredentialStore, RoamingCredentialStore>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ICacheService, TemporaryFolderCacheService>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ISecondaryTileService, SecondaryTileService>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IAlertMessageService, AlertMessageService>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IClientDeveloperService, DeveloperServiceProxy>(new ContainerControlledLifetimeManager());
            Container.RegisterType <INaturalPersonUserControlViewModel, NaturalPersonUserControlViewModel>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ILegalPersonUserControlViewModel, LegalPersonUserControlViewModel>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ICredentialUserControlViewModel, CredentialUserControlViewModel>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IVersionUserControlViewModel, VersionUserControlViewModel>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ISignInViewModel, SignInPageViewModel>(new ContainerControlledLifetimeManager());
            // Register repositories

            // Register web service proxies

            // Register child view models

            ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver((viewType) =>
            {
                var viewModelTypeName = string.Format(CultureInfo.InvariantCulture, "WindowsStore.Client.Developer.Logic.ViewModels.{0}ViewModel, WindowsStore.Client.Developer.Logic, Version=1.0.0.0, Culture=neutral", viewType.Name);
                var viewModelType     = Type.GetType(viewModelTypeName);
                if (viewModelType == null)
                {
                    viewModelTypeName = string.Format(CultureInfo.InvariantCulture, "WindowsStore.Client.Developer.Logic.ViewModels.{0}ViewModel, WindowsStore.Client.Developer.Logic, Version=1.0.0.0, Culture=neutral", viewType.Name);
                    viewModelType     = Type.GetType(viewModelTypeName);
                }

                return(viewModelType);
            });

            // Documentation on working with tiles can be found at http://go.microsoft.com/fwlink/?LinkID=288821&clcid=0x409
            _tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            _tileUpdater.StartPeriodicUpdate(new Uri(Constants.DeveloperTileUpdaterUrl + "/api/TileNotification"), PeriodicUpdateRecurrence.HalfHour);
            var resourceLoader = Container.Resolve <IResourceLoader>();

            // subscribe App_UnhandledException
            //
            this.UnhandledException += App_UnhandledException;
            return(base.OnInitializeAsync(args));
        }