/// <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 ContentService.
      ContentService contentService =
          (ContentService) user.GetService(DfpService.v201408.ContentService);

      // Create a statement to get all content.
      StatementBuilder statementBuilder = new StatementBuilder()
          .OrderBy("id ASC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

      // Set default for page.
      ContentPage page = new ContentPage();

      try {
        do {
          // Get content by statement.
          page = contentService.getContentByStatement(statementBuilder.ToStatement());

          if (page.results != null) {
            int i = page.startIndex;
            foreach (Content content in page.results) {
              Console.WriteLine("{0}) Content with ID \"{1}\", name \"{2}\", and status \"{3}\" " +
                  "was found.", i, content.id, content.name, content.status);
              i++;
            }
          }
          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);

        Console.WriteLine("Number of results found: " + page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get all content. 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 ContentService.
      ContentService contentService =
          (ContentService) user.GetService(DfpService.v201408.ContentService);

      // Get the NetworkService.
      NetworkService networkService = (NetworkService) user.GetService(
          DfpService.v201408.NetworkService);

      // Get the CustomTargetingService.
      CustomTargetingService customTargetingService = (CustomTargetingService) user.GetService(
          DfpService.v201408.CustomTargetingService);

      try {
        // Get content browse custom targeting key ID.
        long contentBrowseCustomTargetingKeyId =
            networkService.getCurrentNetwork().contentBrowseCustomTargetingKeyId;

        // Create a statement to select the categories matching the name comedy.
        Statement categoryFilterStatement = new StatementBuilder()
            .Where("customTargetingKeyId = :contentBrowseCustomTargetingKeyId " +
            " and name = :category")
            .OrderBy("id ASC")
            .Limit(1)
            .AddValue("contentBrowseCustomTargetingKeyId", contentBrowseCustomTargetingKeyId)
            .AddValue("category", "comedy")
            .ToStatement();

        // Get categories matching the filter statement.
        CustomTargetingValuePage customTargetingValuePage =
            customTargetingService.getCustomTargetingValuesByStatement(categoryFilterStatement);

        if (customTargetingValuePage.results != null) {
          // Get the custom targeting value ID for the comedy category.
          long categoryCustomTargetingValueId = customTargetingValuePage.results[0].id;

          // Create a statement to get all active content.
          StatementBuilder statementBuilder = new StatementBuilder()
            .Where("status = :status")
            .OrderBy("id ASC")
            .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
            .AddValue("status", "ACTIVE");

          // Set defaults for page and filterStatement.
          ContentPage page = new ContentPage();

          do {
            // Get content by statement.
            page = contentService.getContentByStatementAndCustomTargetingValue(
                statementBuilder.ToStatement(), categoryCustomTargetingValueId);

            if (page.results != null) {
              int i = page.startIndex;
              foreach (Content content in page.results) {
                Console.WriteLine("{0})  Content with ID \"{1}\", name \"{2}\", and status " +
                    "\"{3}\" was found.", i, content.id, content.name, content.status);
                i++;
              }
            }
            statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
          } while (statementBuilder.GetOffset() < page.totalResultSetSize);

          Console.WriteLine("Number of results found: " + page.totalResultSetSize);
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to get content by category. Exception says \"{0}\"", ex.Message);
      }
    }