public RouterUINavigationController(IRoutingState router, IViewLocator viewLocator = null)
        {
            this.router = router;
            viewLocator = viewLocator ?? ViewLocator.Current;

            var platform = RxApp.DependencyResolver.GetService<IPlatformOperations>();

            var vmAndContract = Observable.CombineLatest(
                router.Navigate,
                orientationChanged,
                (vm, _) => new { ViewModel = vm, Contract = platform.GetOrientation() });

            vmAndContract.Subscribe (x => {
                var view = viewLocator.ResolveView(x.ViewModel, x.Contract);
                view.ViewModel = x.ViewModel;

                this.PushViewController((UIViewController)view, true);
            });

            router.NavigateBack.Subscribe(_ => this.PopViewControllerAnimated(true));
            router.NavigateAndReset.Subscribe (x => {
                this.PopToRootViewController(false);
                router.Navigate.Execute(x);
            });

            this.Delegate = new RouterUINavigationControllerDelegate(this, router);
        }
        public TemplatesModule(IDocumentSession session, IViewLocator viewLocator)
            : base("Templates")
        {
            Get["/"] = p =>
                           {
                               var templates = session.Advanced.LoadStartingWith<ViewTemplate>("NSemble/Views/");
                               return View["List", templates];
                           };

            Get["/new/"] = p => View["Edit", new ViewTemplate {}];

            Get[@"/edit/{viewName*}"] = p =>
                                            {
                                                var viewName = (string) p.viewName;
                                                if (!viewName.StartsWith(Constants.RavenViewDocumentPrefix, StringComparison.InvariantCultureIgnoreCase))
                                                    viewName = Constants.RavenViewDocumentPrefix + viewName;
                                                var template = session.Load<ViewTemplate>(viewName);

                                                // Even if we don't have it stored in the DB, it might still exist as a resource. Try loading it from Nancy.
                                                if (template == null)
                                                {
                                                    var vlr = viewLocator.LocateView(viewName.Substring(Constants.RavenViewDocumentPrefix.Length), Context);
                                                    if (vlr == null)
                                                        return 404;

                                                    template = new ViewTemplate
                                                                   {
                                                                       Location = vlr.Location,
                                                                       Name = vlr.Name,
                                                                       Extension = vlr.Extension,
                                                                       Contents = vlr.Contents.Invoke().ReadToEnd(),
                                                                   };
                                                }

                                                return View["Edit", template];
                                            };

            Post[@"/edit/{viewName*}"] = p =>
                                                   {
                                                       var template = this.Bind<ViewTemplate>();

                                                       var viewName = (string) p.viewName;
                                                       if (!viewName.StartsWith(Constants.RavenViewDocumentPrefix, StringComparison.InvariantCultureIgnoreCase))
                                                           viewName = Constants.RavenViewDocumentPrefix + viewName;

                                                       session.Store(template, string.Concat(Constants.RavenViewDocumentPrefix, template.Location, "/", template.Name, ".", template.Extension));
                                                       session.SaveChanges();

                                                       return "Success";
                                                   };

            Post["/new"] = p =>
                                {
                                    var template = this.Bind<ViewTemplate>();
                                    session.Store(template, string.Concat(Constants.RavenViewDocumentPrefix, template.Location, "/", template.Name, ".", template.Extension));

                                    return Response.AsRedirect("/");
                                };
        }
 public static object CreateView(IViewLocator viewLocator, string documentType, DataTemplate viewTemplate = null, DataTemplateSelector viewTemplateSelector = null) {
     if(documentType == null && viewTemplate == null & viewTemplateSelector == null)
         throw new InvalidOperationException(string.Format("{0}{1}To learn more, see: {2}", Error_CreateViewMissArguments, System.Environment.NewLine, HelpLink_CreateViewMissArguments));
     if(viewTemplate != null || viewTemplateSelector != null) {
         return new ViewPresenter(viewTemplate, viewTemplateSelector);
     }
     IViewLocator actualLocator = viewLocator ?? (ViewLocator.Default ?? ViewLocator.Instance);
     return actualLocator.ResolveView(documentType);
 }
		public LoginPage(ILoginPageViewModel viewModel, ITranslation translation, IViewLocator viewLocator)
		{
			_viewModel = viewModel;
			_viewModel.NavigateToMainPageCommand = new Command(async () => await NavigateToMainPage());
			BindingContext = _viewModel;

			_translation = translation;
			_viewLocator = viewLocator;
		}
Exemple #5
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="UIVisualizerService" /> class.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">The <paramref name="viewLocator" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="typeFactory" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="languageService" /> is <c>null</c>.</exception>
        public UIVisualizerService(IViewLocator viewLocator, ITypeFactory typeFactory, ILanguageService languageService)
        {
            Argument.IsNotNull(() => viewLocator);
            Argument.IsNotNull(() => typeFactory);
            Argument.IsNotNull(() => languageService);

            _viewLocator = viewLocator;
            _typeFactory = typeFactory;
            _languageService = languageService;
        }
        public DefaultViewResolverFixture()
        {
            this.viewLocator = A.Fake<IViewLocator>();
            this.viewResolver = new DefaultViewResolver(this.viewLocator, new ViewLocationConventions(Enumerable.Empty<Func<string, object, ViewLocationContext, string>>()));

            this.viewLocationContext =
                new ViewLocationContext
                {
                    Context = new NancyContext()
                };
        }
 public CalculatorModule(IServiceLocator serviceLocator,
                         IRegionManager regionManager,
                         IViewModelBinder binder,
                         IViewLocator viewStrategy
     )
 {
     _serviceLocator = serviceLocator;
     _regionManager = regionManager;
     _binder = binder;
     _viewStrategy = viewStrategy;
 }
