示例#1
0
 public BottomBarModel()
 {
     _displayController = ClassLocator.GetInstance <IDisplayController>();
     Debug.Assert(_displayController != null, "IDisplayController not found for BottomBarModel");
     UserMessage = "Initializing...";
     MessageType = MessageTypeEnum.Information;
 }
示例#2
0
        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);
        }
示例#3
0
 public AboutViewModel()
 {
     if (this.IsInDesignMode)
     {
         _aboutModel = new AboutModelSimulator();
     }
     else
     {
         _aboutModel = ClassLocator.GetInstance <IAboutModel>();
         Debug.Assert(_aboutModel != null, "IAboutModel not found for AboutViewModel");
     }
 }
示例#4
0
        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();
        }
示例#5
0
        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"
            //});
        }
示例#6
0
        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);
        }
示例#7
0
 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)));
 }
示例#8
0
 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)));
 }
示例#9
0
 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();
         }
     }
 }
示例#10
0
        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);
        }
示例#11
0
        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);
                }),
            };
        }
示例#12
0
        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);
            });
        }
示例#13
0
        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;
        }
示例#14
0
 public ServiceLocator(IEnumerable <string> assemblyMatchRegex, bool debug = false)
 {
     _debug        = debug;
     _classLocator = new ClassLocator(assemblyMatchRegex, debug);
 }
示例#15
0
 public ServiceLocator(string assemblyMatchRegex = ".*", bool debug = false)
 {
     _debug        = debug;
     _classLocator = new ClassLocator(new[] { "^NCore\\.Base\\.Commands$", assemblyMatchRegex }, debug);
 }
示例#16
0
 public AboutModel()
 {
     _displayController = ClassLocator.GetInstance <IDisplayController>();
     Debug.Assert(_displayController != null, "IDisplayController not found for AboutModel");
 }
示例#17
0
 public ServiceDependencies(ContainerBuilder builder)
 {
     _builder = builder;
     _finder  = new ClassLocator("Pangul\\..*");
 }