public BottomBarModel() { _displayController = ClassLocator.GetInstance <IDisplayController>(); Debug.Assert(_displayController != null, "IDisplayController not found for BottomBarModel"); UserMessage = "Initializing..."; MessageType = MessageTypeEnum.Information; }
public static T CreateBindable <T>(object context) where T : BindableObject { var obj = ClassLocator.Create <T>(context); if (obj != null) { obj.BindingContext = GetInstance(context); } return(obj); }
public AboutViewModel() { if (this.IsInDesignMode) { _aboutModel = new AboutModelSimulator(); } else { _aboutModel = ClassLocator.GetInstance <IAboutModel>(); Debug.Assert(_aboutModel != null, "IAboutModel not found for AboutViewModel"); } }
protected override void OnStartup(StartupEventArgs e) { DispatcherHelper.Initialize(); //This one need to be registered immediately so that the ClassLocator.Register <IDisplayController>(() => new DisplayController()); ClassLocator.Register <IBottomBarModel>(() => new BottomBarModel()); _controllerStartUp = new StartUp(); _controllerStartUp.Initialized += (sender, args) => { }; _controllerStartUp.Initialize(); }
public static void AddDefaultViewLocators() { ClassLocator.AddLocator(new DefaultClassLocator <Page> { ReferenceClassNameSuffix = "PageViewModel", ReferenceNamespaceSuffix = "ViewModels", TargetClassNameSuffix = "Page", TargetNamespaceSuffix = "Views" }); ClassLocator.AddLocator(new DefaultClassLocator <Page> { ReferenceClassNameSuffix = "FormViewModel", ReferenceNamespaceSuffix = "ViewModels", TargetClassNameSuffix = "Form", TargetNamespaceSuffix = "Views" }); ClassLocator.AddLocator(new DefaultClassLocator <View> { ReferenceClassNameSuffix = "ViewModel", ReferenceNamespaceSuffix = "ViewModels", TargetClassNameSuffix = "View", TargetNamespaceSuffix = "Views" }); ClassLocator.AddLocator(new DefaultClassLocator <Page> { ReferenceClassNameSuffix = "ViewModel", ReferenceNamespaceSuffix = "ViewModels", TargetClassNameSuffix = "Page", TargetNamespaceSuffix = "Views" }); ClassLocator.AddLocator(new DefaultClassLocator <View> { ReferenceClassNameSuffix = "ViewModel", ReferenceNamespaceSuffix = "ViewModels", TargetClassNameSuffix = "Form", TargetNamespaceSuffix = "Views" }); //ClassLocator.AddLocator(new DefaultClassLocator<Page> { // ReferenceClassNameSuffix = "EditModel", // ReferenceNamespaceSuffix = "ViewModels", // TargetClassNameSuffix = "EditPage", // TargetNamespaceSuffix = "Views" //}); //ClassLocator.AddLocator(new DefaultClassLocator<Page> { // ReferenceClassNameSuffix = "EditModel", // ReferenceNamespaceSuffix = "ViewModels", // TargetClassNameSuffix = "EditForm", // TargetNamespaceSuffix = "Views" //}); }
public void TestClassLocator() { ClassLocator locator = new ClassLocator("someFolder.SomeClassName"); Assert.AreEqual("SomeClassName", locator.ClassName); Assert.AreEqual("someFolder.SomeClassName", locator.ImportFullName); Assert.AreEqual("someFolder/SomeClassName.java", locator.RelativePath); string sourcePath = ModPaths.SourceCodeRootFolder("TestMod", "testorg"); string armorBasePath = Path.Combine(sourcePath, SourceCodeLocator.ArmorBase.RelativePath); string armorBaseFileName = Path.GetFileNameWithoutExtension(armorBasePath); Assert.AreEqual(armorBaseFileName, SourceCodeLocator.ArmorBase.ClassName); }
public ConfigurationViewModel() { if (this.IsInDesignMode) { _configurationModel = new ConfigurationModelSimulator(); } else { _configurationModel = ClassLocator.GetInstance <IConfigurationModel>(); Debug.Assert(_configurationModel != null, "INavigateCommands not found for AboutViewModel"); } ConfigurationItems = new ObservableCollection <IConfigurationItemViewModel>(); _configurationModel.ConfigurationItems.ToList().ForEach(i => ConfigurationItems.Add(ViewModelHelpers.GetConfigurationItemViewModel(i))); }
public MenuViewModel() { if (this.IsInDesignMode) { _menuModel = new MenuModelSimulator(); } else { _menuModel = ClassLocator.GetInstance <IMenuModel>(); Debug.Assert(_menuModel != null, "INavigateCommands not found for AboutViewModel"); } Buttons = new ObservableCollection <ButtonViewModel>(); _menuModel.MenuButtonCommands.ToList().ForEach(i => Buttons.Add(new ButtonViewModel(i))); }
private void RegisterConcreteInstances(ContainerBuilder builder) { foreach (var type in _classLocator.Implements <IConcrete>()) { if (ClassLocator.Implements <ISingleton>(type)) { Trace($"register concrete: {type.Name} -> AsSelf, SingleInstance"); builder.RegisterType(type).AsImplementedInterfaces().SingleInstance(); } else { Trace($"register concrete: {type.Name} -> AsSelf, InstancePerDependency"); builder.RegisterType(type).AsSelf().InstancePerDependency(); } } }
public static UiViewModelBase ViewModel(this ChangeDisplayEventArgs changeDisplayEventArgs) { UiViewModelBase viewModel; var viewModelInterface = changeDisplayEventArgs.ViewModelInterface; var dictionary = ChangeDisplayEventArgs.InterfaceTypeDictionary; if (changeDisplayEventArgs.CreateNew) { viewModel = CreateViewModel(changeDisplayEventArgs, dictionary, viewModelInterface); } else if (ClassLocator.ContainsCreated(changeDisplayEventArgs.ViewModelInterface)) { viewModel = (UiViewModelBase)ClassLocator.GetInstance(changeDisplayEventArgs.ViewModelInterface); } else { viewModel = CreateViewModel(changeDisplayEventArgs, dictionary, viewModelInterface); ClassLocator.Register(() => viewModel); } return(viewModel); }
public MenuModel() { _displayController = ClassLocator.GetInstance <IDisplayController>(); Debug.Assert(_displayController != null, "IDisplayController not found for MenuModel"); MenuButtonCommands = new List <IButtonModel>() { new MenuButtonModel("Home", (s, a) => { _displayController.RevertDisplay(); }), new MenuButtonModel("About", (s, a) => { _displayController.ChangeDisplay(typeof(IAboutViewModel), DisplayActionTypes.PushPreviousDisplay, true); }), new MenuButtonModel("Configuraton", (s, a) => { _displayController.ChangeDisplay(typeof(IConfigurationViewModel), DisplayActionTypes.PushPreviousDisplay, true); }), }; }
public async void Initialize() { ClassLocator.Register <IDisplayController>(() => new DisplayController()); ClassLocator.Register <IBottomBarModel>(() => new BottomBarModel()); _displayController = ClassLocator.GetInstance <IDisplayController>(); _bottomBarModel = ClassLocator.GetInstance <IBottomBarModel>(); Debug.Assert(_displayController != null, "IDisplayController not found for BackEndSimulator"); Debug.Assert(_bottomBarModel != null, "IBottomBarModel not found for BackEndSimulator"); ClassLocator.Register <IMenuModel>(() => new MenuModel()); ClassLocator.Register <IAboutModel>(() => new AboutModel()); ClassLocator.Register <IConfigurationModel>(() => new ConfigurationModel()); Initialized?.Invoke(this, new InitializedEventArgs()); await Task.Run(() => { Thread.Sleep(10000); _bottomBarModel.UpdateUserMessage("10 seconds have passed", MessageTypeEnum.Warning); // _displayController.ChangeDisplay(typeof(IAboutViewModel), true); }); }
public MainViewModel() { PrimaryViewModel = new SplashScreenViewModel { DisposeOfAfterUse = true }; if (this.IsInDesignMode) { _bottomBarModel = new BottomBarModelSimulator(); _displayController = new DisplayControllerSimulator(); } else { _displayController = ClassLocator.GetInstance <IDisplayController>(); Debug.Assert(_displayController != null, nameof(IDisplayController) + " not found for " + GetType().Name); _displayController.ChangeDisplayEvent += DisplayChangeEventHandler; _bottomBarModel = ClassLocator.GetInstance <IBottomBarModel>(); Debug.Assert(_bottomBarModel != null, nameof(IBottomBarModel) + " not found for " + GetType().Name); _bottomBarModel.UpdateEvent += UpdateUserMessageEventHandler; } UserMessage = _bottomBarModel.UserMessage; MessageType = _bottomBarModel.MessageType; }
public ServiceLocator(IEnumerable <string> assemblyMatchRegex, bool debug = false) { _debug = debug; _classLocator = new ClassLocator(assemblyMatchRegex, debug); }
public ServiceLocator(string assemblyMatchRegex = ".*", bool debug = false) { _debug = debug; _classLocator = new ClassLocator(new[] { "^NCore\\.Base\\.Commands$", assemblyMatchRegex }, debug); }
public AboutModel() { _displayController = ClassLocator.GetInstance <IDisplayController>(); Debug.Assert(_displayController != null, "IDisplayController not found for AboutModel"); }
public ServiceDependencies(ContainerBuilder builder) { _builder = builder; _finder = new ClassLocator("Pangul\\..*"); }