Exemple #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RoutedControlHost"/> class.
        /// </summary>
        public RoutedControlHost()
        {
            InitializeComponent();

            _disposables.Add(this.WhenAny(x => x.DefaultContent, x => x.Value).Subscribe(x =>
            {
                if (x != null && Controls.Count == 0)
                {
                    Controls.Add(InitView(x));
                    components.Add(DefaultContent);
                }
            }));

            ViewContractObservable = Observable <string> .Default;

            var vmAndContract =
                this.WhenAnyObservable(x => x.Router.CurrentViewModel)
                .CombineLatest(
                    this.WhenAnyObservable(x => x.ViewContractObservable),
                    (vm, contract) => new { ViewModel = vm, Contract = contract });

            Control viewLastAdded = null;

            _disposables.Add(vmAndContract.Subscribe(
                                 x =>
            {
                // clear all hosted controls (view or default content)
                Controls.Clear();

                if (viewLastAdded != null)
                {
                    viewLastAdded.Dispose();
                }

                if (x.ViewModel == null)
                {
                    if (DefaultContent != null)
                    {
                        InitView(DefaultContent);
                        Controls.Add(DefaultContent);
                    }

                    return;
                }

                IViewLocator viewLocator = ViewLocator ?? ReactiveUI.ViewLocator.Current;
                IViewFor view            = viewLocator.ResolveView(x.ViewModel, x.Contract);
                view.ViewModel           = x.ViewModel;

                viewLastAdded = InitView((Control)view);
                Controls.Add(viewLastAdded);
            }, RxApp.DefaultExceptionHandler.OnNext));
        }
        public GetRecsModule(IConfig config, IMyAnimeListApiFactory malApiFactory, IAnimeRecsClientFactory recClientFactory, IAnimeRecsDbConnectionFactory dbConnectionFactory, IViewFactory viewFactory, IViewLocator viewLocator, RazorViewEngine viewEngine, IRenderContextFactory renderContextFactory)
        {
            _config = config;
            _malApiFactory = malApiFactory;
            _recClientFactory = recClientFactory;
            _dbConnectionFactory = dbConnectionFactory;
            _viewLocator = viewLocator;
            _viewEngine = viewEngine;
            _renderContextFactory = renderContextFactory;

            Post["/GetRecs"] = GetRecs;
        }
Exemple #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NavigationView"/> class.
        /// </summary>
        /// <param name="mainScheduler">The main scheduler to scheduler UI tasks on.</param>
        /// <param name="backgroundScheduler">The background scheduler.</param>
        /// <param name="viewLocator">The view locator which will find views associated with view models.</param>
        /// <param name="rootPage">The starting root page.</param>
        public NavigationView(IScheduler mainScheduler, IScheduler backgroundScheduler, IViewLocator viewLocator, Page rootPage)
            : base(rootPage)
        {
            _backgroundScheduler = backgroundScheduler;
            _mainScheduler       = mainScheduler;
            _viewLocator         = viewLocator;

            PagePopped = Observable
                         .FromEventPattern <NavigationEventArgs>(x => Popped += x, x => Popped -= x)
                         .Select(ep => ep.EventArgs.Page.BindingContext as IPageViewModel)
                         .WhereNotNull();
        }
 public OpenWikiPageKeybindHandler(
     IClipboardProvider clipboardProvider,
     IMediator mediator,
     IViewLocator viewLocator,
     ISidekickSettings settings,
     IProcessProvider processProvider)
 {
     this.clipboardProvider = clipboardProvider;
     this.mediator          = mediator;
     this.viewLocator       = viewLocator;
     this.settings          = settings;
     this.processProvider   = processProvider;
 }
Exemple #12
0
		public MainPage(IMainPageViewModel viewModel, IFlagService flagService, IViewLocator viewLocator)
		{
			Title = "Currency Converter";
			_viewModel = viewModel;
			SetViewModelEvents();
			BindingContext = _viewModel;

			_flagService = flagService;
			_viewLocator = viewLocator;
			CreateUI();

			this.SetDefaultPadding();
		}
        public ViewEngineFixture()
        {
            this.templateLocator = A.Fake<IViewLocator>();
            this.viewCompiler = A.Fake<IViewCompiler>();
            this.view = A.Fake<IView>();
            this.viewLocationResult = new ViewLocationResult(@"c:\some\fake\path", null);

            A.CallTo(() => templateLocator.GetTemplateContents("test")).Returns(viewLocationResult);
            A.CallTo(() => viewCompiler.GetCompiledView<object>(null)).Returns(view);
            A.CallTo(() => viewCompiler.GetCompiledView<MemoryStream>(null)).Returns(view);

            this.engine = new ViewEngine(templateLocator, viewCompiler);
        }
        public HtmlMediaTypeViewFormatter(string siteRootPath = null, IViewLocator viewLocator = null, IViewParser viewParser = null)
        {
            SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
            SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/xhtml"));
            SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/xhtml+xml"));

            SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true));
            SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true));

            _viewLocator = viewLocator;
            _viewParser = viewParser;
            _siteRootPath = siteRootPath;
        }
