public Client() { MefContainer.Compose(this); this.PackageCreatorTasks.Progress += this.OnProgressChanged; this.PackageDeployerTasks.Progress += this.OnProgressChanged; }
protected override async Task <bool> OnApply(IGameState gameState) { var threeChoicesViewModel = MefContainer.GetExportedValue <IThreeChoicesViewModel>(); threeChoicesViewModel.Option1 = Option1; threeChoicesViewModel.Option2 = Option2; threeChoicesViewModel.CanSelectOption1 = CanApplyOption1(gameState); threeChoicesViewModel.CanSelectOption2 = CanApplyOption2(gameState); var result = await MetroDialog.ShowDialog(threeChoicesViewModel); if (result == Selection.None) { return(false); } if (result == Selection.Option1) { return(await ApplyOption1(gameState)); } if (result == Selection.Option2) { return(await ApplyOption2(gameState)); } if (result == Selection.Option3) { return(await ApplyOption3(gameState)); } return(false); }
public static void Main(string[] args) { var config = MefContainer.BuildConfigurationForConsoleApp(); var mef = MefContainer.CreateWithConfiguration(config); mef.GetExport <JobRunner>().RunForeverAsync().Wait(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); MefContainer.ConfigureContainer(); }
public AppContext(string appName, TracingOutput tracingOutput = TracingOutput.File, TracerType tracerType = TracerType.Default, bool debugMode = false, IEnumerable <Assembly> assemblies = null) { Container = new MefContainer(assemblies); Container.ComposeInstance(Container); var tracer = Container.GetInstances <ITracer>().First(t => t.TracerType == tracerType); tracer.Initialize(appName, tracingOutput, debugMode); TraceUtil.SetTracer(tracer); Tracer = tracer; }
protected override async Task <bool> OnApply(IGameState gameState) { var playerWantsToDoBoth = false; if (CanDoBoth(gameState)) { playerWantsToDoBoth = await MetroDialog.ShowMessage("Play visitor", $"Do you want to perform both actions (cost: {DoBothCost}", MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative; } var twoChoicesViewModel = MefContainer.GetExportedValue <ITwoChoicesViewModel>(); twoChoicesViewModel.Option1 = Option1; twoChoicesViewModel.Option2 = Option2; twoChoicesViewModel.CanSelectOption1 = CanApplyOption1(gameState); twoChoicesViewModel.CanSelectOption2 = CanApplyOption2(gameState); var result = await MetroDialog.ShowDialog(twoChoicesViewModel); if (result == Selection.None) { return(false); } if (playerWantsToDoBoth) { if (result == Selection.Option1) { await ApplyOption1(gameState); if (CanApplyOption2(gameState)) { await ApplyOption2(gameState); } } else { await ApplyOption2(gameState); if (CanApplyOption1(gameState)) { await ApplyOption1(gameState); } } ApplyCostforDoingBoth(gameState); return(true); } return(result == Selection.Option1 ? await ApplyOption1(gameState) : await ApplyOption2(gameState)); }
public IMefContainer GetContainer() { var multiCatalog = new AggregateCatalog(); var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly()); multiCatalog.Catalogs.Add(catalog); var container = new MefContainer(multiCatalog); container.Compose(); return(container); }
public static void CreateMef() { var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var catalog = new AggregateCatalog(new AssemblyCatalog(Assembly.GetExecutingAssembly())); catalog.Catalogs.Add(new DirectoryCatalog(directory, "WpfMvvmExample.exe")); var container = new CompositionContainer(catalog); container.ComposeParts(); MefContainer.SetContainer(container); }
public static void Initialize() { var catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly())); //catalog.Catalogs.Add(new AssemblyCatalog(typeof(UserManagementBusinessLayer).Assembly)); catalog.Catalogs.Add(new AssemblyCatalog(typeof(UserManagementBusinessLayerSecond).Assembly)); //catalog.Catalogs.Add(new AssemblyCatalog( // typeof(TestModel.DataAccess.Implementation.MongoDb.UserDataAccess).Assembly)); // catalog.Catalogs.Add(new AssemblyCatalog( typeof(TestModel.DataAccess.Implementation.SqlDatabase.UserDataAccess).Assembly)); MefContainer.LoadMefContainer(catalog); //MefContainer.Container.ComposeParts(this); // MefContainer.Container.SatisfyImportsOnce(this); }
public ApplicationContext GetAppContext() { _container.Configure(c => c.AddRegistry <DefaultRegistry>()); Debug.WriteLine(_container.WhatDidIScan()); _container.Inject <ApplicationContext>(new AppContext(_container)); _container.GetInstance <ITranslationService>().Reload(); var locator = new StructureMapServiceLocator(_container); ServiceLocator.SetLocatorProvider(() => locator); _exportProvider = new CSLExportProvider(locator); var appController = _container.GetInstance <IApplicationController>(); _exportProvider.RegisterType(appController.GetType()); //var bindings = _container.GetAllInstances<IApplicationController>().ToList(); //bindings.ForEach(m => _exportProvider.RegisterType(m.GetType())); MefContainer.AddExportProvider(_exportProvider); return(_container.GetInstance <ApplicationContext>()); }
public CharacterViewModelFacade() { _characterViewModel = (CharacterViewModel)MefContainer.Resolve <ICharacterViewModel>(); }
public string GetAllProduct() { var uss = MefContainer.GetImplementationObject <IUserManagementBusinessLayer>(); throw new NotImplementedException(); }