コード例 #1
0
    private static FeedItemOperation newSiteLinkFeedItemAddOperation(
        SiteLinksDataHolder siteLinksData, String text, String url) {
      // Create the FeedItemAttributeValues for our text values.
      FeedItemAttributeValue linkTextAttributeValue = new FeedItemAttributeValue();
      linkTextAttributeValue.feedAttributeId = siteLinksData.LinkTextFeedAttributeId;
      linkTextAttributeValue.stringValue = text;
      FeedItemAttributeValue linkUrlAttributeValue = new FeedItemAttributeValue();
      linkUrlAttributeValue.feedAttributeId = siteLinksData.LinkUrlFeedAttributeId;
      linkUrlAttributeValue.stringValue = url;

      // Create the feed item and operation.
      FeedItem item = new FeedItem();
      item.feedId = siteLinksData.SiteLinksFeedId;
      item.attributeValues =
          new FeedItemAttributeValue[] {linkTextAttributeValue, linkUrlAttributeValue};
      FeedItemOperation operation = new FeedItemOperation();
      operation.operand = item;
      operation.@operator = Operator.ADD;
      return operation;
    }
コード例 #2
0
    /// <summary>
    /// Creates a FeedItemOperation that will create a FeedItem with the
    /// specified values and ad group target when sent to
    /// FeedItemService.mutate.
    /// </summary>
    /// <param name="name">The value for the name attribute of the FeedItem.
    /// </param>
    /// <param name="price">The value for the price attribute of the FeedItem.
    /// </param>
    /// <param name="date">The value for the date attribute of the FeedItem.
    /// </param>
    /// <param name="adGroupId">The ID of the ad group to target with the
    /// FeedItem.</param>
    /// <param name="dataHolder">The data holder that contains metadata about
    /// the customizer Feed.</param>
    /// <returns>A new FeedItemOperation for adding a FeedItem.</returns>
    private static FeedItemOperation CreateFeedItemAddOperation(string name, string price,
        String date, long adGroupId, CustomizersDataHolder dataHolder) {
      FeedItem feedItem = new FeedItem();
      feedItem.feedId = dataHolder.FeedId;
      List<FeedItemAttributeValue> attributeValues = new List<FeedItemAttributeValue>();

      FeedItemAttributeValue nameAttributeValue = new FeedItemAttributeValue();
      nameAttributeValue.feedAttributeId = dataHolder.NameFeedAttributeId;
      nameAttributeValue.stringValue = name;
      attributeValues.Add(nameAttributeValue);

      FeedItemAttributeValue priceAttributeValue = new FeedItemAttributeValue();
      priceAttributeValue.feedAttributeId = dataHolder.PriceFeedAttributeId;
      priceAttributeValue.stringValue = price;
      attributeValues.Add(priceAttributeValue);

      FeedItemAttributeValue dateAttributeValue = new FeedItemAttributeValue();
      dateAttributeValue.feedAttributeId = dataHolder.DateFeedAttributeId;
      dateAttributeValue.stringValue = date;
      attributeValues.Add(dateAttributeValue);

      feedItem.attributeValues = attributeValues.ToArray();

      feedItem.adGroupTargeting = new FeedItemAdGroupTargeting();
      feedItem.adGroupTargeting.TargetingAdGroupId = adGroupId;

      FeedItemOperation feedItemOperation = new FeedItemOperation();
      feedItemOperation.operand = feedItem;
      feedItemOperation.@operator = Operator.ADD;

      return feedItemOperation;
    }