Google.Api.Ads.AdWords.Examples.CSharp.v201306.UpgradeLegacySitelinks.createSiteLinksFeed C# (CSharp) Méthode

createSiteLinksFeed() private static méthode

Create a feed for holding upgraded sitelinks.
private static createSiteLinksFeed ( FeedService feedService ) : SiteLinksFeed
feedService Google.Api.Ads.AdWords.v201306.FeedService The feed service.
Résultat SiteLinksFeed
        private static SiteLinksFeed createSiteLinksFeed(FeedService feedService)
        {
            SiteLinksFeed siteLinksData = new SiteLinksFeed();

              // Create attributes.
              FeedAttribute textAttribute = new FeedAttribute();
              textAttribute.type = FeedAttributeType.STRING;
              textAttribute.name = "Link Text";
              FeedAttribute urlAttribute = new FeedAttribute();
              urlAttribute.type = FeedAttributeType.URL;
              urlAttribute.name = "Link URL";

              // Create the feed.
              Feed siteLinksFeed = new Feed();
              siteLinksFeed.name = "Feed For Sitelinks";
              siteLinksFeed.attributes = new FeedAttribute[] {textAttribute, urlAttribute};
              siteLinksFeed.origin = FeedOrigin.USER;

              // Create operation.
              FeedOperation operation = new FeedOperation();
              operation.operand = siteLinksFeed;
              operation.@operator = Operator.ADD;

              // Add the feed.
              FeedReturnValue result = feedService.mutate(new FeedOperation[] {operation});

              Feed savedFeed = result.value[0];
              siteLinksData.SiteLinksFeedId = savedFeed.id;
              FeedAttribute[] savedAttributes = savedFeed.attributes;
              siteLinksData.LinkTextFeedAttributeId = savedAttributes[0].id;
              siteLinksData.LinkUrlFeedAttributeId = savedAttributes[1].id;
              return siteLinksData;
        }