StreetFoo.Client.StreetFooRuntime.Start C# (CSharp) Method

Start() public static method

public static Start ( string module ) : System.Threading.Tasks.Task
module string
return System.Threading.Tasks.Task
        public static async Task Start(string module)
        {
            Module = module;

            // setup the default IoC handlers for the view models...
            ViewModelFactory.Current.SetHandler(typeof(IRegisterPageViewModel), typeof(RegisterPageViewModel));
            ViewModelFactory.Current.SetHandler(typeof(ILogonPageViewModel), typeof(LogonPageViewModel));
            ViewModelFactory.Current.SetHandler(typeof(IReportsPageViewModel), typeof(ReportsPageViewModel));
            ViewModelFactory.Current.SetHandler(typeof(IShareTargetPageViewModel), typeof(ShareTargetPageViewModel));
            ViewModelFactory.Current.SetHandler(typeof(ISearchResultsPageViewModel), typeof(SearchResultsPageViewModel));
            ViewModelFactory.Current.SetHandler(typeof(IMySettingsPaneViewModel), typeof(MySettingsPaneViewModel));
            ViewModelFactory.Current.SetHandler(typeof(IHelpPaneViewModel), typeof(HelpPaneViewModel));
            ViewModelFactory.Current.SetHandler(typeof(IReportPageViewModel), typeof(ReportPageViewModel));

            // ...and then for the service proxies...
            ServiceProxyFactory.Current.SetHandler(typeof(IRegisterServiceProxy), typeof(RegisterServiceProxy));
            ServiceProxyFactory.Current.SetHandler(typeof(ILogonServiceProxy), typeof(LogonServiceProxy));
            ServiceProxyFactory.Current.SetHandler(typeof(IEnsureTestReportsServiceProxy), typeof(EnsureTestReportsServiceProxy));
            ServiceProxyFactory.Current.SetHandler(typeof(IGetReportsByUserServiceProxy), typeof(GetReportsByUserServiceProxy));
            ServiceProxyFactory.Current.SetHandler(typeof(IGetReportImageServiceProxy), typeof(GetReportImageServiceProxy));

            // initialize the system database... 
            var conn = GetSystemDatabase();
            await conn.CreateTableAsync<SettingItem>();
		}

Same methods

StreetFooRuntime::Start ( string module ) : void

Usage Example

コード例 #1
0
        // runs the operation...
        public async Task RunAsync(IBackgroundTaskInstance instance)
        {
            // configure the logging system to use a streaming target...
            try
            {
                LogManagerFactory.DefaultConfiguration.AddTarget(LogLevel.Trace, LogLevel.Fatal,
                                                                 new FileStreamingTarget());
            }
            catch
            {
                // no-op... waiting for a change in MetroLog to see if the config
                // has already been done...
            }

            // logging is a bit tricky as we have to gather all of the messages
            // and flush them out...
            var logTasks = new List <Task <LogWriteOperation[]> >();

            // do some logging...
            var asyncLogger = (ILoggerAsync)this.Logger;

            logTasks.Add(asyncLogger.InfoAsync("Started background task '{0}' (#{1})...",
                                               instance.Task.Name, instance.Task.TaskId));

            // run...
            try
            {
                // start the app...
                await StreetFooRuntime.Start("Tasks");

                // defer...
                await DoRunAsync(instance);
            }
            catch (Exception ex)
            {
                logTasks.Add(asyncLogger.FatalAsync(string.Format("Background task '{0}' (#{1}) failed.",
                                                                  instance.Task.Name, instance.Task.TaskId), ex));
            }

            // finish...
            logTasks.Add(asyncLogger.InfoAsync("Finished background task '{0}' (#{1}).",
                                               instance.Task.Name, instance.Task.TaskId));

            // wait...
            await Task.WhenAll(logTasks);
        }