public static void InitUserStoreageService(IUserStorageService userStorageService) { foreach (var user in Users) { userStorageService.Add(user); } }
public CustomAuthSchemaHandler( IOptionsMonitor <CustomAuthSchemaOptions> options, ILoggerFactory loggerFactory, UrlEncoder encoder, ISystemClock clock, IUserStorageService storage) : base(options, loggerFactory, encoder, clock) { _storage = storage; }
internal VWO(AccountSettings settings, IValidator validator, IUserStorageService userStorageService, ICampaignAllocator campaignAllocator, ISegmentEvaluator segmentEvaluator, IVariationAllocator variationAllocator, bool isDevelopmentMode, string goalTypeToTrack = Constants.GoalTypes.ALL, bool shouldTrackReturningUser = false) { this._settings = settings; this._validator = validator; this._userStorageService = new UserStorageAdapter(userStorageService); this._campaignAllocator = campaignAllocator; this._variationAllocator = variationAllocator; this._isDevelopmentMode = isDevelopmentMode; this._segmentEvaluator = segmentEvaluator; this._goalTypeToTrack = goalTypeToTrack; this._shouldTrackReturningUser = shouldTrackReturningUser; }
public UsersManagerViewModel() { IUserStorageService service = Locator.Current.GetService <IUserStorageService>(); Observable.Return(Unit.Default) .Merge(Refresh) .SelectMany(async(e) => { var v = (await service.GetUsers()).Select(u => new UserViewModel { User = u }).ToList(); return(v); }) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.UserViewModels); // TODO solve the problem this.WhenAnyValue(x => x.UserViewModels) .Where(u => u != null) .Subscribe(x => { foreach (var item in x) { item.Refresh.Subscribe(_ => { Refresh.Execute().Subscribe(); }); } }); AddUser = ReactiveCommand.CreateFromTask <(User, string), bool>(async(input) => { var user = input.Item1; return(await service.SaveUser(user.Username, user.Password, input.Item2)); }); AddUser.ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => { Refresh.Execute().Subscribe(); }); }
public void Run() { RunSlaves(); var repositoryFileName = ConfigurationManager.AppSettings["UserMemoryCacheWithStateFileName"]; var repository = new UserDiskRepository(repositoryFileName); RepositoryManager = repository; Assembly assembly = Assembly.Load("UserStorageServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f46a87b3d9a80705"); var masterServiceType = assembly.ExportedTypes .Where(t => t.GetCustomAttribute <MyApplicationServiceAttribute>() != null) .First(t => t.GetCustomAttribute <MyApplicationServiceAttribute>().ServiceMode == "UserStorageMaster"); var storageService = (IUserStorageService)Activator.CreateInstance( masterServiceType, repository, slaveActions.Select(s => s.Receiver)); MasterService = new UserStorageServiceLog(storageService); }
public LogService(IUserStorageService userStorageService) { this.userStorageService = userStorageService; }
public UserStorageController(IOrchardServices services, IUserStorageService userStorageService) { Services = services; _userStorageService = userStorageService; T = NullLocalizer.Instance; }
public UserStorageServiceLog(IUserStorageService storageService) : base(storageService) { }
public HomeController(IWorkContextAccessor wca, IUserStorageService storageService) { _wca = wca; _storageService = storageService; }
public GetDevicesIntentHandler(IUserStorageService userStorageService) { _userStorageService = userStorageService; }
public AppEntry(IEnumerable <IIntentHandler> handlers, IUserStorageService userStorageService) { _handlers = handlers; _userStorageService = userStorageService; }
public MainPageViewModel() { Activator = new ViewModelActivator(); this.ForceDisconnect = ReactiveCommand.CreateFromTask <string, Unit>(ForceDisconnectImpl); this.CancelConnect = ReactiveCommand.Create(() => { Global.ConnectStatus = ConnectStatus.Disconnected; }); this.ContinueConnectWithPin = ReactiveCommand.CreateFromTask <string>(async(pin) => { await Global.DoConnect.Execute(pin); }); this.ContinueConnectWithPassword = ReactiveCommand.CreateFromTask <string>(async(password) => { IUserStorageService service = Locator.Current.GetService <IUserStorageService>(); try { await service.ResetUserPassword(Global.CurrentUser.Username, password, ""); } catch { throw new Exception("新密码保存错误"); } await Global.DoConnect.Execute(""); }); this.Toggle = ReactiveCommand.CreateFromTask(async() => { await Global.Toggle.Execute(); }); this.WhenActivated(d => { this.WhenAnyValue(x => x.Global.CurrentUser) .ToPropertyEx(this, x => x.SelectedUser) .DisposeWith(d); this.WhenAnyValue(x => x.Global.ConnectStatus) .ToPropertyEx(this, x => x.ConnectStatus) .DisposeWith(d); var errorSource = Observable.Merge( this.ContinueConnectWithPin.ThrownExceptions, this.Toggle.ThrownExceptions, this.ContinueConnectWithPassword.ThrownExceptions ); var errorStream = errorSource .Where(u => u is ConnectionException); this.WhenAnyValue(x => x.ConnectStatus) .Where(u => u == ConnectStatus.Connected) .Select(u => Unit.Default) .Merge(Observable.Interval(TimeSpan.FromMinutes(10)).Select(p => Unit.Default)) .SelectMany(async _ => await Locator.Current.GetService <IInternetGatewayService>().GetAccountInfo()) .Catch(Observable.Return(new AccountInfo { Name = "获取失败", Plan = "N/A", UsedTime = TimeSpan.FromMinutes(0) })) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.AccountInfo); errorStream .Select(u => ((ConnectionException)u).ErrorType) .Where(u => u == ConnectionError.LostPin || u == ConnectionError.InvalidPin) .Select(u => true) .Delay(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler) .Merge(this.CancelConnect.Select(_ => false)) .Merge(this.ContinueConnectWithPin.IsExecuting.Select(_ => false)) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.PinRequired) .DisposeWith(d); errorStream .Select(u => ((ConnectionException)u).ErrorType) .Where(u => u == ConnectionError.InvalidCredient) .Select(u => true) .Delay(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler) .Merge(this.CancelConnect.Select(_ => false)) .Merge(this.ContinueConnectWithPassword.IsExecuting.Select(_ => false)) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.PasswordRequired) .DisposeWith(d); var errorFromDriver = errorSource.Where(u => ((u is ConnectionException ce) && ce.ErrorType == ConnectionError.Unclear) || (!(u is ConnectionException))) .Select(u => u.Message); errorFromDriver .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.AlertMessage) .DisposeWith(d); errorFromDriver .Select(u => true) .Merge( errorFromDriver .Delay(TimeSpan.FromMilliseconds(100)) .Select(u => false) ) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.AlertRequired, false) .DisposeWith(d); errorFromDriver .Subscribe(x => { this.Global.ConnectStatus = ConnectStatus.Disconnected; }) .DisposeWith(d); }); }
public UserStorageServiceLog(IUserStorageService userStorageService) : base(userStorageService) { }
protected UserStorageServiceDecorator(IUserStorageService storageService) { this.storageService = storageService; }
protected UserStorageDecorator(IUserStorageService _service) { Service = _service; }
protected UserStorageServiceDecorator(IUserStorageService userStorageService) { UserStorageService = userStorageService; }
/// <summary> /// Initializes a new instance of the <see cref="Client"/> class. /// </summary> public Client(IUserStorageService userStorageService, IUserRepositoryManager userRepositoryManager) { this.userStorageService = userStorageService; this.userRepositoryManager = userRepositoryManager; }
public UserStorageLog(IUserStorageService _service) : base(_service) { }
/// <summary> /// Instantiate a VWOClient to call Activate, GetVariation and Track apis for given user and goal. /// </summary> /// <param name="settingFile">Settings as provided by GetSettings call.</param> /// <param name="isDevelopmentMode">When running in development or non-production mode. This ensures no operations are tracked on VWO account.</param> /// <param name="userStorageService">UserStorageService to Get and Save User-assigned variations.</param> /// <param name="goalTypeToTrack">Specify which goalType to track.</param> /// <param name="shouldTrackReturningUser">Should track returning user or not.</param> /// <returns> /// IVWOClient instance to call Activate, GetVariation and Track apis for given user and goal. /// </returns> public static IVWOClient Launch(Settings settingFile, bool isDevelopmentMode = false, IUserStorageService userStorageService = null, string goalTypeToTrack = Constants.GoalTypes.ALL, bool shouldTrackReturningUser = false) { if (Validator.SettingsFile(settingFile)) { LogDebugMessage.ValidConfiguration(file); AccountSettings accountSettings = SettingsProcessor.ProcessAndBucket(settingFile); LogDebugMessage.SettingsFileProcessed(file); if (accountSettings == null) { return(null); } if (isDevelopmentMode) { LogDebugMessage.SetDevelopmentMode(file); } var vwoClient = new VWO(accountSettings, Validator, userStorageService, CampaignAllocator, SegmentEvaluator, VariationAllocator, isDevelopmentMode, goalTypeToTrack, shouldTrackReturningUser); LogDebugMessage.SdkInitialized(file); return(vwoClient); } LogErrorMessage.ProjectConfigCorrupted(file); return(null); }
public UserStorageAdapter(IUserStorageService userStorageService) { this._userStorageService = userStorageService; }
/// <summary> /// Initializes a new instance of the <see cref="Client"/> class. /// </summary> public Client(IUserStorageService _userStorageService) { this._userStorageService = _userStorageService; }
/// <summary> /// public constructor of Authorization controller /// </summary> /// <param name="loggerFactory"></param> public AuthorizationController(ILoggerFactory loggerFactory, IUserStorageService storage) { _logger = loggerFactory.CreateLogger <AuthorizationController>(); _storage = storage; }
public UserViewModel() { Activator = new ViewModelActivator(); IUserStorageService service = Locator.Current.GetService <IUserStorageService>(); #region Commands Refresh = ReactiveCommand.CreateFromObservable(() => Observable.Return(Unit.Default)); Delete = ReactiveCommand.CreateFromTask(async() => { var ret = await service.DeleteUser(User.Username); await Refresh.Execute(); return(ret); }); ChangePassword = ReactiveCommand.CreateFromTask <(string password, string pin), bool>(async(input) => { var ret = await service.ResetUserPassword(User.Username, input.password, input.pin); await Refresh.Execute(); return(ret); }); ChangePin = ReactiveCommand.CreateFromTask <(string oldPin, string newPin), bool>(async(input) => { var ret = await service.ResetUserPin(User.Username, input.oldPin, input.newPin); await Refresh.Execute(); return(ret); }); VerifyPin = ReactiveCommand.CreateFromTask <string, bool>(async(pin) => { return(await service.CheckUserPinValid(User.Username, pin)); }); TogglePasswordShown = ReactiveCommand.CreateFromTask <string, bool>(async(pin) => { if (!IsPasswordShown) { try { var password = await service.DecryptedUserPassword(User.Username, pin); User.Password = password; return(true); } catch { return(false); } } else { User.Password = ""; return(false); } }); TogglePasswordShown.ToPropertyEx(this, x => x.IsPasswordShown, false); SetCurrent = ReactiveCommand.CreateFromTask(async() => { var status = GlobalStatusStore.Current.ConnectStatus; if (status != ConnectStatus.Disconnected) { throw new Exception("vm_unavailable_change_user"); } GlobalStatusStore.Current.CurrentUser = User; await service.SetDefaultUser(User.Username); }); #endregion this.WhenActivated(d => { this.WhenAnyValue(x => x.User).SelectMany(x => Observable.FromAsync(async() => { return(await service.CheckUserPinExist(x?.Username)); })) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.HasPin) .DisposeWith(d); this.WhenAnyValue(x => x.User) .CombineLatest( GlobalStatusStore.Current.WhenAnyValue(x => x.CurrentUser), (x, y) => (x?.Username == y?.Username) ) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.IsCurrent) .DisposeWith(d); }); }