Exemple #15
0
 public ArticleMasterPage(ITranslation translation,
                          IArticleMasterPageViewModel viewModel,
                          IArticlesHubProxy articlesHub,
                          IViewLocator viewLocator)
 {
     _translation   = translation;
     _viewModel     = viewModel;
     _articlesHub   = articlesHub;
     _viewLocator   = viewLocator;
     BindingContext = _viewModel;
     CreateUI();
     this.SetDefaultPadding();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="NavigationService" /> class.
        /// </summary>
        /// <param name="typeFactory">The type factory.</param>
        /// <param name="viewLocator">The view locator.</param>
        /// <param name="viewModelLocator">The view model locator.</param>
        /// <param name="viewModelFactory">The viewmodel factory.</param>
        public NavigationService(ITypeFactory typeFactory, IViewLocator viewLocator, IViewModelLocator viewModelLocator, IViewModelFactory viewModelFactory)
        {
            Argument.IsNotNull(() => typeFactory);
            Argument.IsNotNull(() => viewLocator);
            Argument.IsNotNull(() => viewModelLocator);

            _typeFactory      = typeFactory;
            _viewLocator      = viewLocator;
            _viewModelFactory = viewModelFactory;
            _viewModelLocator = viewModelLocator;

            Initialize();
        }
Exemple #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StartupService"/> class.
 /// </summary>
 /// <param name="navigationService">The navigationService<see cref="INavigationService"/></param>
 /// <param name="authService">The authService<see cref="IAuthService"/></param>
 /// <param name="appSettings">The appSettings<see cref="IAppSettings"/></param>
 /// <param name="viewLocator">The viewLocator<see cref="IViewLocator"/></param>
 /// <param name="logger">The logger<see cref="ILogger"/></param>
 public StartupService(
     INavigationService navigationService,
     IAuthService authService,
     IAppSettings appSettings,
     IViewLocator viewLocator,
     ILogger logger)
 {
     this.navigationService = navigationService;
     this.authService       = authService;
     this.appSettings       = appSettings;
     this.viewLocator       = viewLocator;
     this.logger            = logger;
 }
 public OpenWikiPageHandler(
     IClipboardProvider clipboardProvider,
     IGameLanguageProvider gameLanguageProvider,
     IMediator mediator,
     IViewLocator viewLocator,
     ISidekickSettings settings)
 {
     this.clipboardProvider    = clipboardProvider;
     this.gameLanguageProvider = gameLanguageProvider;
     this.mediator             = mediator;
     this.viewLocator          = viewLocator;
     this.settings             = settings;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="NavigationService"/> class.
        /// </summary>
        /// <param name="statePersistor"> The state persistor. </param>
        /// <param name="viewModelLocator"> The ViewModel instance locator. </param>
        /// <param name="viewLocator"> The ViewLocator</param>
        /// <param name="platformNavigator"> The platform navigator. </param>
        public NavigationService(
            IViewLocator viewLocator, 
            IViewModelLocator viewModelLocator, 
            IStatePersistor statePersistor, 
            IPlatformNavigator platformNavigator) 
        {
            this.viewModelLocator = viewModelLocator;
            this.viewLocator = viewLocator;
            this.statePersistor = statePersistor;
            this.platformNavigator = platformNavigator;

            this.platformNavigator.BackNavigationRequested += this.PlatformBackNavigationRequested;
        }
Exemple #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NavigationService"/> class.
        /// </summary>
        /// <param name="statePersistor"> The state persistor. </param>
        /// <param name="viewModelLocator"> The ViewModel instance locator. </param>
        /// <param name="viewLocator"> The ViewLocator</param>
        /// <param name="platformNavigator"> The platform navigator. </param>
        public NavigationService(
            IViewLocator viewLocator,
            IViewModelLocator viewModelLocator,
            IStatePersistor statePersistor,
            IPlatformNavigator platformNavigator)
        {
            this.viewModelLocator  = viewModelLocator;
            this.viewLocator       = viewLocator;
            this.statePersistor    = statePersistor;
            this.platformNavigator = platformNavigator;

            this.platformNavigator.BackNavigationRequested += this.PlatformBackNavigationRequested;
        }
		public ArticleMasterPage(ITranslation translation, 
			IArticleMasterPageViewModel viewModel,
			IArticlesHubProxy articlesHub,
			IViewLocator viewLocator)
		{
			_translation = translation;
			_viewModel = viewModel;
			_articlesHub = articlesHub;
			_viewLocator = viewLocator;
			BindingContext = _viewModel;
			CreateUI();
			this.SetDefaultPadding();
		}
Exemple #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NavigationView"/> class.
        /// </summary>
        /// <param name="mainScheduler">The main scheduler to scheduler UI tasks on.</param>
        /// <param name="backgroundScheduler">The background scheduler.</param>
        /// <param name="viewLocator">The view locator which will find views associated with view models.</param>
        public NavigationView(IScheduler mainScheduler, IScheduler backgroundScheduler, IViewLocator viewLocator)
        {
            _backgroundScheduler = backgroundScheduler;
            _mainScheduler       = mainScheduler;
            _viewLocator         = viewLocator;
            _logger = this.Log();

            PagePopped =
                Observable
                .FromEventPattern <NavigationEventArgs>(x => Popped += x, x => Popped -= x)
                .Select(ep => ep.EventArgs.Page.BindingContext as IViewModel)
                .Where(x => x != null);
        }
        public static object CreateView(IViewLocator viewLocator, string documentType, DataTemplate viewTemplate = null, DataTemplateSelector viewTemplateSelector = null) {
            if(viewTemplate != null || viewTemplateSelector != null) {
                var presenter = new ContentPresenter() {
                    ContentTemplate = viewTemplate,
#if !SILVERLIGHT
                    ContentTemplateSelector = viewTemplateSelector
#endif
                };
                return presenter;
            }
            IViewLocator actualLocator = viewLocator ?? (ViewLocator.Default ?? ViewLocator.Instance);
            return actualLocator.ResolveView(documentType);
        }
        public HtmlMediaTypeViewFormatter(string siteRootPath = null, IViewLocator viewLocator = null, IViewParser viewParser = null)
        {
            SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
            SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/xhtml"));
            SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/xhtml+xml"));

            SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true));
            SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true));

            _viewLocator  = viewLocator;
            _viewParser   = viewParser;
            _siteRootPath = siteRootPath;
        }
