/// <summary> /// Main entry point for handling a user operation /// </summary> /// <param name="portal">DevicePortal reference for communicating with the device.</param> /// <param name="parameters">Parsed command line parameters.</param> public static void HandleOperation(DevicePortal portal, ParameterHelper parameters) { if (parameters.HasFlag(ParameterHelper.HelpFlag)) { Console.WriteLine(XblUserUsageMessage); return; } string operationType = parameters.GetParameterValue("subop"); if (string.IsNullOrWhiteSpace(operationType)) { Console.WriteLine("Missing subop parameter"); Console.WriteLine(); Console.WriteLine(XblUserUsageMessage); return; } operationType = operationType.ToLowerInvariant(); if (operationType.Equals("list")) { Task <UserList> getUsers = portal.GetXboxLiveUsersAsync(); getUsers.Wait(); Console.WriteLine(getUsers.Result); } else if (operationType.Equals("addsponsored")) { UserInfo user = new UserInfo(); user.SponsoredUser = true; user.SignedIn = true; UserList userList = new UserList(); userList.Add(user); UpdateXboxLiveUsers(portal, userList); } else if (operationType.Equals("signin") || operationType.Equals("signout") || operationType.Equals("delete") || operationType.Equals("autosignin")) { UserInfo user = new UserInfo(); if (parameters.HasParameter("id")) { uint userId = 0; if (!uint.TryParse(parameters.GetParameterValue("id"), out userId)) { Console.WriteLine(string.Format("Failed to parse id to an unsigned integer: {0}", parameters.GetParameterValue("id"))); return; } user.UserId = userId; } else { user.EmailAddress = parameters.GetParameterValue("msa"); if (user.EmailAddress == null) { Console.WriteLine("Must provide either msa or id to this operation"); Console.WriteLine(); Console.WriteLine(XblUserUsageMessage); return; } } if (operationType.Equals("signin")) { // Optional password (only used on first signin) user.Password = parameters.GetParameterValue("msapwd"); user.SignedIn = true; } else if (operationType.Equals("signout")) { user.SignedIn = false; } else if (operationType.Equals("delete")) { user.Delete = true; } else if (operationType.Equals("autosignin")) { if (parameters.HasFlag("on")) { user.AutoSignIn = true; } else if (parameters.HasFlag("off")) { user.AutoSignIn = false; } else { Console.WriteLine("autosignin operation requires the state (/on or /off)."); Console.WriteLine(); Console.WriteLine(XblUserUsageMessage); return; } } UserList userList = new UserList(); userList.Add(user); UpdateXboxLiveUsers(portal, userList); } else { Console.WriteLine(string.Format("Unrecognized subop: {0}", operationType)); Console.WriteLine(); Console.WriteLine(XblUserUsageMessage); return; } }