コード例 #1
0
 /// <summary>
 ///     Adds default <see cref="WarningBehavior" /> for relational events.
 /// </summary>
 /// <param name="coreOptionsExtension">The core options extension.</param>
 /// <returns>The new core options extension.</returns>
 public static CoreOptionsExtension WithDefaultWarningConfiguration(CoreOptionsExtension coreOptionsExtension)
 => coreOptionsExtension.WithWarningsConfiguration(
     coreOptionsExtension.WarningsConfiguration
     .TryWithExplicit(RelationalEventId.AmbientTransactionWarning, WarningBehavior.Throw)
     .TryWithExplicit(RelationalEventId.IndexPropertiesBothMappedAndNotMappedToTable, WarningBehavior.Throw)
     .TryWithExplicit(RelationalEventId.IndexPropertiesMappedToNonOverlappingTables, WarningBehavior.Throw)
     .TryWithExplicit(RelationalEventId.ForeignKeyPropertiesMappedToUnrelatedTables, WarningBehavior.Throw));
コード例 #2
0
        /// <summary>
        /// 配置报警扩展
        /// </summary>
        /// <param name="optionsBuilder"></param>
        private static void ConfigureWarnings(DbContextOptionsBuilder optionsBuilder)
        {
            CoreOptionsExtension coreOptionsExtension = optionsBuilder.Options.FindExtension <CoreOptionsExtension>() ?? new CoreOptionsExtension();

            coreOptionsExtension = coreOptionsExtension.WithWarningsConfiguration(coreOptionsExtension.WarningsConfiguration.TryWithExplicit(RelationalEventId.AmbientTransactionWarning, WarningBehavior.Throw));
            ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(coreOptionsExtension);
        }
コード例 #3
0
            public TExtension FindExtension <TExtension>()
                where TExtension : class, IDbContextOptionsExtension
            {
                var coreOptionsExtension = new CoreOptionsExtension();

                if (_serviceProvider != null)
                {
                    coreOptionsExtension = coreOptionsExtension.WithApplicationServiceProvider(_serviceProvider);
                }

                return((TExtension)(object)coreOptionsExtension);
            }
コード例 #4
0
        protected override void OnConfiguringService(IServiceCollection services)
        {
            //services.AddSingleton<IStartupConfiguration>(sp => new StartupConfiguration(sp));

            services.AddSingleton <INavigationManager, NavigationManager>();

            CoreOptionsExtension coreOptionsExtension = GetOrCreateExtension <CoreOptionsExtension>();

            if (coreOptionsExtension.UserIndentifier != null)
            {
                var keyType = TypeUtils.FindGenericTypeArguments(coreOptionsExtension.UserIndentifier, typeof(IUserIdentifier <>));
                services.AddTransient(typeof(IUserNavigationManager <>).MakeGenericType(keyType), typeof(UserNavigationManager <>).MakeGenericType(keyType));
                services.AddSingleton(typeof(ISafSession <>).MakeGenericType(keyType), typeof(ClaimsSafSession <>).MakeGenericType(keyType));
            }
            services.TryAddSingleton <Infrastructure.INavigationConfiguration>(coreOptionsExtension.NavigationConfiguration);

            //添加后台队列
            services.AddBackgroundQueue();
        }
コード例 #5
0
 public ExtensionInfo(CoreOptionsExtension extension)
     : base(extension)
 {
 }