Exemple #25
0
        public async Task <IActionResult> AddAsync([FromServices] IViewLocator viewLocator, [FromQuery] string itemType, [FromQuery] int itemIndex = -1)
        {
            if (itemType == null)
            {
                return(BadRequest());
            }

            if (!Field.ValueContentMetadata.Manager.TryGetMetadata(itemType, out ContentMetadataProvider contentMetadataProvider))
            {
                return(BadRequest());
            }

            if (!contentMetadataProvider.IsInheritedOrEqual(Field.ValueContentMetadata))
            {
                return(BadRequest());
            }

            var newItem = contentMetadataProvider.CreateModelInstance();

            var view = viewLocator.FindView(contentMetadataProvider.ModelType);

            if (view != null && view.DefaultModelData != null)
            {
                newItem = contentMetadataProvider.ConvertDictionaryToContentModel(view.DefaultModelData);
            }

            if (Field.IsListValue)
            {
                if (!(Field.GetModelValue(ContentContext.Content) is IList list))
                {
                    list = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(Field.ValueContentMetadata.ModelType));
                }

                if (itemIndex == -1)
                {
                    itemIndex = list.Count;
                }

                list.Insert(itemIndex, newItem);

                Field.SetModelValue(ContentContext.Content, list);
            }
            else
            {
                Field.SetModelValue(ContentContext.Content, newItem);
            }

            await SaveChangesAsync();

            return(await FormValueAsync());
        }
