static async public Task SetXboxLiveSandboxAsync(string url, string sandbox, string userName = null, string password = null)
        {
            DevicePortal connection = GetConnection(url, userName, password);
            await connection.SetXboxLiveSandboxAsync(sandbox);

            await connection.RebootAsync();
        }
Esempio n. 2
0
        /// <summary>
        /// Main entry point for handling a Sandbox 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(SandboxUsageMessage);
                return;
            }

            string desiredValue = parameters.GetParameterValue("value");

            if (string.IsNullOrEmpty(desiredValue))
            {
                Task <Sandbox> getSandboxTask = portal.GetXboxLiveSandboxAsync();
                getSandboxTask.Wait();

                Console.WriteLine(getSandboxTask.Result);
            }
            else
            {
                Task <Sandbox> setSandboxTask = portal.SetXboxLiveSandboxAsync(desiredValue);
                setSandboxTask.Wait();

                Console.WriteLine("{0} -> {1}", setSandboxTask.Result, desiredValue);

                if (parameters.HasFlag("reboot"))
                {
                    Task rebootTask = portal.RebootAsync();
                    rebootTask.Wait();
                    Console.WriteLine("Console rebooting...");
                }
                else
                {
                    Console.WriteLine("A reboot is required before this setting takes effect.");
                }
            }
        }