static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ApplicationController controller = new ApplicationController(new StandardKernel(new CustomNinjectModule())); controller.Run<MainPresenter>(); }
public void Should_run_and_send_email() { var sut = new ApplicationController(); var success = sut.Run(); Assert.IsTrue(success); }
/// <summary> /// Applies the confirm parameters attributes /// </summary> /// <param name="controller">controller to apply the attribute against</param> /// <param name="actionImplementation">action to apply the attribute against</param> /// <param name="message">outbound message</param> /// <returns>whether or not the attribute was successfully applied</returns> public override bool Apply(ApplicationController controller, MethodInfo actionImplementation, out string message) { message = null; bool parametersAccountedFor = false; bool parameterFound = false; List<string> missingParameters = new List<string>(); // iterate over the parameters foreach (string requiredParameter in this.ParametersNames) { parameterFound = false; foreach (string parameter in controller.Parameters) { if (parameter.ToUpper().Equals(requiredParameter.ToUpper())) { parameterFound = true; break; } } if (!parameterFound) { missingParameters.Add(requiredParameter); } } // determine the outcome based on what was found if (missingParameters.Count == 0 ) { parametersAccountedFor = true; } else { message = String.Format("The following required parameters were missing from the request: {0}", String.Join(",", missingParameters.ToArray())); } return parametersAccountedFor; }
static void Main(string[] args) { using (ApplicationController controller = new ApplicationController()) { new ConsoleView(controller).Interact(); } }
protected override void OnSetup() { _event = CreateEvent<ExitApplicationEvent, VetoArgs>(); _presenter = _factory.Create<IShellPresenter>(); _controller = new ApplicationController(_presenter.Object, _aggregator.Object); }
public void calling_AreArgumentsValid_when_the_arguments_specified_are_null_it_should_throw_an_ArgumentException() { var cont = new ApplicationController(null); cont.Invoking(x => x.AreArgumentsValid()) .ShouldThrow<ArgumentNullException>() .WithMessage("The arguments specified must not be null", FluentAssertions.Assertions.ComparisonMode.Substring); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var controller = new ApplicationController(new LightInjectAdapder()) .RegisterView<IProductView, ProductForm>() .RegisterService<IProductService, ProductService>() .RegisterInstance(new ApplicationContext()); controller.Run<ProductPresenter>(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Form1()); var controller = new ApplicationController(new LightInjectAdapter()) .RegisterView<IMainView, MainForm>() .RegisterInstance(new ApplicationContext()); controller.Run<MainPresenter>(); }
public void calling_ProcessTargetsBuildTargetsTemplate_should_save_the_template_on_disk() { var cont = new ApplicationController(new[] { "-p", "My App", "-o", "." }); var config = cont.ProcessTargetsBuildTargetsTemplate(); config.Should().NotBeNull(); File.Exists(config.Persistence.OutputTemplatePath).Should().BeTrue(); config.Persistence.OutputTemplatePath.Should().Be(@".\Targets\Build\My App.BuildTargets.import"); //testing that the template tokens were substituted correctly var templateRes = this.GetContentFromPersistedTemplate(config); }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var controller = new ApplicationController(new LightInjectAdapder()) .RegisterView<ILoginView, LoginForm>() .RegisterView<IMainView, MainForm>() .RegisterView<IChangeUsernameView, ChangeUsernameForm>() .RegisterService<ILoginService, StupidLoginService>() .RegisterInstance(new ApplicationContext()); controller.Run<LoginPresenter>(); }
public void SetUp() { optionsController = MockRepository.GenerateStub<IOptionsController>(); fileSystem = MockRepository.GenerateStub<IFileSystem>(); taskManager = MockRepository.GenerateStub<ITaskManager>(); testController = MockRepository.GenerateStub<ITestController>(); projectController = MockRepository.GenerateStub<IProjectController>(); unhandledExceptionPolicy = MockRepository.GenerateStub<IUnhandledExceptionPolicy>(); eventAggregator = MockRepository.GenerateStub<IEventAggregator>(); commandFactory = MockRepository.GenerateStub<ICommandFactory>(); applicationController = new ApplicationController(optionsController,fileSystem,taskManager,testController, projectController,unhandledExceptionPolicy,eventAggregator,commandFactory); command = MockRepository.GenerateStub<ICommand>(); }
public void calling_ProcessSolutionTemplate_should_save_the_Solution_template() { var cont = new ApplicationController(new[] { "-p", "My App", "-o", "." }); var config = cont.ProcessSolutionTemplate(); config.Should().NotBeNull(); File.Exists(config.Persistence.OutputTemplatePath).Should().BeTrue(); config.Persistence.OutputTemplatePath.Should().Be(@".\My App.BuildSolution.proj"); //testing that the template tokens were substituted correctly var templateRes = this.GetContentFromPersistedTemplate(config); templateRes.CountOcurrences(config.Context.CurrentOptions.ProductName).Should().Be(8); }
private static void Main() { IExceptionHandler exceptionHandler = new ExceptionHandler(); Application.ThreadException += exceptionHandler.Handle; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var controller = new ApplicationController(new LightInjectAdapter()) .RegisterView<ILoginForm, LoginForm>() .RegisterService<ILoginService, LoginService>() .RegisterView<IMessengerForm, MessengerForm>() .RegisterService<IMessengerService, MessengerService>() .RegisterInstance(new ApplicationContext()); controller.Run<LoginPresenter>(); }
public void calling_ProcessPropertiesInitPropertiesTemplate_should_save_the_template() { var cont = new ApplicationController(new[] { "-p", "My App", "-o", ".", "-s", this.GetType().Assembly.Location }); var config = cont.ProcessPropertiesInitPropertiesTemplate(); config.Should().NotBeNull(); File.Exists(config.Persistence.OutputTemplatePath).Should().BeTrue(); config.Persistence.OutputTemplatePath.Should().Be(@".\Properties\My App.InitProperties.import"); //testing that the template tokens were substituted correctly var templateRes = this.GetContentFromPersistedTemplate(config); templateRes.CountOcurrences(config.Context.CurrentOptions.ProductName).Should().Be(2); templateRes.CountOcurrences(config.Context.CurrentOptions.SolutionName).Should().Be(1); templateRes.Should().NotContain("{{ SolutionName }}"); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var controller = new ApplicationController(new StructureMapAdapter()) .RegisterService<IFileSystem, FileSystem>() .RegisterService<IDriveService, DriveService>() .RegisterService<IFolderService, FolderService>() .RegisterService<ITraverseService, TraverseService>() .RegisterService<IFileHelper, FileHelper>() .RegisterService<IFileService, FileService>() .RegisterService<IEqualityComparer<AppFile>, FileNameSizeComparer>() .RegisterService<IBackgroundWorkerFactory, BackgroundWorkerFactory>() .RegisterService<ICopyWorker, CopyWorker>() .RegisterService<IRandomizerWorker, RandomizerWorker>() .RegisterService<ISettingsService, SettingsService>() .RegisterService<IContext, SynchronizationContextAdapter>() .RegisterService<IProcessWrapper, ProcessWrapper>() .RegisterInstance<IFileExtension>(new DefaultMusicExtensions()) .RegisterInstance<IUniqueCharsGenerator>(new GuidCharactersGenerator(7)) .RegisterInstance(new ApplicationContext()) .RegisterSingletonView<IMainFormView, MainForm>() .RegisterSingletonView<IStep1View, Step1View>() .RegisterSingletonView<IStep2View, Step2View>() .RegisterSingletonView<IStep3View, Step3View>() .RegisterView<IRandomizationProcessView, RandomizationProcessView>() .RegisterView<ICopyProcessView, CopyProcessView>() .RegisterView<IFolderBrowserView, FolderBrowser>() .RegisterInstance(new GlobalWizardViewModel(" - FileRandomizer3000")) .RegisterInstance<SettingsBase>(Settings.Default) .RegisterService<IBackgroundWorker, BackgroundWorkerAsync>() .RegisterSingletonService<IMainFormViewHost, MainFormViewHost>() .RegisterSingletonService<Step1ViewModel, Step1ViewModel>() .RegisterSingletonService<Step2ViewModel, Step2ViewModel>() .RegisterSingletonService<Step3ViewModel, Step3ViewModel>() .RegisterSingletonService<RandomizationProcessViewModel, RandomizationProcessViewModel>() .RegisterSingletonService<CopyProcessViewModel, CopyProcessViewModel>(); controller.Run<MainFormPresenter>(); }
public ServiceRequestDialog(TService service, IDialogController dialogController, IRecordService lookupService, TRequest request = null, Action onClose = null) : base(dialogController) { if (onClose != null) { OnCancel = onClose; } Service = service; if (request != null) { Request = request; } else { Request = ApplicationController.ResolveType <TRequest>(); } ConfigEntryDialog = new ObjectEntryDialog(Request, this, ApplicationController, lookupService, null, null, onClose); SubDialogs = new DialogViewModel[] { ConfigEntryDialog }; }
protected void Application_Start(object sender, EventArgs e) { try { ApplicationController objAppController = new ApplicationController(); if (objAppController.IsInstalled()) { SageFrameConfig SageConfig = new SageFrameConfig(); RolesManagementController objController = new RolesManagementController(); RolesManagementInfo res = objController.GetRoleIDByRoleName(SystemSetting.AnonymousUsername); if (res != null) { SystemSetting.ANONYMOUS_ROLEID = res.RoleId.ToString(); } SageFrameSettingKeys.PageExtension = SageConfig.GetSettingsByKey(SageFrameSettingKeys.SettingPageExtension); RegisterRoutes(RouteTable.Routes); } } catch (Exception ex) { } }
public static void Run (ApplicationController controller, ApplicationUI ui) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(GeneralUnhandledExceptionHandler); HttpEncoder.Current = HttpEncoder.Default; Controller = controller; UI = ui; if (PriorProcess() != null) { throw new AbortedOperationException("Another instance of the app is already running."); } Controller.Initialize (); UI.Run (); #if !__MonoCS__ // Suppress assertion messages in debug mode GC.Collect (GC.MaxGeneration, GCCollectionMode.Forced); GC.WaitForPendingFinalizers (); #endif }
public async Task Then_ConfirmApplicationCommand_is_handled( long accountId, ConfirmApplicationRequest request, CreateAccountLegalEntityCommandResult mediatorResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] ApplicationController controller) { mockMediator .Setup(mediator => mediator.Send( It.Is <ConfirmApplicationCommand>(c => c.AccountId.Equals(accountId) && c.AccountId.Equals(request.AccountId) && c.ApplicationId.Equals(request.ApplicationId) && c.DateSubmitted.Equals(request.DateSubmitted)), It.IsAny <CancellationToken>())) .ReturnsAsync(Unit.Value); var controllerResult = await controller.ConfirmApplication(request) as StatusCodeResult; Assert.IsNotNull(controllerResult); controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK); }
protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType) { Controller controller = null; ApplicationController appController = null; if (controllerType == typeof(HomeController)) { appController = new HomeController(this.dbRepository); } else if (controllerType == typeof(AccountController)) { appController = new AccountController(this.dbRepository); } else { controller = base.GetControllerInstance(requestContext, controllerType) as Controller; } controller = appController; return(controller); }
static void Main() { Application.EnableVisualStyles(); Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.SetCompatibleTextRenderingDefault(false); ulong appid = ulong.Parse(ConfigurationManager.AppSettings["AppIdForTest"]); VKGroupHelperWorker vk = new VKGroupHelperWorker(appid); ServiceContainer container = new ServiceContainer(); container.RegisterInstance <VKGroupHelperWorker>(vk); container.RegisterInstance <Settings>(Globals.Settings); container.RegisterInstance <ApplicationContext>(Context); container.Register <IMainFormView, MainForm>(); container.Register <MainFormPresenter>(); ApplicationController controller = new ApplicationController(container); controller.Run <MainFormPresenter>(); }
public async Task ListApplicationsAsync_WithNoInputs_ReturnsList() { // Arrange var applicationService = Substitute.For <IApplicationService>(); var inList = new List <Application>(); inList.Add(new Application { Name = "Test Applications 1", Uuid = Guid.NewGuid() }); inList.Add(new Application { Name = "Test Applications 2", Uuid = Guid.NewGuid() }); inList.Add(new Application { Name = "Test Applications 3", Uuid = Guid.NewGuid() }); applicationService.GetListAsync().Returns(inList); var controller = new ApplicationController(applicationService); // Act IActionResult actionResult = await controller.ListApplicationsAsync(false, 0, 50, string.Empty, null); // Assert var okResult = actionResult as OkObjectResult; Assert.NotNull(okResult); var outList = okResult.Value as List <Application>; Assert.NotNull(outList); for (var i = 0; i < outList.Count; i++) { Assert.Equal(outList[i].Uuid, inList[i].Uuid); Assert.Equal(outList[i].Name, inList[i].Name); } }
public void CompleteDialog() { ApplicationController.DoOnAsyncThread( () => { LoadingViewModel.IsLoading = true; try { CompleteDialogExtention(); foreach (var action in _onCompletedEvents) { action(); } if (DialogCompletionCommit) { if (FatalException == null) { StartNextAction(); } } } catch (Exception ex) { //if we have an application which does not spawn async threads //and a fatal error has been thrown at completion processing //then allow that error to find its way up the stack if (DialogCompletionCommit) { throw; } else { ProcessError(ex); } } LoadingViewModel.IsLoading = false; } ); }
public void LogEvent(string eventName, IDictionary <string, string> properties = null) { var settings = ApplicationController.ResolveType <ApplicationInsightsSettings>(); if (!IsDebugMode && settings.AllowUseLogging) { properties = properties ?? new Dictionary <string, string>(); void addProperty(string name, string value) { if (!properties.ContainsKey(name)) { properties.Add(name, value); } } addProperty("App", ApplicationController.ApplicationName); addProperty("App Version", ApplicationController.Version); TelemetryClient.Context.User.Id = settings.AllowCaptureUsername ? UserName : AnonymousString; TelemetryClient.TrackEvent(eventName, properties); } }
public override void Run(Session argument) { Argument = argument; Argument.Stopped += ArgumentStopped; Argument.ClientConnected += ArgumentClientConnected; Argument.ClientDisconnected += ArgumentClientDisconnected; Argument.ConnectionDataUpdated += ArgumentConnectionDataUpdated; View.SessionClients = new List <SessionClient>(); View.SessionStatus = Argument.SessionStatus; View.GroupName = Argument.GroupName; View.Time = Argument.Exam.Time; SessionArgument sessionArgument = new SessionArgument(Argument, View); View.SessionInformationView = ApplicationController.Run <SessionInformationPresenter, Session>(Argument).View; View.ConnectionStatusView = ApplicationController.Run <ConnectionStatusPresenter, SessionArgument>(sessionArgument).View; View.ChatView = ApplicationController.Run <ChatPresenter, SessionArgument>(sessionArgument).View; View.Show(); }
internal override void RefreshEditabilityExtention() { if (FieldViewModels != null) { foreach (var field in FieldViewModels) { var methods = FormService.GetOnLoadTriggers(field.FieldName, GetRecordType()); foreach (var method in methods) { try { method(this); } catch (Exception ex) { ApplicationController.ThrowException(ex); } } } } base.RefreshEditabilityExtention(); }
public async Task ApplicationControllerGetActionThrowsAndLogsRedirectExceptionWhenExceptionOccurs() { var requestModel = new ActionGetRequestModel { Path = ChildAppPath, Data = ChildAppData }; var fakeApplicationService = A.Fake <IApplicationService>(); A.CallTo(() => fakeApplicationService.GetMarkupAsync(A <ApplicationModel> .Ignored, A <PageViewModel> .Ignored, A <string> .Ignored)).Throws <RedirectException>(); A.CallTo(() => fakeApplicationService.GetApplicationAsync(childAppActionGetRequestModel)).Returns(defaultApplicationModel); using var applicationController = new ApplicationController(defaultMapper, defaultLogger, fakeApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService) { ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext(), }, }; await applicationController.Action(requestModel).ConfigureAwait(false); A.CallTo(() => defaultLogger.Log(LogLevel.Information, 0, A <IReadOnlyList <KeyValuePair <string, object> > > .Ignored, A <Exception> .Ignored, A <Func <object, Exception, string> > .Ignored)).MustHaveHappened(4, Times.Exactly); }
public void CreateApplication_Unsuccessfull() { // Arrange Application app = new Application { ApplicationName = "Test", Description = "Xunit test", BookId = 3, AppTypeName = "Applicaion server" }; int tenantId = 1; applicationServiceMoq.Setup(c => c.CreateApplication(app, tenantId)).Returns(false); // Act var controller = new ApplicationController(logger.Object, applicationServiceMoq.Object); var response = controller.CreateApplication(app, tenantId) as BadRequestObjectResult; // Assert Assert.IsType <BadRequestObjectResult>(response); Assert.Equal("Application Not created", response.Value); applicationServiceMoq.Verify(c => c.CreateApplication(app, tenantId), Times.Once); }
public DynamicGridViewModel(IApplicationController applicationController) : base(applicationController) { DisplayHeaders = true; LoadingViewModel = new LoadingViewModel(applicationController); //this one a bit of a hack as loading/display controlled in code behind so set the vm as always loading SortLoadingViewModel = new LoadingViewModel(applicationController) { LoadingMessage = "Please Wait While Reloading Sorted Items", IsLoading = true }; OnDoubleClick = () => { }; OnClick = () => { }; OnKeyDown = () => { }; PreviousPageButton = new XrmButtonViewModel("Prev", () => { if (PreviousPageButton.Enabled) { HasNavigated = true; --CurrentPage; } }, ApplicationController) { Enabled = false }; NextPageButton = new XrmButtonViewModel("Next", () => { if (NextPageButton.Enabled) { HasNavigated = true; ++CurrentPage; } }, ApplicationController) { Enabled = false }; MaxHeight = 600; LoadDialog = (d) => { ApplicationController.UserMessage(string.Format("Error The {0} Method Has Not Been Set In This Context", nameof(LoadDialog))); }; RemoveParentDialog = () => { ApplicationController.UserMessage(string.Format("Error The {0} Method Has Not Been Set In This Context", nameof(RemoveParentDialog))); }; }
private async void ViewWatchTask(IEditSavingView sender) { try { Exam exam = GetCheckedExam(); if (exam == null) { return; } int ticketNumber = sender.CurrentTicket.Instance.TicketNumber; Ticket ticket = GetTicket(exam, ticketNumber); await ApplicationController.Run <LoadingContextPresenter <object>, Task <object> >(Task.Run(() => { DocXService.GetInstance().ExamDocXWorker.OpenTask(exam, ticket, false); return(LoadingContextPresenter <object> .EmptyObject); })).GetTask(); } catch (Exception ex) { View.ShowError(ex.Message); } }
public async Task ApplicationControllerGetActionAddsModelStateErrorWhenPathIsNull() { var requestModel = new ActionGetRequestModel { Path = BadChildAppPath, Data = BadChildAppData }; var fakeApplicationService = A.Fake <IApplicationService>(); A.CallTo(() => fakeApplicationService.GetMarkupAsync(A <ApplicationModel> .Ignored, A <PageViewModel> .Ignored, A <string> .Ignored)).Throws <RedirectException>(); A.CallTo(() => fakeApplicationService.GetApplicationAsync(childAppActionGetRequestModel)).Returns(defaultApplicationModel); using var applicationController = new ApplicationController(defaultMapper, defaultLogger, fakeApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService) { ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext(), }, }; await applicationController.Action(requestModel).ConfigureAwait(false); A.CallTo(() => defaultLogger.Log <ApplicationController>(A <LogLevel> .Ignored, A <EventId> .Ignored, A <ApplicationController> .Ignored, A <Exception> .Ignored, A <Func <ApplicationController, Exception, string> > .Ignored)).MustHaveHappened(3, Times.Exactly); }
public async Task ApplicationControllerPostActionAddsModelStateErrorWhenPathIsNull() { var fakeApplicationService = A.Fake <IApplicationService>(); A.CallTo(() => fakeApplicationService.PostMarkupAsync(A <ApplicationModel> .Ignored, A <string> .Ignored, A <string> .Ignored, A <IEnumerable <KeyValuePair <string, string> > > .Ignored, A <PageViewModel> .Ignored)).Throws <RedirectException>(); A.CallTo(() => fakeApplicationService.GetApplicationAsync(BadChildAppPath)).Returns(null as ApplicationModel); var applicationController = new ApplicationController(defaultMapper, defaultLogger, fakeApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService) { ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { Request = { Method = "POST" }, }, }, }; await applicationController.Action(defaultPostRequestViewModel).ConfigureAwait(false); A.CallTo(() => defaultLogger.Log(LogLevel.Information, 0, A <IReadOnlyList <KeyValuePair <string, object> > > .Ignored, A <Exception> .Ignored, A <Func <object, Exception, string> > .Ignored)).MustHaveHappened(3, Times.Exactly); applicationController.Dispose(); }
/* * public void AsciiParserToTree(object swender, EventArgs args) * { * Guid treeID = ApplicationController.CeptrInterface.ParseSemtrex( * ApplicationController.CeptrInterface.RootSymbolsNode, * ApplicationController.CeptrInterface.RootStructuresNode, * View.tbMatchExpression.Text); * * string dump = ApplicationController.CeptrInterface.Dump( * ApplicationController.CeptrInterface.RootSymbolsNode, * ApplicationController.CeptrInterface.RootStructuresNode, * treeID); * * View.tbSemtrexTree.Text = ApplicationController.FormatDump(dump); * } */ // Formatted output of the resulting tree. public void DumpOutput(Guid id) { string dump = ApplicationController.CeptrInterface.Dump( ApplicationController.CeptrInterface.RootSymbolsNode, ApplicationController.CeptrInterface.RootStructuresNode, id); string json = ApplicationController.CeptrInterface.CreateVisualTree( ApplicationController.CeptrInterface.RootSymbolsNode, ApplicationController.CeptrInterface.RootStructuresNode, id); json = json.Replace("SEMTREX_", ""); json = json.Replace("HTTP_REQUEST_", ""); View.tbSemtrexTree.Text = ApplicationController.FormatDump(dump); if (ApplicationController.VisualTreeController != null) { ApplicationController.VisualTreeController.ShowTree(json); } }
private void SageInitPart() { ApplicationController objAppController = new ApplicationController(); if (objAppController.IsInstalled()) { if (!objAppController.CheckRequestExtension(Request)) { SetPortalCofig(); InitializePage(); hypUpgrade.NavigateUrl = "~/Admin/sfUpgrader" + Extension; SageFrameConfig sfConfig = new SageFrameConfig(); IsUseFriendlyUrls = sfConfig.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls); LoadMessageControl(); BindModuleControls(); } } else { HttpContext.Current.Response.Redirect(ResolveUrl("~/Install/InstallWizard.aspx")); } }
protected void ProcessError(Exception ex) { //note also used in CompleteDialog determining not to continue to next action FatalException = ex; if (ParentDialog != null) { ParentDialog.ProcessError(ex); } else { CompletionMessage = string.Format("Fatal error:\n{0}", ex.DisplayString()); if (OverideCompletionScreenMethod != null) { ApplicationController.UserMessage(CompletionMessage); OverideCompletionScreenMethod(); } else { Controller.ShowCompletionScreen(this); } } }
protected override void CompleteDialogExtention() { ApplicationController.ResolveType <ISettingsManager>().SaveSettingsObject(SettingsObject); ApplicationController.RegisterInstance <TSettingsInterface>(SettingsObject); if (OverideCompletionScreenMethod == null && !HasParentDialog) { //okay in this case let set the dialog to //keep appending the settings entry to itself when completed OverideCompletionScreenMethod = () => { //append new dialog for the setting entry and //trigger this dialog to start it var configEntryDialog = new ObjectEntryDialog(SettingsObject, this, ApplicationController, LookupService, null, OnSave, null, saveButtonLabel: "Save", cancelButtonLabel: "Close", initialMessage: "Changes Have Been Saved"); SubDialogs = SubDialogs.Union(new[] { configEntryDialog }).ToArray(); DialogCompletionCommit = false; StartNextAction(); }; } }
public void ApplicationController_Post() { Application application = new Application() { ApplicationName = "Unit test App", CreatedDate = System.DateTime.Now, CreatedUser = "******", Expiration = System.DateTime.Now.AddDays(365), IMatrixNumber = "IS773739", IsActive = true, IsApproved = true, PhaseId = 1, POC = "Unit Test User Manager", StatusId = 1, SystemOwner = "Unit Test Product Owner", Icon = "Active", }; ApplicationController _controller = new ApplicationController(_mockService.Object, _logger.Object); var result = _controller.Post(application); Assert.IsNotNull(result); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var form = new GraphControlTestForm(); // Register dependencies var controller = new ApplicationController(new DependInjectWrapper()); controller.RegisterInstance <IApplicationController>(controller) .RegisterInstance <IDataProviderService>(new SinusDataProviderService()) .RegisterInstance <IGraphControlTestFormView>(form) .RegisterInstance(new ApplicationContext()); // Parse parameters if (args.Length > 0) { foreach (var arg in args) { var param = arg.Split('='); if (param.Length == 2) { if (param[0].Equals("testPoints", StringComparison.InvariantCultureIgnoreCase)) { if (UInt32.TryParse(param[1], out uint testPoints)) { controller.GetInstance <IDataProviderService>().TestPoints = testPoints; } } } } } controller.Run <GraphControlTestFormPresenter>(); Application.Run(form); }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += FMSC.Utility.ErrorHandling.ErrorHandlers.UnhandledException; using (NamedMutex mutex = new NamedMutex(false, "Global\\" + "FScruiser")) { if (mutex.WaitOne(0, false)) { //not already running DialogService.Instance = new WinFormsDialogService(); using (SoundService.Instance = new WinFormsSoundService()) using (ViewController viewController = new ViewController()) using (ApplicationController appController = new ApplicationController(viewController)) { if (args.Length > 1) { appController.OpenFile(args[1]); } viewController.Run(); } Debug.Close(); } else { //is already running string message = "FScruiser is already running\r\n"; if (ViewController.PlatformType == FMSC.Controls.PlatformType.WM) { message += "To halt or activate background programs, go to Settings->System->Memory"; } MessageBox.Show(message); return; } } }
void SaveData(IDataEntryDataService dataService, ISampleSelectorRepository sampleSelectorRepository) { try { sampleSelectorRepository.SaveSamplerStates(); Exception ex; ex = dataService.SaveNonPlotData(); ex = dataService.SavePlotData() ?? ex; if (ex != null) { throw ex; } ApplicationController.OnLeavingCurrentUnit(); } catch (FMSC.ORM.ReadOnlyException) { MessageBox.Show("File Is Read Only \r\n" + dataService.DataStore.Path); } catch (FMSC.ORM.ConstraintException ex) { MessageBox.Show("Data Constraint Failed\r\n" + ex.Message, "Error"); if (DialogService.AskYesNo("Would you like to go back to data entry?", string.Empty)) { ShowDataEntry(dataService, sampleSelectorRepository); } } catch (Exception ex) { ReportException(ex); if (DialogService.AskYesNo("Would you like to go back to data entry?", string.Empty)) { ShowDataEntry(dataService, sampleSelectorRepository); } } }
/// <summary> /// Loads the specified PrinterProfile, performing recovery options if required /// </summary> /// <param name="profileID">The profile ID to load</param> /// <param name="useActiveInstance">Return the in memory instance if already loaded. Alternatively, reload from disk</param> /// <returns></returns> public static async Task <PrinterSettings> LoadProfileAsync(string profileID, bool useActiveInstance = true) { if (useActiveInstance && ActiveSliceSettings.Instance?.ID == profileID) { return(ActiveSliceSettings.Instance); } // Only load profiles by ID that are defined in the profiles document var printerInfo = ProfileManager.Instance[profileID]; if (printerInfo == null) { return(null); } // Attempt to load from disk, pull from the web or fall back using recovery logic PrinterSettings printerSettings = LoadWithoutRecovery(profileID); if (printerSettings != null) { return(printerSettings); } else if (ApplicationController.GetPrinterProfileAsync != null) { // Attempt to load from MCWS if missing on disk printerSettings = await ApplicationController.GetPrinterProfileAsync(printerInfo, null); if (printerSettings != null) { // If successful, persist downloaded profile and return printerSettings.Save(); return(printerSettings); } } // Otherwise attempt to recover to a working profile return(await PrinterSettings.RecoverProfile(printerInfo)); }
protected override void CompleteDialogExtention() { if (SaveSettings) { var isMovingFolder = VisualStudioService.GetSolutionFolder(VisualStudioService.ItemFolderName) == null && VisualStudioService.GetItemText("solution.xrmconnection", "SolutionItems") != null; base.CompleteDialogExtention(); //set the active connection to the connection selected as active if (SettingsObject.Connections != null) { var activeConnections = SettingsObject.Connections.Where(c => c.Active); if (activeConnections.Any()) { var activeConnection = activeConnections.First(); var settingsManager = ApplicationController.ResolveType(typeof(ISettingsManager)) as ISettingsManager; if (settingsManager == null) { throw new NullReferenceException("settingsManager"); } settingsManager.SaveSettingsObject(activeConnection); XrmConnectionModule.RefreshXrmServices(activeConnection, ApplicationController, xrmRecordService: (RefreshActiveServiceConnection ? XrmRecordService : null)); LookupService = (XrmRecordService)ApplicationController.ResolveType(typeof(XrmRecordService)); } } if (isMovingFolder) { var openIt = ApplicationController.UserConfirmation("This Visual Studio extention is changing the way saved settings are stored. Click yes to open a window outlining the changes, and detailing code changes required if you use instances of the Xrm Solution Template"); if (openIt) { var blah = new SettingsFolderMoving(); var displaySomething = new ObjectDisplayViewModel(blah, FormController.CreateForObject(blah, ApplicationController, null)); ApplicationController.NavigateTo(displaySomething); } } } CompletionMessage = "Settings Updated"; }
protected override void CompleteDialogExtention() { ObjectToEnter.HideActive = false; //uh huh - okay now ObjectToEnter.Active = true; //lets set the connection in the service our parent dialog is using if (XrmRecordService != null) { XrmRecordService.XrmRecordConfiguration = ObjectToEnter; } //lets also refresh it in the applications containers SavedXrmConnectionsModule.RefreshXrmServices(ObjectToEnter, ApplicationController, xrmRecordService: XrmRecordService); //lets also refresh it in the saved settings var appSettingsManager = ApplicationController.ResolveType(typeof(ISettingsManager)) as ISettingsManager; var savedConnectionsObject = ApplicationController.ResolveType <ISavedXrmConnections>(); if (savedConnectionsObject.Connections != null) { foreach (var item in savedConnectionsObject.Connections) { item.Active = false; } } savedConnectionsObject.Connections = savedConnectionsObject.Connections == null ? new [] { ObjectToEnter } : savedConnectionsObject.Connections.Union(new [] { ObjectToEnter }).ToArray(); appSettingsManager.SaveSettingsObject(savedConnectionsObject); var recordconfig = new ObjectMapping.ClassMapperFor <SavedXrmRecordConfiguration, XrmRecordConfiguration>().Map(ObjectToEnter); appSettingsManager.SaveSettingsObject(recordconfig); if (!HasParentDialog) { CompletionItem = new CompletedMessage(); } }
public ImageBuffer GetIcon(string oemName) { string cachePath = ApplicationController.CacheablePath("OemIcons", oemName + ".png"); try { if (File.Exists(cachePath)) { return(AggContext.ImageIO.LoadImage(cachePath)); } else { var imageBuffer = new ImageBuffer(16, 16); ApplicationController.Instance.LoadRemoteImage( imageBuffer, ApplicationController.Instance.GetFavIconUrl(oemName), scaleToImageX: false).ContinueWith(t => { try { AggContext.ImageIO.SaveImageData(cachePath, imageBuffer); } catch (Exception ex) { Console.Write(ex.Message); } }); return(imageBuffer); } } catch { } return(new ImageBuffer(16, 16)); }
public override Task Rebuild() { this.DebugDepth("Rebuild"); using (RebuildLock()) { double pointsToMm = 0.352778; var printer = new TypeFacePrinter(Text, new StyledTypeFace(ApplicationController.GetTypeFace(Font), PointSize)) { ResolutionScale = 10 }; var scaledLetterPrinter = new VertexSourceApplyTransform(printer, Affine.NewScaling(pointsToMm)); var vertexSource = new VertexStorage(); foreach (var vertex in scaledLetterPrinter.Vertices()) { if (vertex.IsMoveTo) { vertexSource.MoveTo(vertex.position); } else if (vertex.IsLineTo) { vertexSource.LineTo(vertex.position); } else if (vertex.IsClose) { vertexSource.ClosePolygon(); } } this.VertexSource = vertexSource; base.Mesh = null; } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path)); return(Task.CompletedTask); }
private async static Task <PrinterSettings> LoadHttpOemProfile(string make, string model) { string deviceToken = OemSettings.Instance.OemProfiles[make][model]; string cacheKey = deviceToken + ProfileManager.ProfileExtension; string cachePath = Path.Combine(ApplicationDataStorage.ApplicationUserDataPath, "data", "temp", "cache", "profiles", cacheKey); return(await ApplicationController.LoadCacheableAsync <PrinterSettings>( cacheKey, "profiles", async() => { if (File.Exists(cachePath)) { return null; } else { // If the cache file for the current deviceToken does not exist, attempt to download it return await ApplicationController.DownloadPublicProfileAsync(deviceToken); } }, Path.Combine("Profiles", make, model + ProfileManager.ProfileExtension))); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppDomain.CurrentDomain.SetData("DataDirectory", Path.GetDirectoryName(Application.ExecutablePath)); var controller = new ApplicationController(new AutofacInjectAdapter()) .RegisterView<ILoginView, LoginForm>() .RegisterView<IMainTeacherView, MainTeacherForm>() .RegisterView<IAddEditQuestionView, AddEditQuestionForm>() .RegisterView<ILoginStudentView, LoginStudentForm>() .RegisterView<ITestView, TestForm>() .RegisterService<LoginPresenter>() .RegisterService<MainTeacherPresenter>() .RegisterService<AddEditQuestionPresenter>() .RegisterService<TestPresenter>() .RegisterService<StudentFormPresenter>() .RegisterInstance(new ApplicationContext()) .DoneBuilding(); controller.Run<LoginPresenter, bool>(true); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // TODO Switch to another container that provides signed assemblies IIocContainer container = new LightInjectContainer(); // UI classes IApplicationController controller = new ApplicationController(container) .RegisterView<IMainView, MainForm>() .RegisterView<IThumbnailView, ThumbnailView>() .RegisterView<IThumbnailDescriptionView, ThumbnailDescriptionView>() .RegisterInstance(new ApplicationContext()); // Application services controller.RegisterService<IThumbnailManager, ThumbnailManager>() .RegisterService<IThumbnailViewFactory, ThumbnailViewFactory>() .RegisterService<IThumbnailDescriptionViewFactory, ThumbnailDescriptionViewFactory>() .RegisterService<IConfigurationStorage, ConfigurationStorage>() .RegisterInstance<IApplicationConfiguration>(new ApplicationConfiguration()); controller.Run<MainPresenter>(); }
/// <summary> /// Starting point of the applciation /// </summary> /// <param name="args">The argsuments</param> internal static void Main(string[] args) { ApplicationController<Options> controller = null; try { controller = new ApplicationController<Options>(args, new Options()); controller.ParseArguments(); controller.Execute(); Environment.Exit(0); } catch (ParsingArgumentsException) { Console.Out.WriteLine(controller.GetHelp()); Environment.Exit(5); } catch (Exception exc) { Console.Error.WriteLine("The following error ocurred: " + exc.Message); Environment.Exit(9); } }
static void Main() { using (Mutex mutex = new Mutex(false, "Global\\" + appGuid)) { if (!mutex.WaitOne(0, false)) { MessageBox.Show("Приложение уже запущено!"); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var controller = new ApplicationController(new LightInjectAdapder()) .RegisterService<ILoginService, UserLoginService>() .RegisterService<IConnectionSettings, ConnectionSettings>() .RegisterView<IToDoListView, ToDoListView>() .RegisterView<IEventEditorView, EventsEditor>() .RegisterView<ICalendarsEditorView, Calendars>() .RegisterView<IProposalsEditorView, ProposalsView>() .RegisterView<IEditProposalItemView, EditProposalItemView>() .RegisterView<ICurrentEventsView, CurrentEvents>() .RegisterView<ITrainersInfoView, TrainersInfo>() .RegisterView<IDressingView, Dressings>() .RegisterView<IPlansView, Plans>() .RegisterView<IReportsView, Reports>() .RegisterView<IMainView, MainView>() .RegisterView<ILoginView, LoginView>() .RegisterView<IExportView, Shedules>() .RegisterView<ITestView, TestView>() .RegisterInstance(new ApplicationContext()); controller.Run<LoginPresenter>(); } }
/// <summary> /// Checks to see if the requeste action is available. /// </summary> /// <param name="args">the event arguments</param> /// <param name="controllerToInvoke">controller to invoke</param> /// <param name="actionToInvoke">action to invoke</param> /// <param name="message">outbound message</param> /// <returns></returns> private static bool IsActionAvailable(nServer.HttpRequestEventArgs args, out ApplicationController controllerToInvoke, out MethodInfo actionToInvoke, out string message) { bool isActionAvailable = false; Uri requestedAction = args.RequestContext.Request.Url; message = null; controllerToInvoke = null; actionToInvoke = null; string[] requestParts = requestedAction.LocalPath.Split('/'); if (requestParts.Length == 3) { controllerToInvoke = Controllers.ControllerManager.GetControllerInstance(requestParts[1] + "controller"); if (controllerToInvoke != null) { controllerToInvoke.Parameters = args.RequestContext.Request.QueryString; actionToInvoke = Controllers.ControllerManager.GetControllerAction(controllerToInvoke, requestParts[2]); } } if (controllerToInvoke != null && actionToInvoke != null) { isActionAvailable = true; } else { if (controllerToInvoke == null) { message = "Controller does not exist."; } else if (actionToInvoke == null) { message = "Action does not exist."; } } return isActionAvailable; }
public void can_create_new_ApplicationController() { var cont = new ApplicationController(null); cont.Should().NotBeNull(); }
public void calling_ProcessTemplate_with_invalid_argument_line_options_it_should_throw_an_ArgumentException() { var cont = new ApplicationController(new[] { "-p", "My App", "-o" }); cont.Invoking(x => x.ProcessTemplate("my res", "my namespace", (w, y, z) => { })) .ShouldThrow<ArgumentException>() .WithMessage("The command line arguments must be valid before calling the ProcessTemplate method", FluentAssertions.Assertions.ComparisonMode.Substring); }
public void when_calling_AreArgumentsValid_with_valid_arguments_it_should_return_true() { var args = new[] { "-p", "my app", "-o", "." }; var cont = new ApplicationController(args); cont.AreArgumentsValid().Should().BeTrue(); }
public void when_calling_AreArgumentsValid_with_invalid_arguments_it_should_return_false() { var args = new[] { "-p" }; var cont = new ApplicationController(args); cont.AreArgumentsValid().Should().BeFalse(); }
public void when_calling_GetCommandHelp_it_should_return_the_help_specifying_how_to_use_the_application() { var cont = new ApplicationController(new[] { "-p" }); cont.GetCommandLineHelp().Should().NotBeNullOrEmpty().And.NotBeBlank(); }
// Use this for initialization void Start () { app = GameObject.Find("Application").GetComponent<ApplicationController>(); on = true; }
public virtual bool Apply(ApplicationController controller, MethodInfo actionImplementation, out string message) { message = null; return true; }
public MainWindow() { InitializeComponent(); Loaded += MainWindow_Loaded; InkInputHelper.DisableWPFTabletSupport(); _appController = new ApplicationController(baseDirectory); _captureController = _appController.CaptureController; if (Settings.Default.accessKey == "") { MessageBox.Show("Please setup keys in the credentials.json in the " + baseDirectory + " directory", "Missing Credentials", MessageBoxButton.OK); Environment.Exit(0); } KinectSensor.GetDefault().Open(); _cameraImagePresenter = new SmithersDS4.Visualization.CameraImagePresenter(camera, Settings.Default.useDSAPI); _cameraImagePresenter.CameraMode = SmithersDS4.Visualization.CameraMode.Depth; _cameraImagePresenter.Enabled = true; //camera.Source = _captureController.ColorBitmap.Bitmap; _captureController.SessionManager.ShotBeginning += (sender, e) => { if (_captureController.CaptureMode == SmithersDS4.Sessions.CaptureMode.Trigger) { _flashAttack.Begin(); _cameraImagePresenter.Enabled = false; } else { _cameraImagePresenter.Enabled = true; } }; _captureController.SessionManager.ShotCompletedSuccess += (sender, e) => { _cameraImagePresenter.Enabled = true; }; _captureController.SessionManager.ShotCompletedError += (sender, e) => { this.Dispatcher.InvokeAsync(() => { _flashDecay.Begin(); MessageBox.Show(e.ErrorMessage); _cameraImagePresenter.Enabled = true; }); }; _captureController.SessionManager.FrameCaptured += (sender, e) => { this.Dispatcher.InvokeAsync(() => { _flashDecay.Begin(); int numFramesInMemory = _captureController.SessionManager.NumFrameInMemory; lblCaptureCount.Content = "Captured Frames: " + numFramesInMemory; tbCapturedSweeps.Text = _captureController.Session.SweepCounter.ToString(); tbCapturedFrames.Text = numFramesInMemory.ToString(); var sensorProperty = _captureController.Session.Metadata.DeviceConfig; inputImageExposure.Text = sensorProperty.DepthExposure.ToString(); inputImageGain.Text = sensorProperty.DepthGain.ToString(); colorImageExposure.Text = sensorProperty.ColorExposure.ToString(); colorImageGain.Text = sensorProperty.ColorGain.ToString(); }); }; _captureController.SessionManager.ShotSavedSuccess += (sender, e) => { this.Dispatcher.InvokeAsync(() => { SetBtnCaptureContent("Start Recording"); btnCapture.IsEnabled = true; btnEndSessionAndUpload.IsEnabled = true; btnEndAndStartNewSession.IsEnabled = true; BtnRedoSweep.Visibility = Visibility.Visible; }); }; _captureController.SessionManager.ShotSavedError += (sender, e) => { this.Dispatcher.InvokeAsync(() => { _flashDecay.Begin(); if (e.Exception == null) MessageBox.Show(e.ErrorMessage); else MessageBox.Show(e.ErrorMessage + ": " + e.Exception.Message); }); }; _appController.UploadManager.UploadFinished += UploadManager_UploadFinished; //_captureController.SkeletonPresenter = new SkeletonPresenter(canvas); //_captureController.SkeletonPresenter.ShowBody = true; //_captureController.SkeletonPresenter.ShowHands = true; //// _captureController.FrameReader.AddResponder(_captureController.SkeletonPresenter); //_captureController.SkeletonPresenter.ProjectionMode = ProjectionMode.COLOR_IMAGE; //_captureController.SkeletonPresenter.CoordinateMapper = KinectSensor.GetDefault().CoordinateMapper; //_captureController.SkeletonPresenter.Underlay = camera; // _captureController.FrameReader.AddResponder(_cameraImagePresenter); _captureController.FrameReader.FrameArrived += _cameraImagePresenter.FrameArrived; _captureController.FrameRateReporter.FpsChanged += this.FpsChanged; _flashAttack = FindResource("FlashAttack") as Storyboard; _flashDecay = FindResource("FlashDecay") as Storyboard; buttonBg = (SolidColorBrush)(new BrushConverter().ConvertFrom("#3cdc3c")); }
public DataEntryPresenter(ApplicationController applicationController) { _applicationController = applicationController; }