Exemple #26
0
 public TrayProvider(IWebHostEnvironment webHostEnvironment,
                     ILogger <TrayProvider> logger,
                     IViewLocator viewLocator,
                     IClipboardProvider clipboardProvider,
                     IMediator mediator,
                     TrayResources resources)
 {
     this.webHostEnvironment = webHostEnvironment;
     this.logger             = logger;
     this.viewLocator        = viewLocator;
     this.clipboardProvider  = clipboardProvider;
     this.mediator           = mediator;
     this.resources          = resources;
 }
        public static object CreateView(IViewLocator viewLocator, string documentType, DataTemplate viewTemplate = null, DataTemplateSelector viewTemplateSelector = null)
        {
            if (documentType == null && viewTemplate == null & viewTemplateSelector == null)
            {
                throw new InvalidOperationException(string.Format("{0}{1}To learn more, see: {2}", Error_CreateViewMissArguments, System.Environment.NewLine, HelpLink_CreateViewMissArguments));
            }
            if (viewTemplate != null || viewTemplateSelector != null)
            {
                return(new ViewPresenter(viewTemplate, viewTemplateSelector));
            }
            IViewLocator actualLocator = viewLocator ?? (ViewLocator.Default ?? ViewLocator.Instance);

            return(actualLocator.ResolveView(documentType));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LoginViewModel"/> class.
 /// </summary>
 /// <param name="appSettings">The appSettings<see cref="IAppSettings"/></param>
 /// <param name="dialogService">The dialogService<see cref="IDialogService"/></param>
 /// <param name="authService">The authService<see cref="IAuthService"/></param>
 /// <param name="viewLocator">The viewLocator<see cref="IViewLocator"/></param>
 /// <param name="navigationService">The navigationService<see cref="INavigationService"/></param>
 public LoginViewModel(
     IAppSettings appSettings,
     IDialogService dialogService,
     IAuthService authService,
     IViewLocator viewLocator,
     INavigationService navigationService)
 {
     this.appSettings       = appSettings;
     this.dialogService     = dialogService;
     this.authService       = authService;
     this.viewLocator       = viewLocator;
     this.navigationService = navigationService;
     this.LoginCommand      = new Command(async() => await this.Login());
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultViewResolver"/> class.
        /// </summary>
        /// <param name="viewLocator">The view locator that should be used to locate views.</param>
        /// <param name="conventions">The conventions that the view resolver should use to figure out where to look for views.</param>
        public DefaultViewResolver(IViewLocator viewLocator, IEnumerable<Func<string, dynamic, ViewLocationContext, string>> conventions)
        {
            if (viewLocator == null)
            {
                throw new InvalidOperationException("Cannot create an instance of DefaultViewResolver with view locator parameter having null value.");
            }

            if (conventions == null)
            {
                throw new InvalidOperationException("Cannot create an instance of DefaultViewResolver with conventions parameter having null value.");
            }

            this.viewLocator = viewLocator;
            this.conventions = conventions;
        }
Exemple #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultViewResolver"/> class.
        /// </summary>
        /// <param name="viewLocator">The view locator that should be used to locate views.</param>
        /// <param name="conventions">The conventions that the view resolver should use to figure out where to look for views.</param>
        public DefaultViewResolver(IViewLocator viewLocator, ViewLocationConventions conventions)
        {
            if (viewLocator == null)
            {
                throw new InvalidOperationException("Cannot create an instance of DefaultViewResolver with view locator parameter having null value.");
            }

            if (conventions == null)
            {
                throw new InvalidOperationException("Cannot create an instance of DefaultViewResolver with conventions parameter having null value.");
            }

            this.viewLocator = viewLocator;
            this.conventions = conventions;
        }
Exemple #31
0
        public NavigationView(IScheduler backgroundScheduler, IScheduler mainScheduler, IViewLocator viewLocator)
        {
            //Ensure.ArgumentNotNull(backgroundScheduler, nameof(backgroundScheduler));
            //Ensure.ArgumentNotNull(mainScheduler, nameof(mainScheduler));
            //Ensure.ArgumentNotNull(viewLocator, nameof(viewLocator));

            this.backgroundScheduler = backgroundScheduler;
            this.mainScheduler       = mainScheduler;
            this.viewLocator         = viewLocator;

            this.pagePopped = Observable
                              .FromEventPattern <NavigationEventArgs>(x => this.Popped += x, x => this.Popped -= x)
                              .Select(ep => ep.EventArgs.Page.BindingContext as IPageViewModel)
                              .WhereNotNull();
        }
        private CommerceService()
        {
            this._listClient      = ClientContext.Clients.CreateListClient();
            this._browseClient    = ClientContext.Clients.CreateBrowseClient();
            this._storeClient     = ClientContext.Clients.CreateStoreClient();
            this._cartClient      = ClientContext.Clients.CreateCartClient();
            this._orderClient     = ClientContext.Clients.CreateOrderClient();
            this._priceClient     = ClientContext.Clients.CreatePriceClient();
            this._marketingClient = ClientContext.Clients.CreateMarketingClient();
            this._themeClient     = ClientContext.Clients.CreateThemeClient();
            this._reviewsClient   = ClientContext.Clients.CreateReviewsClient();

            _themesCacheStoragePath = ConfigurationManager.AppSettings["ThemeCacheFolder"];
            this._viewLocator       = new FileThemeViewLocator(_themesCacheStoragePath);
            this._cartHelper        = new CartHelper(this);
        }
Exemple #33
0
        public DotLiquidView(ControllerContext controllerContext, IViewLocator locator, ViewLocationResult viewResult, ViewLocationResult masterViewResult)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            if (viewResult == null)
            {
                throw new ArgumentNullException("viewPath");
            }

            _locator              = locator;
            this.ViewResult       = viewResult;
            this.MasterViewResult = masterViewResult;
        }
Exemple #34
0
        public PopupViewStackServiceFixture()
        {
            _view             = Substitute.For <IView>();
            _popupNavigation  = Substitute.For <IPopupNavigation>();
            _viewLocator      = Substitute.For <IViewLocator>();
            _viewModelFactory = Substitute.For <IViewModelFactory>();

            _view
            .PushPage(Arg.Any <INavigable>(), Arg.Any <string>(), Arg.Any <bool>(), Arg.Any <bool>())
            .Returns(Observable.Return(Unit.Default));
            _view.PopPage().Returns(Observable.Return(Unit.Default));
            _viewLocator.ResolveView(Arg.Any <IViewModel>()).Returns(new PopupMock {
                ViewModel = new NavigableViewModelMock()
            });
            _viewModelFactory.Create <NavigableViewModelMock>(Arg.Any <string>()).Returns(new NavigableViewModelMock());
        }
        public ReactiveNavigationViewHost(
            IScheduler backgroundScheduler = null,
            IScheduler mainScheduler       = null,
            IViewLocator viewLocator       = null
            )
        {
            this._backgroundScheduler = backgroundScheduler ?? RxApp.TaskpoolScheduler;
            this._mainScheduler       = mainScheduler ?? RxApp.MainThreadScheduler;
            this._viewLocator         = viewLocator ?? Locator.Current.GetService <IViewLocator>();


            this._pagePopped = Observable
                               .FromEventPattern <NavigationEventArgs>(x => this.Popped += x, x => this.Popped -= x)
                               .Select(ep => ep.EventArgs.Page.BindingContext as IPageViewModel)
                               .Where(v => v != null);
        }
        public DotLiquidView(ControllerContext controllerContext, IViewLocator locator, ViewLocationResult viewResult, ViewLocationResult masterViewResult)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            if (viewResult == null)
            {
                throw new ArgumentNullException("viewPath");
            }

            _locator = locator;
            this.ViewResult = viewResult;
            this.MasterViewResult = masterViewResult;
        }
