示例#1
0
        /// <summary>
        /// The main method.
        /// </summary>
        /// <param name="args">Command line arguments - see ShowUsage for options</param>
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                ShowUsage();
                return;
            }

            Console.WriteLine("Authorized Buyers AdExchange Buyer II API DotNet Sample");
            Console.WriteLine("====================");

            // Create a new service instance for Ad Exchange Buyer II.
            // Note: This is where security configuration takes place and will need to be
            // configured before the code will work!
            AdExchangeBuyerIIService v2Service = Utilities.GetV2Service();

            // If --all is passed run all the examples
            string[] examplesToRun = (args[0].ToLower() == "--all")
                ? examples.Keys.ToArray() : args;

            foreach (string exampleName in examplesToRun)
            {
                if (examples.ContainsKey(exampleName))
                {
                    ExampleBase example = examples[exampleName];
                    Console.WriteLine(example.Description);

                    if (example.getClientType() == ExampleBase.ClientType.ADEXCHANGEBUYERII)
                    {
                        example.Run(v2Service);
                    }
                }
                else
                {
                    Console.WriteLine("Unrecognised argument " + exampleName);
                    ShowUsage();
                    break;
                }
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }