コード例 #1
0
        /// <summary>
        /// Gets the text value of an object.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>A formatted text representation of the value.</returns>
        /// <remarks>DateValue is formatted in yyyy-mm-dd format. DateTimeValue is
        /// formatted in yyyy-mm-dd HH:mm:ss Z format.</remarks>
        private static string getTextValue(Object value)
        {
            if (value == null)
            {
                return("");
            }

            if (value is DateValue)
            {
                Google.Api.Ads.Dfp.v201405.DateValue dateValue =
                    (Google.Api.Ads.Dfp.v201405.DateValue)value;
                return(string.Format("{0:0000}-{1:00}-{2:00}", dateValue.value.year, dateValue.value.month,
                                     dateValue.value.day));
            }
            else if (value is DateTimeValue)
            {
                Google.Api.Ads.Dfp.v201405.DateTimeValue dateTimeValue =
                    (Google.Api.Ads.Dfp.v201405.DateTimeValue)value;
                return(string.Format("{0:0000}-{1:00}-{2:00}T{3:00}:{4:00}:{5:00} {6}",
                                     dateTimeValue.value.date.year, dateTimeValue.value.date.month,
                                     dateTimeValue.value.date.day, dateTimeValue.value.hour,
                                     dateTimeValue.value.minute, dateTimeValue.value.second,
                                     dateTimeValue.value.timeZoneID));
            }
            else
            {
                // NumberValue, BooleanValue, TextValue
                return(value.ToString());
            }
        }
コード例 #2
0
 /// <summary>
 /// Adds a new Date value to the list of query parameters.
 /// </summary>
 /// <param name="key">The parameter name.</param>
 /// <param name="value">The parameter value.</param>
 /// <returns>The statement builder, for chaining method calls.</returns>
 public StatementBuilder AddValue(string key, Date value) {
   DateValue queryValue = new DateValue();
   queryValue.value = value;
   return AddValue(key, queryValue);
 }