private static void RunSample(TasksService service, bool modify, ETagAction behaviour)
        {
            Console.WriteLine("Testing for E-Tag case " + behaviour + " with modified=" + modify + "...");

            // Create a new task list.
            TaskList list = service.Tasklists.Insert(new TaskList() { Title = "E-Tag Collision Test" }).Execute();

            // Add a task.
            Task myTask = service.Tasks.Insert(new Task() { Title = "My Task" }, list.Id).Execute();

            // Retrieve a second instance of this task, modify it and commit it.
            if (modify)
            {
                Task myTaskB = service.Tasks.Get(list.Id, myTask.Id).Execute();
                myTaskB.Title = "My Task B!";
                service.Tasks.Update(myTaskB, list.Id, myTaskB.Id).Execute();
            }

            // Modify the original task, and see what happens.
            myTask.Title = "My Task A!";
            var request = service.Tasks.Update(myTask, list.Id, myTask.Id);
            request.ETagAction = behaviour;

            try
            {
                request.Execute();
                Console.WriteLine("\tResult: Success!");
            }
            catch (GoogleApiException ex)
            {
                Console.WriteLine("\tResult: Failure! The error message is: " + ex.Message);
            }
            finally
            {
                // Delete the created list. 
                service.Tasklists.Delete(list.Id).Execute();
                Console.WriteLine();
            }
        }
Exemple #2
0
 /// <summary>
 /// Sets the ETag-behavior of this request.
 /// </summary>
 public IRequest WithETagAction(ETagAction action)
 {
     ETagAction = action;
     return this;
 }