protected override void Init() { Container.Register <ILogger, DebugLogger>(); Container.Register <IDbService, TestDbService>(); SmallProfiler.Start(); Container.Resolve <IDbService>().Initialize(); AsanaStateService.Initialize(); ViewModelMap.Register <DevRain.Asana.Pages.MainPage, MainViewModel>(); ViewModelMap.Register <WorkspaceDetails, WorkspaceDetailsViewModel>(); ViewModelMap.Register <UserDetails, UserDetailsViewModel>(); ViewModelMap.Register <AddEditProject, AddEditProjectViewModel>(); ViewModelMap.Register <TagDetails, TagDetailsViewModel>(); ViewModelMap.Register <TaskDetails, TaskDetailsViewModel>(); ViewModelMap.Register <AddEditTask, AddEditTaskViewModel>(); ViewModelMap.Register <ProjectDetails, ProjectDetailsViewModel>(); ViewModelCache.Register <WorkspaceDetailsViewModel>(); ViewModelCache.Register <ProjectDetailsViewModel>(); ViewModelCache.Register <UserDetailsViewModel>(); ViewModelCache.Register <TagDetailsViewModel>(); ViewModelCache.Register <TaskDetailsViewModel>(); //Container.Resolve<ILogger>().Debug("Init complete"); }
private PropertyViewModel GetViewModelCore(IPropertyInfo property) { Type[] interfaces = property.GetType().GetInterfaces(); Type hasPredefinedValues = interfaces.FirstOrDefault(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IHavePredefinedValues <>)); if (hasPredefinedValues != null) { bool combinable = (bool)hasPredefinedValues.GetProperty(nameof(IHavePredefinedValues <bool> .IsValueCombinable)).GetValue(property); Type type = combinable ? typeof(CombinablePropertyViewModel <>).MakeGenericType(hasPredefinedValues.GenericTypeArguments[0]) : typeof(PredefinedValuesViewModel <>).MakeGenericType(hasPredefinedValues.GenericTypeArguments[0]); return((PropertyViewModel)Activator.CreateInstance(type, TargetPlatform, property, this.objEditors)); } else if (property.Type == typeof(object)) { return(new ObjectPropertyViewModel(EditorProvider, TargetPlatform, property, this.objEditors)); } if (ViewModelMap.TryGetValue(property.Type, out var vmFactory)) { return(vmFactory(TargetPlatform, property, this.objEditors)); } return(new StringPropertyViewModel(TargetPlatform, property, this.objEditors)); }
private PropertyViewModel CreateViewModel(IPropertyInfo property, PropertyVariation variant = null) { PropertyViewModel vm; Type[] interfaces = property.GetType().GetInterfaces(); Type hasPredefinedValues = interfaces.FirstOrDefault(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IHavePredefinedValues <>)); if (hasPredefinedValues != null) { bool combinable = (bool)hasPredefinedValues.GetProperty(nameof(IHavePredefinedValues <bool> .IsValueCombinable)).GetValue(property); Type type = combinable ? typeof(CombinablePropertyViewModel <>).MakeGenericType(hasPredefinedValues.GenericTypeArguments[0]) : typeof(PredefinedValuesViewModel <>).MakeGenericType(hasPredefinedValues.GenericTypeArguments[0]); vm = (PropertyViewModel)Activator.CreateInstance(type, TargetPlatform, property, this.objEditors, variant); } else if (ViewModelMap.TryGetValue(property.Type, out var vmFactory)) { vm = vmFactory(TargetPlatform, property, this.objEditors, variant); } else { vm = new StringPropertyViewModel(TargetPlatform, property, this.objEditors, variant); } vm.Parent = this; vm.VariantsChanged += OnVariantsChanged; return(vm); }
protected AppBootstrapper(Type startupPageType) { _startupPageType = startupPageType; Container = new IocContainer(); ViewModelMap = new ViewModelMap(); InitContainer(); InitCore(); }
private ViewModelMap <MenuItemVM, MenuItem> CreateViewModelMap(MenuAnchor anchor, Expression <Func <bool> > hasItemsProperty) { var map = new ViewModelMap <MenuItemVM, MenuItem>(MenuManager.Instance.GetMenuItems(anchor), vm => this.CreateMenuItem(vm, hasItemsProperty)); map.CollectionChanged += (o, e) => this.RaisePropertyChanged(hasItemsProperty); return(map); }
protected Bootstrapper() { Container = new IocContainer(); ViewModelMap = new ViewModelMap(); InitRootFrame(); InitContainer(); InitPhoneServices(); InitMvvm(); Current = this; }
protected override void Init() { Container.Register <ILogger, DebugLogger>(); Container.Register <DbService, DbService>(); Container.RegisterInstance <IAsanaResponseProcessor, AsanaResponseProcessor>(); SmallProfiler.Start(); Container.Resolve <DbService>().Initialize(); InteractionEffectManager.AllowedTypes.Add(typeof(RadDataBoundListBoxItem)); Counter.Start(10669); RadDiagnostics diagnostics = new RadDiagnostics(); diagnostics.EmailTo = AsanaConstants.FeedbackEmail; diagnostics.EmailSubject = AsanaConstants.AppTitle; diagnostics.ApplicationVersion = DeviceHelper.GetAppVersion().ToString(); //diagnostics.MessageBoxInfo.Title = ""; diagnostics.MessageBoxInfo.Content = "Would you to like to send information about error to developers?"; diagnostics.Init(); Telerik.Windows.Controls.ApplicationUsageHelper.Init(DeviceHelper.GetAppVersion().ToString()); /// /// AsanaStateService.Initialize(); //ApplicationRatingNotificationServiceFromNokia.Initialize("Winsana","*****@*****.**"); ViewModelMap.Register <MainPage, MainViewModel>(); ViewModelMap.Register <WorkspaceDetails, WorkspaceDetailsViewModel>(); ViewModelMap.Register <UserDetails, UserDetailsViewModel>(); ViewModelMap.Register <AddEditProject, AddEditProjectViewModel>(); ViewModelMap.Register <TagDetails, TagDetailsViewModel>(); ViewModelMap.Register <TaskDetails, TaskDetailsViewModel>(); ViewModelMap.Register <AddEditTask, AddEditTaskViewModel>(); ViewModelMap.Register <ProjectDetails, ProjectDetailsViewModel>(); ViewModelMap.Register <AllTasks, AllTasksViewModel>(); ViewModelMap.Register <SettingsPage, SettingsViewModel>(); ViewModelCache.Register <WorkspaceDetailsViewModel>(); ViewModelCache.Register <ProjectDetailsViewModel>(); ViewModelCache.Register <UserDetailsViewModel>(); ViewModelCache.Register <TagDetailsViewModel>(); ViewModelCache.Register <TaskDetailsViewModel>(); System.Threading.Tasks.TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; }
public GameClientExplorerVM(GameClientExplorerModule module, Dispatcher dispatcher) { this.Module = module; this.Dispatcher = dispatcher; _gameClients = new ViewModelMap <IRepository, LocalGameClientNodeVM>(RepositoryManager.Instance.Repositories, r => new LocalGameClientNodeVM(this, ((LocalGameClient)r)), null, r => r is LocalGameClient); this.ExplorerTreeDragHandler = new ExplorerTreeDragHandlerImpl(); this.ManageRepositoriesCommand = new RelayCommand(this.ManageRepositories); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddJsonOptions(options => { options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }); services.AddAntiforgery(); //Map mapper = new Map(); ViewModelMap viewModelMap = new ViewModelMap(); switch (Configuration.GetSection("DatabaseEngine").Value) { case "MySQL": services.AddDbContext <TrainersContext>( options => options.UseMySql( Configuration.GetConnectionString("DefaultConnection"), x => x.MigrationsAssembly("PersonalTrainer.WebApp.Core"))); break; default: services.AddDbContext <TrainersContext>( options => options.UseSqlServer( Configuration.GetConnectionString("DefaultConnection"), x => x.MigrationsAssembly("PersonalTrainer.WebApp.Core"))); break; } ContainerBuilder builder = new ContainerBuilder(); builder.Populate(services); builder.RegisterModule <ApplicationLayerModule>(); builder.RegisterModule <DomainModelLayerModule>(); builder.RegisterModule <InfrastructureLayerModule>(); builder.RegisterModule <ExtensionsModule>(); this.ApplicationContainer = builder.Build(); return(new AutofacServiceProvider(this.ApplicationContainer)); }
public TankMuseumVM() { _allTanks = new ViewModelMap <IRepository, TankVM[]>(RepositoryManager.Instance.Repositories, r => { var repositoryVm = new RepositoryVM(r); return(r.TankDatabase.QueryMany("tank") .Select(t => new TankVM(repositoryVm, new Tank(t))).ToArray()); }); _allTanks.CollectionChanged += _allTanks_CollectionChanged; this.ListedTanks = CollectionViewSource.GetDefaultView(_allTanks); this.ListedTanks.Filter = this.Filter; this.TankListDragHandler = new TankListDragHandlerImpl(); this.ContextMenuItems = new ObservableCollection <MenuItemVM>(); this.ContextMenuItems.Add(new MenuItemVM("text")); this.ResetFiltersCommand = new RelayCommand(this.ResetFilters); }
public MacPanelViewModel(IEditorProvider provider) : base(provider) { ViewModelMap.Add(typeof(CoreGraphics.CGPoint), (p, e) => new PropertyViewModel <CoreGraphics.CGPoint> (p, e)); }