public static string ToUnixTime(this DateTime value) { return(BCObject.DateToUnix(value)); }
private static string ToJSON(this BCVideo video, JSONType type) { //--Build Video in JSON -------------------------------------// Builder jsonVideo = new Builder(",", "{", "}"); //id if (type.Equals(JSONType.Update)) { jsonVideo.AppendObject("id", video.id); } //referenceId if (!string.IsNullOrEmpty(video.referenceId)) { jsonVideo.AppendField("referenceId", video.referenceId); } //name if (!string.IsNullOrEmpty(video.name)) { jsonVideo.AppendField("name", video.name); } //shortDescription if (!string.IsNullOrEmpty(video.shortDescription)) { jsonVideo.AppendField("shortDescription", video.shortDescription); } //longDescription if (!string.IsNullOrEmpty(video.longDescription)) { jsonVideo.AppendField("longDescription", video.longDescription); } //Tags should be a list of strings if (video.tags.Count > 0) { jsonVideo.AppendStringArray("tags", video.tags); } //videoStillURL if (!string.IsNullOrEmpty(video.videoStillURL)) { jsonVideo.AppendField("videoStillURL", HttpUtility.UrlEncode(video.videoStillURL)); } //thumbnailURL if (!string.IsNullOrEmpty(video.thumbnailURL)) { jsonVideo.AppendField("thumbnailURL", HttpUtility.UrlEncode(video.thumbnailURL)); } if (video.cuePoints.Count > 0) { jsonVideo.AppendObject("cuePoints", video.cuePoints.ToJSON()); } if (video.renditions.Count > 0) { jsonVideo.AppendObject("renditions", video.renditions.ToJSON()); } if (!string.IsNullOrEmpty(video.videoFullLength.url) || !string.IsNullOrEmpty(video.videoFullLength.remoteUrl)) { jsonVideo.AppendObject("videoFullLength", video.videoFullLength.ToJSON()); } if (video.customFields.Values.Count > 0) { jsonVideo.AppendDictionaryArray("customFields", video.customFields.Values); } //startdate if (video.startDate != null) { jsonVideo.AppendField("startDate", BCObject.DateToUnix(video.startDate.Value)); } //enddate if (video.endDate != null) { jsonVideo.AppendField("endDate", BCObject.DateToUnix(video.endDate.Value)); } //economics jsonVideo.AppendObject("economics", video.economics.ToString()); if (video.iosRenditions.Count > 0) { jsonVideo.AppendObject("iosRenditions", video.iosRenditions.ToJSON()); } //remoteURL if (!string.IsNullOrEmpty(video.HLSURL)) { jsonVideo.AppendField("HLSURL", HttpUtility.UrlEncode(video.HLSURL)); } //adKeys if (!string.IsNullOrEmpty(video.adKeys)) { jsonVideo.AppendField("adKeys", HttpUtility.UrlEncode(video.adKeys)); } return(jsonVideo.ToString()); }