Beispiel #1
0
        public static void CreateOrConsolidate(this IClientConfiguration clientConfiguration, Action <IClientConfiguration> creator)
        {
            using (IScopedIocResolver scope = IocManager.Instance.CreateScope())
            {
                creator(clientConfiguration);

                scope.Resolve <IApplicationConfiguration>().ClientConfiguration = clientConfiguration;

                scope.Resolve <IAppConfigManager>().SaveOrUpdate("ClientId", clientConfiguration.Id);
            }
        }
Beispiel #2
0
        private void HandleExceptionsOrNothing()
        {
            using (IScopedIocResolver scope = _bootstrapper.IocManager.CreateScope())
            {
                bool isExtraLoggingEnabled = scope.Resolve <IApplicationConfiguration>().IsExtraLoggingEnabled;

                AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
                {
                    var googleClient = scope.Resolve <IGoogleAnalyticsService>();
                    var logger       = scope.Resolve <ILogger>();

                    if (isExtraLoggingEnabled)
                    {
                        logger.Error($"Unhandled Exception occured: {args.ExceptionObject.ToString()}");
                    }

                    try
                    {
                        googleClient.TrackException(args.ExceptionObject.ToString(), false);
                    }
                    catch (Exception)
                    {
                        //throw;
                    }
                };

                TaskScheduler.UnobservedTaskException += (sender, args) =>
                {
                    args.Exception.Handle(exception =>
                    {
                        var googleClient = scope.Resolve <IGoogleAnalyticsService>();
                        var logger       = scope.Resolve <ILogger>();

                        if (isExtraLoggingEnabled)
                        {
                            logger.Error($"Unhandled Exception occured: {exception.ToString()}");
                        }

                        try
                        {
                            googleClient.TrackException(exception.ToString(), false);
                        }
                        catch (Exception)
                        {
                            //throw;
                        }
                        return(true);
                    });
                };
            }
        }
        public async Task <bool> CheckVisible(IScopedIocResolver scope)
        {
            var abpSession = scope.Resolve <ISession>();

            if (!abpSession.UserId.HasValue)
            {
                return(false);
            }

            var permissionDependencyContext = scope.Resolve <PermissionDependencyContext>();

            permissionDependencyContext.User = abpSession.ToUserIdentifier();

            return(await _permissionDependency.IsSatisfiedAsync(permissionDependencyContext));
        }
Beispiel #4
0
        private void RegisterEntityCoreCache()
        {
            var dbContextTypes =
                _typeFinder.Find(type =>
            {
                var typeInfo = type.GetTypeInfo();
                return(typeInfo.IsPublic &&
                       !typeInfo.IsAbstract &&
                       typeInfo.IsClass &&
                       typeof(AbpDbContext).IsAssignableFrom(type));
            });

            if (dbContextTypes.IsNullOrEmpty())
            {
                Logger.Warn("No class found derived from AbpDbContext.");
                return;
            }

            using (IScopedIocResolver scope = IocManager.CreateScope())
            {
                foreach (var dbContextType in dbContextTypes)
                {
                    scope.Resolve <IEntityCoreCacheRegistrar>().RegisterForDbContext(dbContextType, IocManager);
                }
            }
        }
Beispiel #5
0
        private async Task CheckVersion()
        {
            using (IScopedIocResolver scope = IocManager.Instance.CreateScope())
            {
                Release release = await GetReleaseFromCache(scope.Resolve <GitHubClient>());

                string incomingVersion = release.TagName;

                if (scope.Resolve <IVersionChecker>().IsNew(incomingVersion))
                {
                    await this.DispatchingAsync(() =>
                    {
                        _newVersionButton.Visibility = Visibility.Visible;
                        _newVersionButton.Content    = $"A new version {incomingVersion} released, update now!";
                        _configurations.ApplicationConfiguration.UpdateLink = release.Assets.FirstOrDefault()?.BrowserDownloadUrl;
                    });
                }
            }
        }
Beispiel #6
0
        private void RegisterGenericRepositoriesAndMatchDbContexes()
        {
            var dbContextTypes =
                _typeFinder.Find(type =>
            {
                var typeInfo = type.GetTypeInfo();
                return(typeInfo.IsPublic &&
                       !typeInfo.IsAbstract &&
                       typeInfo.IsClass &&
                       typeof(AbpDbContext).IsAssignableFrom(type));
            });

            if (dbContextTypes.IsNullOrEmpty())
            {
                Logger.Warn("No class found derived from AbpDbContext.");
                return;
            }

            using (IScopedIocResolver scope = IocManager.CreateScope())
            {
                foreach (var dbContextType in dbContextTypes)
                {
                    Logger.Debug("Registering DbContext: " + dbContextType.AssemblyQualifiedName);

                    scope.Resolve <IEfGenericRepositoryRegistrar>().RegisterForDbContext(dbContextType, IocManager, EfCoreAutoRepositoryTypes.Default);

//                    IocManager.IocContainer.Register(
//                        Component.For<ISecondaryOrmRegistrar>()
//                            .Named(Guid.NewGuid().ToString("N"))
//                            .Instance(new EfCoreBasedSecondaryOrmRegistrar(dbContextType, scope.Resolve<IDbContextEntityFinder>()))
//                            .LifestyleTransient()
//                    );
                    IocManager.IocContainer.UseInstance <ISecondaryOrmRegistrar>(new EfCoreBasedSecondaryOrmRegistrar(dbContextType,
                                                                                                                      scope.Resolve <IDbContextEntityFinder>()));
                }

                scope.Resolve <IDbContextTypeMatcher>().Populate(dbContextTypes);
            }
        }
 public async Task <bool> CheckVisible(IScopedIocResolver scope)
 {
     return(await Task.FromResult(
                scope.Resolve <ISession>().UserId.HasValue
                ));
 }
Beispiel #8
0
 public MyDependency CreateDependency()
 {
     return(resolver.Resolve <MyDependency>());
 }
Beispiel #9
0
 public T GetService <T>()
 {
     return(_scopedIocResolver.Resolve <T>());
 }