コード例 #1
0
        private static async Task DemoVirtualNetworkOperations(ManagementControllerParameters managementControllerParameters)
        {
            using (var controller = new ManagementController(managementControllerParameters))
            {
                Console.WriteLine("1. List virtual networks");
                ConsoleContinuePrompt("list");
                controller.ListVirtualNetworks();
                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("2. Get virtual network configuration");
                ConsoleContinuePrompt("get configuration");
                await controller.GetVirtualNetworkConfigurationAsync();

                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("3. Add virtual network");
                ConsoleContinuePrompt("add");
                await controller.AddVirtualNetworkSiteAsync();

                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("4. Set new virtual network configuration");
                Console.WriteLine("********************************************************************************");
                Console.WriteLine("         Your existing virtual network configuration will be replaced.");
                Console.WriteLine("         This operation will fail if you have virtual networks in use ");
                Console.WriteLine("         that cannot be deleted.");
                Console.WriteLine("********************************************************************************");
                ConsoleContinuePrompt("set");
                await controller.SetVirtualNetworkConfigurationAsync();

                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("5. Restore original configuraiton");
                ConsoleContinuePrompt("restore");
                await controller.CleanUpAsync();

                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("Done. Press a key to exit");
                Console.ReadKey();
            }
        }
コード例 #2
0
        private static async Task DemoVirtualNetworkOperations(ManagementControllerParameters managementControllerParameters)
        {
            using (var controller = new ManagementController(managementControllerParameters))
            {
                Console.WriteLine("1. List virtual networks");
                ConsoleContinuePrompt("list");
                controller.ListVirtualNetworks();
                Console.WriteLine("\n...Complete\n");
                
                Console.WriteLine("2. Get virtual network configuration");
                ConsoleContinuePrompt("get configuration");
                await controller.GetVirtualNetworkConfigurationAsync();
                Console.WriteLine("\n...Complete\n");
                
                Console.WriteLine("3. Add virtual network");
                ConsoleContinuePrompt("add");
                await controller.AddVirtualNetworkSiteAsync();
                Console.WriteLine("\n...Complete\n");
                
                Console.WriteLine("4. Set new virtual network configuration");
                Console.WriteLine("********************************************************************************");
                Console.WriteLine("         Your existing virtual network configuration will be replaced.");
                Console.WriteLine("         This operation will fail if you have virtual networks in use ");
                Console.WriteLine("         that cannot be deleted.");
                Console.WriteLine("********************************************************************************");
                ConsoleContinuePrompt("set");
                await controller.SetVirtualNetworkConfigurationAsync();
                Console.WriteLine("\n...Complete\n");
                
                Console.WriteLine("5. Restore original configuraiton");
                ConsoleContinuePrompt("restore");
                await controller.CleanUpAsync();
                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("Done. Press a key to exit"); 
                Console.ReadKey();
            }
        }