public OptionsForm() { _provider = OptionsProviderRegistry.CurrentOptionsProvider; _options = _provider.GetOptions(); InitializeComponent(); optionsUI.SetOptions(_options); }
/// <summary> /// 添加JPush客户端 /// </summary> public void AddJPushClient() { var options = _optionsProvider.GetOptions(_services); if (options == null) { throw new NoOptionsConfiguredException($"{nameof(JPushOptions)} didn't configured."); } if (!DataAnnotationsValidator.TryValidate(options, out ICollection <ValidationResult> results)) { var errMsg = results .Select(r => r.ErrorMessage) .Aggregate((current, next) => $"{current}, {next}"); throw new InvalidOptionsConfiguredException($"Invalid {nameof(JPushOptions)} configuration, details: {errMsg}"); } _services.AddTransient <JPushClient, JPushClient>(p => new JPushClient(options.AppKey, options.MasterSecret)); }