コード例 #1
0
ファイル: AppPatternAdded.cs プロジェクト: jrlost/squidex
        public IEvent Migrate(AppDomainObject.State state)
        {
            var newSettings = new AppSettings
            {
                Patterns = ReadonlyList.ToReadonlyList(new List <Pattern>(state.Settings.Patterns.Where(x => x.Name != Name || x.Regex != Pattern))
                {
                    new Pattern(Name, Pattern)
                    {
                        Message = Message
                    }
                }),
                Editors = state.Settings.Editors
            };

            var newEvent = new AppSettingsUpdated
            {
                Settings = newSettings
            };

            return(SimpleMapper.Map(this, newEvent));
        }
コード例 #2
0
        public static void AddSquidexApps(this IServiceCollection services, IConfiguration config)
        {
            if (config.GetValue <bool>("apps:deletePermanent"))
            {
                services.AddSingletonAs <AppPermanentDeleter>()
                .As <IEventConsumer>();
            }

            services.AddTransientAs <AppDomainObject>()
            .AsSelf();

            services.AddSingletonAs <RolePermissionsProvider>()
            .AsSelf();

            services.AddSingletonAs <AppEventDeleter>()
            .As <IDeleter>();

            services.AddSingletonAs <AppUsageDeleter>()
            .As <IDeleter>();

            services.AddSingletonAs <DefaultAppLogStore>()
            .As <IAppLogStore>().As <IDeleter>();

            services.AddSingletonAs <AppHistoryEventsCreator>()
            .As <IHistoryEventsCreator>();

            services.AddSingletonAs <DefaultAppImageStore>()
            .As <IAppImageStore>();

            services.AddSingletonAs <AppProvider>()
            .As <IAppProvider>();

            services.AddSingletonAs <AppUISettings>()
            .As <IAppUISettings>().As <IDeleter>();

            services.AddSingletonAs <AppSettingsSearchSource>()
            .As <ISearchSource>();

            services.AddSingleton(c =>
            {
                var uiOptions = c.GetRequiredService <IOptions <MyUIOptions> >().Value;

                var patterns = new List <Pattern>();

                if (uiOptions.RegexSuggestions != null)
                {
                    foreach (var(key, value) in uiOptions.RegexSuggestions)
                    {
                        if (!string.IsNullOrWhiteSpace(key) &&
                            !string.IsNullOrWhiteSpace(value))
                        {
                            patterns.Add(new Pattern(key, value));
                        }
                    }
                }

                return(new InitialSettings
                {
                    Settings = new AppSettings
                    {
                        Patterns = ReadonlyList.ToReadonlyList(patterns)
                    }
                });
            });
        }