示例#1
0
        /// <summary>
        /// Parse a campaign. </summary>
        /// <param name="campaignId"> already parsed campaign id. </param>
        /// <param name="values"> content data. </param>
        /// <exception cref="JSONException"> if payload parsing failure. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: EngagementReachContent(CampaignId campaignId, android.content.ContentValues values) throws org.json.JSONException
        internal EngagementReachContent(CampaignId campaignId, ContentValues values)
        {
            /* Parse base fields */
            mCampaignId = campaignId;
            mDlc        = values.getAsInteger(DLC);
            mDlcId      = values.getAsString(DLC_ID);
            mCategory   = values.getAsString(CATEGORY);
            long?expiry = values.getAsLong(TTL);

            if (expiry != null)
            {
                expiry *= 1000L;
                if (parseBoolean(values, USER_TIME_ZONE))
                {
                    expiry -= TimeZone.Default.getOffset(expiry);
                }
            }
            mExpiry = expiry;
            if (values.containsKey(PAYLOAD))
            {
                Payload = new JSONObject(values.getAsString(PAYLOAD));
            }
        }
	  /// <summary>
	  /// Parse a campaign. </summary>
	  /// <param name="campaignId"> already parsed campaign id. </param>
	  /// <param name="values"> content data. </param>
	  /// <exception cref="JSONException"> if payload parsing failure. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: EngagementReachContent(CampaignId campaignId, android.content.ContentValues values) throws org.json.JSONException
	  internal EngagementReachContent(CampaignId campaignId, ContentValues values)
	  {
		/* Parse base fields */
		mCampaignId = campaignId;
		mDlc = values.getAsInteger(DLC);
		mDlcId = values.getAsString(DLC_ID);
		mCategory = values.getAsString(CATEGORY);
		long? expiry = values.getAsLong(TTL);
		if (expiry != null)
		{
		  expiry *= 1000L;
		  if (parseBoolean(values, USER_TIME_ZONE))
		  {
			expiry -= TimeZone.Default.getOffset(expiry);
		  }
		}
		mExpiry = expiry;
		if (values.containsKey(PAYLOAD))
		{
		  Payload = new JSONObject(values.getAsString(PAYLOAD));
		}
	  }
	  /// <summary>
	  /// Parse boolean from content values. </summary>
	  /// <param name="values"> content values. </param>
	  /// <param name="key"> key. </param>
	  /// <returns> boolean value. </returns>
	  internal static bool parseBoolean(ContentValues values, string key)
	  {
		int? val = values.getAsInteger(key);
		return val != null && val == 1;
	  }
示例#4
0
        /// <summary>
        /// Parse boolean from content values. </summary>
        /// <param name="values"> content values. </param>
        /// <param name="key"> key. </param>
        /// <returns> boolean value. </returns>
        internal static bool parseBoolean(ContentValues values, string key)
        {
            int?val = values.getAsInteger(key);

            return(val != null && val == 1);
        }