/// <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 LineItemService.
              LineItemService lineItemService =
              (LineItemService) user.GetService(DfpService.v201211.LineItemService);

              // Set the order that all created line items will belong to and the
              // placement containing ad units with a mobile target platform.
              long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));
              long[] targetedPlacementIds = new long[] {long.Parse(_T("INSERT_MOBILE_PLACEMENT_ID_HERE"))};

              // Create inventory targeting.
              InventoryTargeting inventoryTargeting = new InventoryTargeting();
              inventoryTargeting.targetedPlacementIds = targetedPlacementIds;

              // Create technology targeting.
              TechnologyTargeting technologyTargeting = new TechnologyTargeting();

              // Create device manufacturer targeting.
              DeviceManufacturerTargeting deviceManufacturerTargeting = new DeviceManufacturerTargeting();
              deviceManufacturerTargeting.isTargeted = true;

              // Target the Google device manufacturer (40100).
              Technology deviceManufacturerTechnology = new Technology();
              deviceManufacturerTechnology.id = 40100L;
              deviceManufacturerTargeting.deviceManufacturers =
              new Technology[] {deviceManufacturerTechnology};
              technologyTargeting.deviceManufacturerTargeting = deviceManufacturerTargeting;

              // Create mobile device targeting.
              MobileDeviceTargeting mobileDeviceTargeting = new MobileDeviceTargeting();

              // Exclude the Nexus One device (604046).
              Technology mobileDeviceTechnology = new Technology();
              mobileDeviceTechnology.id = 604046L;
              mobileDeviceTargeting.targetedMobileDevices = new Technology[] {mobileDeviceTechnology};
              technologyTargeting.mobileDeviceTargeting = mobileDeviceTargeting;

              // Create mobile device submodel targeting.
              MobileDeviceSubmodelTargeting mobileDeviceSubmodelTargeting =
              new MobileDeviceSubmodelTargeting();

              // Target the iPhone 4 device submodel (640003).
              Technology mobileDeviceSubmodelTechnology = new Technology();
              mobileDeviceSubmodelTechnology.id = 640003L;
              mobileDeviceSubmodelTargeting.targetedMobileDeviceSubmodels =
              new Technology[] {mobileDeviceSubmodelTechnology};
              technologyTargeting.mobileDeviceSubmodelTargeting = mobileDeviceSubmodelTargeting;

              // Create targeting.
              Targeting targeting = new Targeting();
              targeting.inventoryTargeting = inventoryTargeting;
              targeting.technologyTargeting = technologyTargeting;

              // Create local line item object.
              LineItem lineItem = new LineItem();
              lineItem.name = "Mobile line item";
              lineItem.orderId = orderId;
              lineItem.targeting = targeting;
              lineItem.lineItemType = LineItemType.STANDARD;
              lineItem.allowOverbook = true;

              // Set the target platform to mobile.
              lineItem.targetPlatform = TargetPlatform.MOBILE;

              // Set the creative rotation type to even.
              lineItem.creativeRotationType = CreativeRotationType.EVEN;

              // Create the creative placeholder.
              CreativePlaceholder creativePlaceholder = new CreativePlaceholder();
              Size size = new Size();
              size.width = 300;
              size.height = 250;
              size.isAspectRatio = false;
              creativePlaceholder.size = size;

              // Set the size of creatives that can be associated with this line item.
              lineItem.creativePlaceholders = new CreativePlaceholder[] {creativePlaceholder};

              // Set the length of the line item to run.
              lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY;
              lineItem.endDateTime = DateTimeUtilities.FromString("20120901 00:00:00");

              // Set the cost per unit to $2.
              lineItem.costType = CostType.CPM;
              Money money = new Money();
              money.currencyCode = "USD";
              money.microAmount = 2000000L;
              lineItem.costPerUnit = money;

              // Set the number of units bought to 500,000 so that the budget is
              // $1,000.
              lineItem.unitsBought = 500000L;
              lineItem.unitType = UnitType.IMPRESSIONS;

              try {
            // Create the line item on the server.
            lineItem = lineItemService.createLineItem(lineItem);

            if (lineItem != null) {
              Console.WriteLine("A line item with ID \"{0}\", belonging to order ID \"{1}\", and " +
              "named \"{2}\" was created.", lineItem.id, lineItem.orderId, lineItem.name);
            } else {
              Console.WriteLine("No line item created.");
            }
              } catch (Exception ex) {
            Console.WriteLine("Failed to create line items. 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 LineItemService.
      LineItemService lineItemService =
          (LineItemService) user.GetService(DfpService.v201211.LineItemService);

      // Set the order that all created line items will belong to and the
      // video ad unit ID to target.
      long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));
      string targetedVideoAdUnitId = _T("INSERT_TARGETED_VIDEO_AD_UNIT_ID_HERE");

      // Set the custom targeting key ID and value ID representing the metadata
      // on the content to target. This would typically be a key representing
      // a "genre" and a value representing something like "comedy".
      long contentCustomTargetingKeyId =
          long.Parse(_T("INSERT_CONTENT_CUSTOM_TARGETING_KEY_ID_HERE"));
      long contentCustomTargetingValueId =
          long.Parse(_T("INSERT_CONTENT_CUSTOM_TARGETING_VALUE_ID_HERE"));

      // Create custom criteria for the content metadata targeting.
      CustomCriteria contentCustomCriteria = new CustomCriteria();
      contentCustomCriteria.keyId = contentCustomTargetingKeyId;
      contentCustomCriteria.valueIds = new long[] {contentCustomTargetingValueId};
      contentCustomCriteria.@operator = CustomCriteriaComparisonOperator.IS;

      // Create custom criteria set.
      CustomCriteriaSet customCriteriaSet = new CustomCriteriaSet();
      customCriteriaSet.children = new CustomCriteriaNode[] {contentCustomCriteria};

      // Create inventory targeting.
      InventoryTargeting inventoryTargeting = new InventoryTargeting();
      AdUnitTargeting adUnitTargeting = new AdUnitTargeting();
      adUnitTargeting.adUnitId = targetedVideoAdUnitId;
      adUnitTargeting.includeDescendants = true;
      inventoryTargeting.targetedAdUnits = new AdUnitTargeting[] {adUnitTargeting};

      // Create video position targeting.
      VideoPositionTargeting videoPositionTargeting = new VideoPositionTargeting();
      videoPositionTargeting.targetedVideoPositions =
          new VideoPositionTargetingType[] {VideoPositionTargetingType.PREROLL};

      // Create targeting.
      Targeting targeting = new Targeting();
      targeting.customTargeting = customCriteriaSet;
      targeting.inventoryTargeting = inventoryTargeting;
      targeting.videoPositionTargeting = videoPositionTargeting;

      // Create local line item object.
      LineItem lineItem = new LineItem();
      lineItem.name = "Video line item";
      lineItem.orderId = orderId;
      lineItem.targeting = targeting;
      lineItem.lineItemType = LineItemType.SPONSORSHIP;
      lineItem.allowOverbook = true;

      // Set the environment type to video.
      lineItem.environmentType = EnvironmentType.VIDEO_PLAYER;

      // Set the creative rotation type to optimized.
      lineItem.creativeRotationType = CreativeRotationType.OPTIMIZED;

      // Create the master creative placeholder.
      CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder();
      Size size1 = new Size();
      size1.width = 400;
      size1.height = 300;
      size1.isAspectRatio = false;
      creativeMasterPlaceholder.size = size1;

      // Create companion creative placeholders.
      CreativePlaceholder companionCreativePlaceholder1 = new CreativePlaceholder();
      Size size2 = new Size();
      size2.width = 300;
      size2.height = 250;
      size2.isAspectRatio = false;
      companionCreativePlaceholder1.size = size2;

      CreativePlaceholder companionCreativePlaceholder2 = new CreativePlaceholder();
      Size size3 = new Size();
      size3.width = 728;
      size3.height = 90;
      size3.isAspectRatio = false;
      companionCreativePlaceholder2.size = size3;

      // Set companion creative placeholders.
      creativeMasterPlaceholder.companions = new CreativePlaceholder[] {
          companionCreativePlaceholder1, companionCreativePlaceholder2};

      // Set the size of creatives that can be associated with this line item.
      lineItem.creativePlaceholders = new CreativePlaceholder[] {creativeMasterPlaceholder};

      // Set delivery of video companions to optional.
      lineItem.companionDeliveryOption = CompanionDeliveryOption.OPTIONAL;

      // Set the length of the line item to run.
      lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY;
      lineItem.endDateTime = DateTimeUtilities.FromString("20120901 00:00:00");

      // Set the cost per day to $1.
      lineItem.costType = CostType.CPD;
      Money money = new Money();
      money.currencyCode = "USD";
      money.microAmount = 1000000L;
      lineItem.costPerUnit = money;

      // Set the percentage to be 100%.
      lineItem.unitsBought = 100;

      try {
        // Create the line item on the server.
        lineItem = lineItemService.createLineItem(lineItem);

        if (lineItem != null) {
          Console.WriteLine("A line item with ID \"{0}\", belonging to order ID \"{1}\", and " +
              "named \"{2}\" was created.", lineItem.id, lineItem.orderId, lineItem.name);
        } else {
          Console.WriteLine("No line item created.");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to create line items. Exception says \"{0}\"",
            ex.Message);
      }
    }