Exemple #37
0
        public TemplatesModule(IDocumentSession session, IViewLocator viewLocator)
            : base("Templates")
        {
            Get["/"] = p =>
            {
                var templates = session.Query <ViewTemplate>().ToArray();

                return(View["List", templates]);
            };

            Get["/new/"] = p => View["Edit", new ViewTemplate {
                                     }];

            Get[@"/edit/(?<viewName>\S+)/"] = p =>
            {
                var viewName = (string)p.viewName;
                var template = session.Load <ViewTemplate>(viewName);

                // Even if we don't have it stored in the DB, it might still exist as a resource. Try loading it from Nancy.
                if (template == null)
                {
                    ViewLocationResult vlr = viewLocator.LocateView(viewName, Context);
                    if (vlr == null)
                    {
                        return(404);
                    }

                    template = new ViewTemplate
                    {
                        Location  = vlr.Location,
                        Name      = vlr.Name,
                        Extension = vlr.Extension,
                        Contents  = vlr.Contents.Invoke().ReadToEnd(),
                    };
                }

                return(View["Edit", template]);
            };

            Post["/new/"] = p =>
            {
                var template = this.Bind <ViewTemplate>();
                session.Store(template, string.Concat(Constants.RavenViewDocumentPrefix, template.Location, "/", template.Name, ".", template.Extension));

                return(Response.AsRedirect("/"));
            };
        }
        public ViewModelViewHost()
        {
            this.InitializeComponent();

            this.disposables.Add(this.WhenAny(x => x.DefaultContent, x => x.Value).Subscribe(x => {
                if (x != null && this.currentView == null)
                {
                    this.Controls.Clear();
                    this.Controls.Add(this.InitView(x));
                    this.components.Add(this.DefaultContent);
                }
            }));

            this.ViewContractObservable = Observable.Return(default(string));

            var vmAndContract =
                this.WhenAny(x => x.ViewModel, x => x.Value)
                .CombineLatest(this.WhenAnyObservable(x => x.ViewContractObservable),
                               (vm, contract) => new { ViewModel = vm, Contract = contract });

            this.disposables.Add(vmAndContract.Subscribe(x => {
                //clear all hosted controls (view or default content)
                this.Controls.Clear();

                if (this.currentView != null)
                {
                    this.currentView.Dispose();
                }

                if (this.ViewModel == null)
                {
                    if (this.DefaultContent != null)
                    {
                        this.InitView(this.DefaultContent);
                        this.Controls.Add(this.DefaultContent);
                    }
                    return;
                }

                IViewLocator viewLocator = this.ViewLocator ?? ReactiveUI.ViewLocator.Current;
                IViewFor view            = viewLocator.ResolveView(x.ViewModel, x.Contract);
                view.ViewModel           = x.ViewModel;

                this.CurrentView = this.InitView((Control)view);
                this.Controls.Add(this.CurrentView);
            }, RxApp.DefaultExceptionHandler.OnNext));
        }
Exemple #39
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NavigationView"/> class.
        /// </summary>
        /// <param name="mainScheduler">The main scheduler to scheduler UI tasks on.</param>
        /// <param name="backgroundScheduler">The background scheduler.</param>
        /// <param name="viewLocator">The view locator which will find views associated with view models.</param>
        /// <param name="rootPage">The starting root page.</param>
        public NavigationView(IScheduler mainScheduler, IScheduler backgroundScheduler, IViewLocator viewLocator, Page rootPage) : base(rootPage)
        {
            MainThreadScheduler  = mainScheduler;
            _backgroundScheduler = backgroundScheduler;
            _viewLocator         = viewLocator;

            PagePopped = Observable
                         .FromEvent <EventHandler <NavigationEventArgs>, object>(
                handler =>
            {
                void Handler(object sender, NavigationEventArgs args) => handler(args.Page.BindingContext);
                return(Handler);
            },
                x => Popped += x,
                x => Popped -= x)
                         .Cast <IViewModel>();
        }
Exemple #40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UICompositionService" /> class.
        /// </summary>
        /// <param name="regionManager">The region manager</param>
        /// <param name="viewManager">The view manager</param>
        /// <param name="viewLocator">The view locator</param>
        /// <param name="dispatcherService">The dispatcher service</param>
        /// <param name="viewModelManager">The view model manager.</param>
        /// <param name="viewModelFactory">The view model factory.</param>
        /// <exception cref="System.ArgumentNullException">The <paramref name="regionManager" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="viewManager" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="viewLocator" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="dispatcherService" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="viewModelManager" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="viewModelFactory" /> is <c>null</c>.</exception>
        public UICompositionService(IRegionManager regionManager, IViewManager viewManager, IViewLocator viewLocator,
                                    IDispatcherService dispatcherService, IViewModelManager viewModelManager, IViewModelFactory viewModelFactory)
        {
            Argument.IsNotNull(() => regionManager);
            Argument.IsNotNull(() => viewManager);
            Argument.IsNotNull(() => viewLocator);
            Argument.IsNotNull(() => dispatcherService);
            Argument.IsNotNull(() => viewModelManager);
            Argument.IsNotNull(() => viewModelFactory);

            _regionManager     = regionManager;
            _viewManager       = viewManager;
            _viewLocator       = viewLocator;
            _dispatcherService = dispatcherService;
            _viewModelManager  = viewModelManager;
            _viewModelFactory  = viewModelFactory;
        }
        public DefaultViewResolverFixture()
        {
            this.viewLocator  = A.Fake <IViewLocator>();
            this.viewResolver = new DefaultViewResolver(this.viewLocator, new ViewLocationConventions(Enumerable.Empty <Func <string, object, ViewLocationContext, string> >()));

            this.viewLocationContext =
                new ViewLocationContext
            {
                Context = new NancyContext
                {
                    Trace = new DefaultRequestTrace
                    {
                        TraceLog = new DefaultTraceLog()
                    }
                }
            };
        }
