/// <summary> /// Create a new instance of a Url/Key <digital-content> object /// </summary> /// <param name="key"> /// The <key> tag contains a key needed to download or /// unlock a digital content item. /// </param> /// <param name="description"> /// The <description> tag contains instructions for downloading a digital /// content item. Please use the <item-description> tag to provide /// the description of the item being purchased. /// </param> /// <remarks></remarks> public DigitalItem(string key, string description) { key = EncodeHelper.CleanString(key); if (key.Length == 0) throw new ArgumentNullException(MISSING_KEY_OR_URL); _key = key; SetDescription(description); }
/// <summary> /// helper method to validate the description /// </summary> /// <param name="description">The description to set.</param> private void SetDescription(string description) { description = EncodeHelper.CleanString(description); if (description.Length > 0) description = EncodeHelper.EscapeXmlChars(description); if (description.Length > 1024) throw new ArgumentException(DESCRIPTION_LONG, "description"); _description = description; //The value is not required so we are not going to throw an exception //if it is not set. }
/// <summary> /// Create a new instance of a Url/Key <digital-content> object /// </summary> /// <param name="key"> /// The <key> tag contains a key needed to download or /// unlock a digital content item. /// </param> /// <param name="url"> /// The <url> tag contains a URI from which the customer /// can download the purchased content. /// </param> /// <param name="description"> /// The <description> tag contains instructions for downloading a digital /// content item. Please use the <item-description> tag to provide /// the description of the item being purchased. /// </param> /// <remarks>Either the Key or the Url is required. /// You may pass in null or String.Empty into one of the two parameters.</remarks> public DigitalItem(string key, string url, string description) { key = EncodeHelper.CleanString(key); url = EncodeHelper.CleanString(url); //either can be set, we don't care which one. if (key.Length == 0 && url.Length == 0) throw new ArgumentNullException(MISSING_KEY_OR_URL); _key = key; _url = url; SetDescription(description); }