protected override void AttachToComponentRegistration(IComponentRegistryBuilder componentRegistry, IComponentRegistration registration) { if (!DataSettings.DatabaseIsInstalled()) { return; } var userProperty = FindUserProperty(registration.Activator.LimitType); if (userProperty == null) { return; } registration.Metadata.Add("Property.T", FastProperty.Create(userProperty)); registration.PipelineBuilding += (sender, pipeline) => { // Add our Localizer middleware to the pipeline. pipeline.Use(PipelinePhase.ParameterSelection, (context, next) => { next(context); if (!context.Resolve <IEngine>().IsInitialized) { return; } if (!context.NewInstanceActivated || context.Registration.Metadata.Get("Property.T") is not FastProperty prop) { return; } try { var iText = context.Resolve <IText>(); if (prop.Property.PropertyType == typeof(Localizer)) { Localizer localizer = context.Resolve <IText>().Get; prop.SetValue(context.Instance, localizer); } else { LocalizerEx localizerEx = context.Resolve <IText>().GetEx; prop.SetValue(context.Instance, localizerEx); } } catch { } }); };
static NullLocalizer() { _instance = (format, args) => new LocalizedString((args == null || args.Length == 0) ? format : string.Format(format, args)); _instanceEx = (format, languageId, args) => new LocalizedString((args == null || args.Length == 0) ? format : string.Format(format, args)); }