public void HelloWorldVM() { VMController.RegisterAssembly <BaseVM>(typeof(HelloWorldVM).Assembly); var vmController = new VMController(TestResponse); vmController.OnRequestVM("conn1", typeof(HelloWorldVM).Name); Assert.AreEqual(typeof(HelloWorldVM).Name, _vmId); var vm = GetVM <HelloWorldVM>(); Assert.IsNotNull(vm); Assert.AreEqual("Hello", vm.FirstName); Assert.AreEqual("World", vm.LastName); Assert.AreEqual("Hello World", vm.FullName); var update = new Dictionary <string, object>() { { "FirstName", "John" } }; vmController.OnUpdateVM("conn1", typeof(HelloWorldVM).Name, update); Assert.IsNotNull(VMData); Assert.AreEqual("John World", VMData["FullName"]); update = new Dictionary <string, object>() { { "LastName", "Doe" } }; vmController.OnUpdateVM("conn1", typeof(HelloWorldVM).Name, update); Assert.IsNotNull(VMData); Assert.AreEqual("John Doe", VMData["FullName"]); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); VMController.RegisterAssembly(typeof(MvcApplication).Assembly); }
public void Configuration(IAppBuilder app) { app.MapSignalR(); app.UseNancy(); VMController.RegisterAssembly(typeof(HomeModule).Assembly); VMController.RegisterAssembly(typeof(ExamplesLibrary.TreeViewVM).Assembly); }
public static IApplicationBuilder UseDotNetifyPulse(this IApplicationBuilder app, Action <PulseConfiguration> options = null) { var pulseConfig = app.ApplicationServices.GetRequiredService <PulseConfiguration>(); options?.Invoke(pulseConfig); VMController.RegisterAssembly(typeof(PulseVM).Assembly); app.UseMiddleware <PulseMiddleware>(); return(app); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddMemoryCache(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddReact(); services.AddSignalR(); services.AddDotNetify(); VMController.RegisterAssembly(GetType().GetTypeInfo().Assembly); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); // Register the assembly that has the view model. VMController.RegisterAssembly(typeof(MvcApplication).Assembly); // Using IoC container to inject dependencies. var container = new Container(); VMController.CreateInstance = (type, args) => args == null?container.GetInstance(type) : Activator.CreateInstance(type, args); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc(); // SignalR and Memory Cache are required by dotNetify. services.AddSignalR(options => options.Hubs.EnableDetailedErrors = true); services.AddMemoryCache(); // Add dotNetify services. services.AddDotNetify(); // Tell dotNetify which assembly to resolve the view models. VMController.RegisterAssembly(this.GetType().GetTypeInfo().Assembly); }
public void Initialize() { VMController.RegisterAssembly(typeof(BetterListVM).Assembly); var baseDelegate = VMController.CreateInstance; VMController.CreateInstance = (type, args) => { if (type == typeof(BetterListVM)) { return(new BetterListVM(_model)); } return(baseDelegate(type, args)); }; }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); // Find the DEMO assembly "ViewModels" and register it to DotNetify.VMController. // This will cause all the classes inside the assembly that inherits from DotNetify.BaseVM to be known as view models. var vmAssembly = System.Reflection.Assembly.Load("ViewModels"); if (vmAssembly != null) { VMController.RegisterAssembly(vmAssembly); } // The following demonstrates dotNetify's capability to support dependency injection. // In this example, the responsibility of constructing the model object is delegated // away from its view model. You can use your favorite IoC container to provide // view model instances here. VMController.CreateInstance = (type, args) => { if (type == typeof(SimpleListVM)) { return(new SimpleListVM(new EmployeeModel(7))); } else if (type == typeof(BetterListVM)) { return(new BetterListVM(new EmployeeModel(7))); } else if (type == typeof(AFITop100VM)) { return(new AFITop100VM(new AFITop100Model())); } else if (type == typeof(TreeViewVM)) { return(new TreeViewVM(new EmployeeModel())); } else if (type == typeof(GridViewVM)) { return(new GridViewVM(new EmployeeModel())); } else if (type == typeof(CompositeViewVM)) { return(new CompositeViewVM(new EmployeeModel())); } return(Activator.CreateInstance(type, args)); }; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc(); // SignalR and Memory Cache are required by dotNetify. services.AddSignalR(options => options.Hubs.EnableDetailedErrors = true); services.AddMemoryCache(); services.AddDotNetify(); // Find the assembly "ViewModels.Examples" and register it to DotNetify.VMController. // This will cause all the classes inside the assembly that inherits from DotNetify.BaseVM to be known as view models. var vmAssembly = Assembly.Load(new AssemblyName("ViewModels.Examples")); if (vmAssembly != null) { VMController.RegisterAssembly(vmAssembly); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc(); services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); // Add authentication middleware and inform .NET Core MVC what scheme we'll be using. services.AddAuthentication(options => options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); // SignalR and Memory Cache are required by dotNetify. services.AddSignalR(options => options.Hubs.EnableDetailedErrors = true); services.AddMemoryCache(); services.AddTransient <IMenuRepository, MenuRepository>(); services.AddTransient <IMenuService, MenuService>(); services.AddTransient <IShoppingCartService, ShoppingCartService>(); services.AddTransient <IAccountService, AccountService>(); services.AddSingleton <IUserCache, UserCache>(); services.AddDotNetify(); services.AddScoped <ClaimsPrincipal>(p => p.GetRequiredService <IPrincipalAccessor>().Principal as ClaimsPrincipal); // Find the assembly "ViewModels" and register it to DotNetify.VMController. // This will cause all the classes inside the assembly that inherits from DotNetify.BaseVM to be known as view models. var vmAssembly = Assembly.Load(new AssemblyName("ViewModels")); if (vmAssembly != null) { VMController.RegisterAssembly(vmAssembly); } }
public static void Initialize(TestContext testContext) { VMController.RegisterAssembly <BaseVM>(typeof(ControlTypesVM).Assembly); }
static VMControllerTest() { VMController.RegisterAssembly <BaseVM>(typeof(UnitTestVM).Assembly); }