Exemple #42
0
        public DotLiquidViewEngine(IFileSystemFactory fileSystem, IViewLocator viewLocator, IEnumerable <Type> filters)
        {
            DotLiquid.Liquid.UseRubyDateFormat = true;
            _viewLocator     = viewLocator;
            this._fileSystem = fileSystem;
            // Register custom tags (Only need to do this once)
            Template.RegisterFilter(typeof(CommonFilters));
            Template.RegisterFilter(typeof(CommerceFilters));

            foreach (var filter in filters)
            {
                Template.RegisterFilter(filter);
            }

            Template.RegisterTag <Paginate>("paginate");
            Template.RegisterTag <CurrentPage>("current_page");
            Template.RegisterTag <Layout>("layout");
        }
Exemple #43
0
        public StockView(IViewLocator locator)
        {
            InitializeComponent();

            _lastPage = null; //  ya se... redundante...

            _locator = locator;
            //  _viewModel = ViewModelSource.Create(() => new StockViewModel(new Localizador()));
            _viewModel = ViewModelSource.Create(() => new StockViewModel(_locator));

            //  bind eventos del VM
            _viewModel.WorkViewAdded   += ViewModelOnWorkViewAdded;
            _viewModel.WorkViewRemoved += ViewModelOnWorkViewRemoved;

            CreateWorkViews();

            BindCommands();
        }
        public DotLiquidViewEngine(IFileSystemFactory fileSystem, IViewLocator viewLocator, IEnumerable<Type> filters)
        {
            DotLiquid.Liquid.UseRubyDateFormat = true;
            _viewLocator = viewLocator;
            this._fileSystem = fileSystem;
            // Register custom tags (Only need to do this once)
            Template.RegisterFilter(typeof(CommonFilters));
            Template.RegisterFilter(typeof(CommerceFilters));

            foreach (var filter in filters)
            {
                Template.RegisterFilter(filter);
            }

            Template.RegisterTag<Paginate>("paginate");
            Template.RegisterTag<CurrentPage>("current_page");
            Template.RegisterTag<Layout>("layout");
        }
Exemple #45
0
        public TemplatesModule(IDocumentSession session, IViewLocator viewLocator)
            : base("Templates")
        {
            Get["/"] = p =>
                           {
                               var templates = session.Query<ViewTemplate>().ToArray();

                               return View["List", templates];
                           };

            Get["/new/"] = p => View["Edit", new ViewTemplate {}];

            Get[@"/edit/(?<viewName>\S+)/"] = p =>
                                                  {
                                                      var viewName = (string) p.viewName;
                                                var template = session.Load<ViewTemplate>(viewName);

                                                // Even if we don't have it stored in the DB, it might still exist as a resource. Try loading it from Nancy.
                                                if (template == null)
                                                {
                                                    ViewLocationResult vlr = viewLocator.LocateView(viewName, Context);
                                                    if (vlr == null)
                                                        return 404;

                                                    template = new ViewTemplate
                                                                   {
                                                                       Location = vlr.Location,
                                                                       Name = vlr.Name,
                                                                       Extension = vlr.Extension,
                                                                       Contents = vlr.Contents.Invoke().ReadToEnd(),
                                                                   };
                                                }

                                                return View["Edit", template];
                                            };

            Post["/new/"] = p =>
                                {
                                    var template = this.Bind<ViewTemplate>();
                                    session.Store(template, string.Concat(Constants.RavenViewDocumentPrefix, template.Location, "/", template.Name, ".", template.Extension));

                                    return Response.AsRedirect("/");
                                };
        }
Exemple #46
0
 public void UpdateViewTemplate(IViewLocator viewLocator)
 {
     if (ViewTemplate != null)
     {
         return;
     }
     if (ViewType != null)
     {
         ViewTemplate = viewLocator.CreateViewTemplate(ViewType);
         return;
     }
     if (!string.IsNullOrEmpty(ViewName))
     {
         ViewTemplate = viewLocator.CreateViewTemplate(ViewName);
         return;
     }
     ViewTemplate = null;
     return;
 }
        public ViewEngineStartupFixture()
        {
            this.views = new List<ViewLocationResult>
            {
                new ViewLocationResult("", "", "html", null),
                new ViewLocationResult("", "", "spark", null),
            };

            var viewLocationProvider = A.Fake<IViewLocationProvider>();
            A.CallTo(() => viewLocationProvider.GetLocatedViews(A<IEnumerable<string>>._))
                                               .Returns(views);

            var viewEngine = A.Fake<IViewEngine>();
            A.CallTo(() => viewEngine.Extensions).Returns(new[] { "liquid" });

            this.viewLocator = new DefaultViewLocator(viewLocationProvider, new[] { viewEngine });

            this.viewCache = A.Fake<IViewCache>();
        }
