/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(IExampleDataService exampleDataService) { _exampleDataService = exampleDataService; _exampleDataService.GetData( (item, error) => { if (error != null) { // Report error here return; } WelcomeTitle = item.Title; }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IExampleDataService exampleDataService) { if (!env.IsDevelopment()) { app.UseRewriter(new RewriteOptions().AddRedirectToHttps(301)); } app.UseCors("CorsPolicy"); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseMvc(); app.UseSpa(spa => { spa.ApplicationBuilder.UseMetaDataMiddleware(new List <MetadataMiddlewareOptions> { // This metadata affects to all the routes that are not included in the list new MetadataMiddlewareOptions { FilterPath = "/", GetTokens = (route) => { return(new List <MetadataToken> { new MetadataToken { Key = AppKeys.TwitterCardTokenKey, Value = AppKeys.TwitterCardTokenValue }, new MetadataToken { Key = AppKeys.MetadataTitleKey, Value = AppKeys.MetadataTitleValue }, new MetadataToken { Key = AppKeys.MetadataImageKey, Value = AppKeys.MetadataImageValue }, new MetadataToken { Key = AppKeys.MetadataDescriptionKey, Value = AppKeys.MetadataDescriptionValue } }); } }, // This metadata will only affect to /page1 new MetadataMiddlewareOptions { FilterPath = "page1", GetTokens = (route) => { var results = exampleDataService.Get(route).Result; return(new List <MetadataToken> { new MetadataToken { Key = AppKeys.TwitterCardTokenKey, Value = AppKeys.TwitterCardTokenValue }, new MetadataToken { Key = AppKeys.MetadataTitleKey, Value = results.Title }, new MetadataToken { Key = AppKeys.MetadataImageKey, Value = results.Image }, new MetadataToken { Key = AppKeys.MetadataDescriptionKey, Value = results.Description } }); } }, // This metadata will only affect to /page2 new MetadataMiddlewareOptions { FilterPath = "page2", GetTokens = (route) => { return(new List <MetadataToken> { new MetadataToken { Key = AppKeys.TwitterCardTokenKey, Value = AppKeys.TwitterCardTokenValue }, new MetadataToken { Key = AppKeys.MetadataTitleKey, Value = "Custom title" }, new MetadataToken { Key = AppKeys.MetadataImageKey, Value = AppKeys.MetadataImageValue }, new MetadataToken { Key = AppKeys.MetadataDescriptionKey, Value = "Custom description" } }); } } }); }); }
public UserViewModel(IMvxLogProvider logProvider, IMvxNavigationService navigationService, IExampleDataService exampleDataService) : base(logProvider, navigationService) { this._exampleDataService = exampleDataService; }
public ExampleDataController(IExampleDataService exampleDataService) { _exampleDataService = exampleDataService; }