internal void RunCalls()
        {
            AdClients adClients = GetAllAdClients();

            // Get a host ad client ID, so we can run the rest of the samples.
            // Make sure it's a host ad client.
            AdClient exampleAdClient = FindAdClientForHost(adClients.Items);

            if (exampleAdClient != null)
            {
                // Custom Channels: List, Add, Update, Delete
                CustomChannels hostCustomChannels = GetAllCustomChannels(exampleAdClient.Id);
                CustomChannel  newCustomChannel   = AddCustomChannel(exampleAdClient.Id);
                newCustomChannel = UpdateCustomChannel(exampleAdClient.Id, newCustomChannel.Id);
                DeleteCustomChannel(exampleAdClient.Id, newCustomChannel.Id);

                // URL Channels: List, Add, Delete
                GetAllUrlChannels(exampleAdClient.Id);
                UrlChannel newUrlChannel = AddUrlChannel(exampleAdClient.Id);
                DeleteUrlChannel(exampleAdClient.Id, newUrlChannel.Id);

                GenerateReport(service, exampleAdClient.Id);
            }
            else
            {
                Console.WriteLine("No host ad clients found, unable to run remaining host samples.");
            }
        }
        /// <summary>This example updates a custom channel on a host ad client.</summary>
        /// <param name="adClientId">The ID for the ad client to be used.</param>
        /// <param name="customChannelId">The ID for the custom channel to be updated.</param>
        /// <returns>The updated custom channel.</returns>
        private CustomChannel UpdateCustomChannel(string adClientId, string customChannelId)
        {
            Console.WriteLine("=================================================================");
            Console.WriteLine("Updating custom channel {0}", customChannelId);
            Console.WriteLine("=================================================================");


            CustomChannel patchCustomChannel = new CustomChannel();

            System.Random random = new System.Random(System.DateTime.Now.Millisecond);
            patchCustomChannel.Name = "Updated Sample Channel #"
                                      + random.Next(0, 10000).ToString();

            // Update custom channel: Using REST's PATCH method to update just the Name field.
            CustomChannel customChannel = this.service.Customchannels
                                          .Patch(patchCustomChannel, adClientId, customChannelId).Execute();

            Console.WriteLine("Custom channel with id {0}, code {1} and name {2} was updated",
                              customChannel.Id, customChannel.Code, customChannel.Name);

            Console.WriteLine();

            // Return the Custom Channel that was just created
            return(customChannel);
        }
Beispiel #3
0
            public override void Config(Channel ch)
            {
                CustomChannel cch = ch as CustomChannel;

                prs.SetExpr(cch.prs.GetExpr());
                step = cch.step;
            }
Beispiel #4
0
 private static void CheckCustomChannel(CustomChannel chan)
 {
     if (chan.Hell)
     {
         Globals.HellChannels.Add(chan.Id);
     }
     else
     {
         Globals.JailChannels.Add(chan.Id);
     }
 }
Beispiel #5
0
    // Rest of CustomChannel's implementation...
    //</Snippet1>

    public static void Main()
    {
        CustomChannel channel = new CustomChannel(8085);

        channel.AddHookChannelUri("TempConverter");

        /*System.Runtime.Remoting.Channels.Http.HttpChannel channel =
         * new System.Runtime.Remoting.Channels.Http.HttpChannel(8085);*/

        /*System.Runtime.Remoting.Channels.Tcp.TcpChannel channel =
         * new System.Runtime.Remoting.Channels.Tcp.TcpChannel(8085);*/

        System.Console.WriteLine(channel.ChannelSinkChain);
    }
