示例#1
0
文件: App.xaml.cs 项目: younes21/abp
    protected async override void OnStartup(StartupEventArgs e)
    {
        Log.Logger = new LoggerConfiguration()
#if DEBUG
                     .MinimumLevel.Debug()
#else
                     .MinimumLevel.Information()
#endif
                     .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                     .Enrich.FromLogContext()
                     .WriteTo.Async(c => c.File("Logs/logs.txt"))
                     .CreateLogger();

        try
        {
            Log.Information("Starting WPF host.");

            _abpApplication = await AbpApplicationFactory.CreateAsync <MyProjectNameModule>(options =>
            {
                options.UseAutofac();
                options.Services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true));
            });

            await _abpApplication.InitializeAsync();

            _abpApplication.Services.GetRequiredService <MainWindow>()?.Show();
        }
        catch (Exception ex)
        {
            Log.Fatal(ex, "Host terminated unexpectedly!");
        }
    }
示例#2
0
 public AbpInitialize()
 {
     Application = AbpApplicationFactory.Create <SincaModule>(options =>
     {
         options.UseAutofac(); //Autofac integration
     });
     Application.Initialize();
 }
        public static async Task RunTests <T>(this IAbpApplicationWithInternalServiceProvider application, Func <T, Task> testStart)
        {
            var app = application.ServiceProvider.GetRequiredService <T>();

            System.Console.WriteLine($"{app.GetType().Name} Start...");
            await testStart(app);

            System.Console.WriteLine($"{app.GetType().Name} End");
        }
        public CadastroClienteViewModel(IAbpApplicationWithInternalServiceProvider application, ClienteDto clienteDto) : base()
        {
            _clienteAppService = application.ServiceProvider.GetRequiredService <IClienteAppService>();

            NovoOnClick    = new RelayCommand(param => NovoDto());
            GravarOnClick  = new RelayCommand(param => Gravar());
            ExcluirOnClick = new RelayCommand(param => Excluir());
            Dto            = clienteDto;
        }
示例#5
0
        public ConsultaClienteViewModel(IAbpApplicationWithInternalServiceProvider application) : base(application)
        {
            _clienteAppService = application.ServiceProvider.GetRequiredService <IClienteAppService>();

            PesquisarOnClick     = new RelayCommand(param => PesquisarClientePorNome());
            NovoClienteOnClick   = new RelayCommand(param => NovoCliente());
            EditarClienteOnClick = new RelayCommand(param => EditarCliente());

            NovoDto();
            Listar();
        }
示例#6
0
        public ConsultaClienteView()
        {
            InitializeComponent();

            _application = AbpApplicationFactory.Create <SincaModule>(options =>
            {
                options.UseAutofac(); //Autofac integration
            });
            _application.Initialize();

            DataContext = new ConsultaClienteViewModel(_application);
        }
示例#7
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            using (IAbpApplicationWithInternalServiceProvider application = AbpApplicationFactory.Create <SnookerConsoleApiClientModule>())
            {
                application.Initialize();

                ClientDemoService demo = application.ServiceProvider.GetRequiredService <ClientDemoService>();
                await demo.RunAsync();

                application.Shutdown();
            }
        }
示例#8
0
        private ContractTester(IAbpApplicationWithInternalServiceProvider application, ECKeyPair keyPair)
        {
            application.Services.AddTransient(o =>
            {
                var mockService = new Mock <IAccountService>();
                mockService.Setup(a => a.SignAsync(It.IsAny <byte[]>())).Returns <byte[]>(data =>
                                                                                          Task.FromResult(CryptoHelper.SignWithPrivateKey(keyPair.PrivateKey, data)));

                mockService.Setup(a => a.GetPublicKeyAsync()).ReturnsAsync(keyPair.PublicKey);

                return(mockService.Object);
            });

            Application = application;

            KeyPair = keyPair;
        }
示例#9
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            _abpApplication = await AbpApplicationFactory.CreateAsync <EasyStoreConsoleAppAppModule>(options =>
            {
                options.Services.ReplaceConfiguration(_configuration);
                options.Services.AddSingleton(_hostEnvironment);

                options.UseAutofac();
                options.Services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog());
            });

            await _abpApplication.InitializeAsync();

            var helloWorldService = _abpApplication.ServiceProvider.GetRequiredService <HelloWorldService>();

            await helloWorldService.SayHelloAsync();
        }
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            using (IAbpApplicationWithInternalServiceProvider application = AbpApplicationFactory.Create <SnookerDbMigratorModule>(options =>
            {
                options.UseAutofac();
                options.Services.AddLogging(c => c.AddSerilog());

                // Not added by ABP.io framework
                options.Services.ReplaceConfiguration(BuildConfiguration());
            }))
            {
                application.Initialize();

                await application
                .ServiceProvider
                .GetRequiredService <SnookerDbMigrationService>()
                .MigrateAsync();

                application.Shutdown();

                _hostApplicationLifetime.StopApplication();
            }
        }
示例#11
0
        private ContractTester(IAbpApplicationWithInternalServiceProvider application, ECKeyPair keyPair)
        {
            application.Services.AddTransient(o =>
            {
                var mockService = new Mock <IAccountService>();
                mockService.Setup(a => a.SignAsync(It.IsAny <byte[]>())).Returns <byte[]>(data =>
                                                                                          Task.FromResult(CryptoHelpers.SignWithPrivateKey(keyPair.PrivateKey, data)));

                mockService.Setup(a => a.VerifySignatureAsync(It.IsAny <byte[]>(), It.IsAny <byte[]>(), It.IsAny <byte[]>()
                                                              )).Returns <byte[], byte[], byte[]>((signature, data, publicKey) =>
                {
                    var recoverResult = CryptoHelpers.RecoverPublicKey(signature, data, out var recoverPublicKey);
                    return(Task.FromResult(recoverResult && publicKey.BytesEqual(recoverPublicKey)));
                });

                mockService.Setup(a => a.GetPublicKeyAsync()).ReturnsAsync(keyPair.PublicKey);

                return(mockService.Object);
            });

            Application = application;

            KeyPair = keyPair;
        }
示例#12
0
        private ContractTester(IAbpApplicationWithInternalServiceProvider application, int chainId)
        {
            application.Services.Configure <ChainOptions>(o => { o.ChainId = chainId; });

            Application = application;
        }
        public CadastroClienteView(IAbpApplicationWithInternalServiceProvider application, ClienteDto clienteDto)
        {
            InitializeComponent();

            DataContext = _viewModels = new CadastroClienteViewModel(application, clienteDto);
        }
示例#14
0
 public static T Resolve <T>(this IAbpApplicationWithInternalServiceProvider app)
 {
     return((T)app.ServiceProvider.GetRequiredService <T>());
 }
示例#15
0
 public BaseViewModel(IAbpApplicationWithInternalServiceProvider application) : this()
 {
     Application = application;
 }