Exemple #48
0
 public override void RegisterViews(IViewLocator viewLocator)
 {
     // database
     viewLocator.Bind <DatabaseConfigViewModel, DatabaseConfigView>();
     viewLocator.Bind <DebugQueryToolViewModel, DebugQueryToolView>();
     // solutions
     viewLocator.Bind <SolutionExplorerViewModel, SolutionExplorerView>();
     // parameters
     viewLocator.Bind <ParametersViewModel, ParametersView>();
     // history
     viewLocator.Bind <HistoryViewModel, HistoryView>();
     // dbc store
     viewLocator.Bind <DBCConfigViewModel, DBCConfigView>();
     // sql editor
     viewLocator.Bind <SqlEditorViewModel, SqlEditorView>();
     // updater
     viewLocator.Bind <ChangeLogViewModel, ChangeLogView>();
     viewLocator.Bind <UpdaterConfigurationViewModel, UpdaterConfigurationView>();
 }
        public ActivityRoutedViewHost(Activity hostActivity, IViewLocator viewLocator = null)
        {
            viewLocator = viewLocator ?? ViewLocator.Current;
            var platform = RxApp.DependencyResolver.GetService <IPlatformOperations>();

            var keyUp = hostActivity.GetType()
                        .GetMethods(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Instance)
                        .FirstOrDefault(x => x.Name == "OnKeyUp");

            if (keyUp == null)
            {
                throw new Exception("You must override OnKeyUp and call theRoutedViewHost.OnKeyUp");
            }

            var viewFor = hostActivity as IViewFor;

            if (viewFor == null)
            {
                throw new Exception("You must implement IViewFor<TheViewModelClass>");
            }

            bool firstSet = false;

            _inner = _hostScreen.Router.CurrentViewModel
                     .Where(x => x != null)
                     .Subscribe(vm => {
                if (!firstSet)
                {
                    viewFor.ViewModel = vm;
                    firstSet          = true;
                    return;
                }

                var view = viewLocator.ResolveView(vm, platform.GetOrientation());
                if (view.GetType() != typeof(Type))
                {
                    throw new Exception("Views in Android must be the Type of an Activity");
                }

                hostActivity.StartActivity((Type)view);
            });
        }
        public ActivityRoutedViewHost(Activity hostActivity, IViewLocator viewLocator = null)
        {
            viewLocator = viewLocator ?? ViewLocator.Current;
            var platform = RxApp.DependencyResolver.GetService<IPlatformOperations>();

            var keyUp = hostActivity.GetType()
                .GetMethods(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Instance)
                .FirstOrDefault(x => x.Name == "OnKeyUp");

            if (keyUp == null) {
                throw new Exception("You must override OnKeyUp and call theRoutedViewHost.OnKeyUp");
            }

            var viewFor = hostActivity as IViewFor;
            if (viewFor == null) {
                throw new Exception("You must implement IViewFor<TheViewModelClass>");
            }

            bool firstSet = false;

            _inner = _hostScreen.Router.CurrentViewModel
                .Where(x => x != null)
                .Subscribe(vm => {
                    if (!firstSet) {
                        viewFor.ViewModel = vm;
                        firstSet = true;
                        return;
                    }

                    var view = viewLocator.ResolveView(vm, platform.GetOrientation());
                    if (view.GetType() != typeof(Type)) {
                        throw new Exception("Views in Android must be the Type of an Activity");
                    }
                    
                    hostActivity.StartActivity((Type)view);
                });
        }
 static void Verify(IViewLocator viewLocator) {
     if(viewLocator == null)
         throw new ArgumentNullException("viewLocator");
 }
 public ThemeFileSystem(IViewLocator locator)
 {
     this._locator = locator;
 }
 public DefaultViewFactoryFixture()
 {
     this.locator = A.Fake<IViewLocator>();
 }
 protected virtual void OnViewLocatorChanged(IViewLocator oldValue, IViewLocator newValue) { }
 public ViewEngineStartupContext(IViewCache viewCache, IViewLocator viewLocator)
 {
     this.ViewLocator = viewLocator;
     this.ViewCache = viewCache;
 }
 public NavigationViewManager(IViewLocator viewLocator, IViewModelBinder viewModelBinder)
     : base(viewLocator, viewModelBinder)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="UIVisualizerService"/> class.
        /// </summary>
        /// <param name="viewLocator">The view locator.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="viewLocator"/> is <c>null</c>.</exception>
        public UIVisualizerService(IViewLocator viewLocator)
        {
            Argument.IsNotNull(() => viewLocator);

            _viewLocator = viewLocator;
        }
Exemple #58
0
 /// <summary>
 /// Initializes the framework with the specified view locator and view model binder.
 /// </summary>
 /// <param name="viewLocator">The view locator.</param>
 /// <param name="viewModelBinder">The view model binder.</param>
 public static void Initialize(IViewLocator viewLocator, IViewModelBinder viewModelBinder)
 {
     View.viewLocator = viewLocator;
     View.viewModelBinder = viewModelBinder;
 }
Exemple #59
0
 /// <summary>
 /// Sets the <see cref="IViewLocator"/>.
 /// </summary>
 /// <param name="d">The element to attach the strategy to.</param>
 /// <param name="value">The strategy.</param>
 public static void SetStrategy(DependencyObject d, IViewLocator value)
 {
     d.SetValue(StrategyProperty, value);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewEngineApplicationStartup"/> class, with the
 /// provided <paramref name="viewEngines"/>, <paramref name="viewCache"/> and <paramref name="viewLocator"/>.
 /// </summary>
 /// <param name="viewEngines">The available view engines.</param>
 /// <param name="viewCache">The view cache.</param>
 /// <param name="viewLocator">The view locator.</param>
 public ViewEngineApplicationStartup(IEnumerable<IViewEngine> viewEngines, IViewCache viewCache, IViewLocator viewLocator)
 {
     this.viewEngines = viewEngines;
     this.viewCache = viewCache;
     this.viewLocator = viewLocator;
 }