public static void FromLegacy(
            this MembershipRebootConfiguration config, 
            INotificationService notificationService, 
            IPasswordPolicy passwordPolicy)
        {
            if (config == null) throw new ArgumentNullException("config");
            
            if (notificationService != null)
            {
                config.AddEventHandler(new NotificationServiceEventHandler(notificationService));
                if (config.SecuritySettings.RequireAccountVerification)
                {
                    config.AddEventHandler(new NotificationServiceAccountCreatedEventHandler(notificationService));
                }
            }

            if (passwordPolicy != null)
            {
                config.RegisterPasswordValidator(new DelegateValidator(
                    (svc, acct, password) =>
                    {
                        if (!passwordPolicy.ValidatePassword(password))
                        {
                            return new ValidationResult("Invalid password: " + passwordPolicy.PolicyMessage);
                        }
                        return null;
                    }));
            }
        }
        public static void ConfigureCookieBasedTwoFactorAuthPolicy(this MembershipRebootConfiguration config, CookieBasedTwoFactorAuthPolicy policy)
        {
            if (config == null) throw new ArgumentNullException("config");

            config.TwoFactorAuthenticationPolicy = policy;
            config.AddEventHandler(policy);
        }
Ejemplo n.º 3
0
    /// <summary>
    /// Returns an observable sequence of events from the specified <paramref name="event"/> descriptor.
    /// </summary>
    /// <param name="event">The descriptor from which to create an observable sequence of changed notifications.</param>
    /// <param name="source">The object to which the <paramref name="event"/> belongs.</param>
    /// <returns>An observable sequence of events.</returns>
    public static IObservable<EventPattern<EventArgs>> EventRaised(
      this EventDescriptor @event,
      object source)
    {
      Contract.Requires(@event != null);
      Contract.Requires(source != null);
      Contract.Ensures(Contract.Result<IObservable<EventPattern<EventArgs>>>() != null);

      return @event.EventType == typeof(EventHandler)
        ? Observable.FromEventPattern<EventHandler, EventArgs>(
            handler => handler.Invoke,
            handler => @event.AddEventHandler(source, handler),
            handler => @event.RemoveEventHandler(source, handler))
        : new EventProxyObservable(source, @event);
    }