Beispiel #6
0
        public void ConnectionButtonOpenClick(object sender, EventArgs e)
        {
            Protect();

            var address = ConnectionTextServerName.Text;

            ConnectionLabelError.Text = "Provide correct server name";

            if (string.IsNullOrEmpty(address) == false)
            {
                _channel = new CustomChannel(address);
                _channel.StartServer();

                OpenConnection(string.Empty);
            }
        }
        /// <summary>This example deletes a custom channel on a host ad client.</summary>
        /// <param name="adClientId">The ID for the ad client to be used.</param>
        /// <param name="customChannelId">The ID for the custom channel to be updated.</param>
        private void DeleteCustomChannel(string adClientId, string customChannelId)
        {
            Console.WriteLine("=================================================================");
            Console.WriteLine("Deleting custom channel {0}", customChannelId);
            Console.WriteLine("=================================================================");

            // Delete custom channel
            CustomChannel customChannel = this.service.Customchannels
                                          .Delete(adClientId, customChannelId).Execute();

            // Delete nonexistent custom channel
            try
            {
                CustomChannel wrongcustomChannel = this.service.Customchannels
                                                   .Delete(adClientId, "wrong_id").Execute();
            }
            catch (Google.GoogleApiException ex)
            {
                Console.WriteLine("Error with message '{0}' was correctly caught.", ex.Message);
            }

            Console.WriteLine("Custom channel with id {0} was deleted.", customChannelId);
            Console.WriteLine();
        }
        /// <summary>
        /// This example adds a custom channel to a host ad client.
        /// </summary>
        /// <param name="adClientId">The ID for the ad client to be used.</param>
        /// <returns>The created custom channel.</returns>
        private CustomChannel AddCustomChannel(string adClientId)
        {
            Console.WriteLine("=================================================================");
            Console.WriteLine("Adding custom channel to ad client {0}", adClientId);
            Console.WriteLine("=================================================================");

            CustomChannel newCustomChannel = new CustomChannel();

            System.Random random = new System.Random(System.DateTime.Now.Millisecond);
            newCustomChannel.Name = "Sample Channel #"
                                    + random.Next(0, 10000).ToString();

            // Create custom channel.
            CustomChannel customChannel = this.service.Customchannels
                                          .Insert(newCustomChannel, adClientId).Execute();

            Console.WriteLine("Custom channel with id {0}, code {1} and name {2} was created",
                              customChannel.Id, customChannel.Code, customChannel.Name);

            Console.WriteLine();

            // Return the Custom Channel that was just created
            return(customChannel);
        }
Beispiel #9
0
        /// <summary>
        /// Update a custom channel in the host AdSense account.
        /// Documentation https://developers.google.com/adsensehost/v4.1/reference/customchannels/update
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AdSenseHost service.</param>
        /// <param name="adClientId">Ad client in which the custom channel will be updated.</param>
        /// <param name="body">A valid AdSenseHost v4.1 body.</param>
        /// <returns>CustomChannelResponse</returns>
        public static CustomChannel Update(AdSenseHostService service, string adClientId, CustomChannel body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (adClientId == null)
                {
                    throw new ArgumentNullException(adClientId);
                }

                // Make the request.
                return(service.Customchannels.Update(body, adClientId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Customchannels.Update failed.", ex);
            }
        }
        /// <summary>This example updates a custom channel on a host ad client.</summary>
        /// <param name="adClientId">The ID for the ad client to be used.</param>
        /// <param name="customChannelId">The ID for the custom channel to be updated.</param>
        /// <returns>The updated custom channel.</returns>
        private CustomChannel UpdateCustomChannel(string adClientId, string customChannelId)
        {
            Console.WriteLine("=================================================================");
            Console.WriteLine("Updating custom channel {0}", customChannelId);
            Console.WriteLine("=================================================================");


            CustomChannel patchCustomChannel = new CustomChannel();

            System.Random random = new System.Random(System.DateTime.Now.Millisecond);
            patchCustomChannel.Name = "Updated Sample Channel #"
                + random.Next(0, 10000).ToString();

            // Update custom channel: Using REST's PATCH method to update just the Name field.
            CustomChannel customChannel = this.service.Customchannels
                .Patch(patchCustomChannel, adClientId, customChannelId).Execute();

            Console.WriteLine("Custom channel with id {0}, code {1} and name {2} was updated",
                customChannel.Id, customChannel.Code, customChannel.Name);

            Console.WriteLine();

            // Return the Custom Channel that was just created
            return customChannel;
        }
        /// <summary>
        /// This example adds a custom channel to a host ad client.
        /// </summary>
        /// <param name="adClientId">The ID for the ad client to be used.</param>
        /// <returns>The created custom channel.</returns>
        private CustomChannel AddCustomChannel(string adClientId)
        {
            Console.WriteLine("=================================================================");
            Console.WriteLine("Adding custom channel to ad client {0}", adClientId);
            Console.WriteLine("=================================================================");

            CustomChannel newCustomChannel = new CustomChannel();

            System.Random random = new System.Random(System.DateTime.Now.Millisecond);
            newCustomChannel.Name = "Sample Channel #"
                + random.Next(0, 10000).ToString();

            // Create custom channel.
            CustomChannel customChannel = this.service.Customchannels
                .Insert(newCustomChannel, adClientId).Execute();

            Console.WriteLine("Custom channel with id {0}, code {1} and name {2} was created",
                customChannel.Id, customChannel.Code, customChannel.Name);

            Console.WriteLine();

            // Return the Custom Channel that was just created
            return customChannel;
        }