/// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the AudienceSegmentService.
      AudienceSegmentService audienceSegmentService =
          (AudienceSegmentService) user.GetService(DfpService.v201308.AudienceSegmentService);

      // Set defaults for page and Statement.
      AudienceSegmentPage page = new AudienceSegmentPage();
      Statement statement = new Statement();
      int offset = 0;

      try {
        do {
          // Create a Statement to get all audience segments.
          statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);

          // Get audience segment by Statement.
          page = audienceSegmentService.getAudienceSegmentsByStatement(statement);

          // Display results.
          if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (AudienceSegment segment in page.results) {
              Console.WriteLine("{0}) 'Audience segment with id \"{1}\" and name \"{2}\" was " +
                  "found.", i, segment.id, segment.name);
              i++;
            }
          }

          offset += 500;
        } while (offset < page.totalResultSetSize);
        Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get audience segment. Exception says \"{0}\"", ex.Message);
      }
    }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the AudienceSegmentService.
              AudienceSegmentService audienceSegmentService =
              (AudienceSegmentService) user.GetService(DfpService.v201308.AudienceSegmentService);

              // Create a statement to only select first party audience segments.
              string statementText = "where type = :type order by id ASC LIMIT 500";
              Statement statement = new StatementBuilder(statementText).
              AddValue("type", "FIRST_PARTY").ToStatement();
              // Set defaults for page and Statement.
              AudienceSegmentPage page = new AudienceSegmentPage();
              int offset = 0;

              try {
            do {
              // Create a Statement to get all first party audience segments.
              statement.query = statementText + " OFFSET " + offset;

              // Get audience segment by Statement.
              page = audienceSegmentService.getAudienceSegmentsByStatement(statement);

              // Display results.
              if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (AudienceSegment segment in page.results) {
              Console.WriteLine("{0}) 'Audience segment with id \"{1}\" and name \"{2}\" was " +
                  "found.", i, segment.id, segment.name);
              i++;
            }
              }

              offset += 500;
            } while (offset < page.totalResultSetSize);
            Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
              } catch (Exception ex) {
            Console.WriteLine("Failed to get audience segment. Exception says \"{0}\"", ex.Message);
              }
        }