public void Handle(GetScreensForUser command, Action<IEnumerable<IScreen>> callback) { var screens = new List<IScreen>(); for (int i = 0; i < 32; i++) { if ((1 << i & command.Permissions) > 0) { string screenName; if (_screens.TryGetValue(i, out screenName)) screens.Add(_container.Resolve<IScreen>(screenName)); } } callback(screens); }
public IEnumerable<IResult> DoLogin() { ShowScreens = false; Error = null; if (Login == null) yield break; var loginUser = new LoginUser() { Login = Login.Name, Password = Password }.AsResult(); yield return loginUser; if (loginUser.Response == null) { Error = "Invalid password"; } else { var getScreens = new GetScreensForUser() { Permissions = loginUser.Response.Type }.AsResult(); yield return getScreens; Screens.Clear(); foreach (var screen in getScreens.Response) { Screens.Add(screen); } ShowScreens = true; } }