コード例 #1
0
        /// <summary>
        /// Serializes the <see cref="BrightcoveAudioTrackPlaylist"/>. Note that the <see cref="AudioTracks"/> property is not serialized with the rest of the other properties as the <see cref="AudioTrackIds"/> properties is instead used by Brightcove.
        /// </summary>
        /// <param name="serializer">The serializer.</param>
        /// <returns>
        /// A serialized <see cref="IDictionary{String,Object}" />.
        /// </returns>
        public IDictionary <string, object> Serialize(JavaScriptSerializer serializer)
        {
            IDictionary <string, object> serialized = new Dictionary <string, object>();

            serialized["filterTags"]       = FilterTags;
            serialized["name"]             = Name;
            serialized["playlistType"]     = PlaylistType.ToBrightcoveName();
            serialized["referenceId"]      = ReferenceId;
            serialized["shortDescription"] = ShortDescription;
            serialized["thumbnailURL"]     = ThumbnailUrl;

            // The Id must be non-0.
            if (Id != 0)
            {
                serialized["id"] = Id;
            }

            // Smart playlists (i.e. anything but an Explicit playlist) should not have the VideoIds
            // populated, as 1) Brightcove determines which video Ids belong in a smart playlist, and
            // 2) serializing this property for a smart playlists results in an error.
            //
            // It is still the case that you cannot switch from a smart playlist to an explicit playlist,
            // and attempting to do so will result in an error. A workaround in this case is detailed @
            // https://github.com/BrightcoveOS/.NET-MAPI-Wrapper/wiki/Known-Issues#wiki-convert-smart-playlist-to-explicit.
            if (PlaylistType == PlaylistType.Explicit && AudioTrackIds != null && AudioTrackIds.Any())
            {
                serialized["audioTrackIds"] = AudioTrackIds;
            }

            return(serialized);
        }
コード例 #2
0
        /// <summary>
        /// Serializes the <see cref="BrightcovePlaylist"/>. Note that the <see cref="Videos"/> property is not serialized with the rest of the other properties as the <see cref="VideoIds"/> properties is instead used by Brightcove.
        /// </summary>
        /// <param name="serializer">The serializer.</param>
        /// <returns>A serialized <see cref="IDictionary{String,Object}" />.</returns>
        public IDictionary <string, object> Serialize(JavaScriptSerializer serializer)
        {
            IDictionary <string, object> serialized = new Dictionary <string, object>();

            serialized["filterTags"]       = FilterTags;
            serialized["name"]             = Name;
            serialized["playlistType"]     = PlaylistType.ToBrightcoveName();
            serialized["referenceId"]      = ReferenceId;
            serialized["shortDescription"] = ShortDescription;
            serialized["thumbnailURL"]     = ThumbnailUrl;

            // The Id must be non-0.
            if (Id != 0)
            {
                serialized["id"] = Id;
            }

            // If TagInclusionRule is set to None, then we won't serialize the value back to Brightcove.
            // In this case, whatever the value of TagInclusionRule was before the call will remain the
            // same. In the event of a Create call, it will be set to Or. In the event of an Update, the
            // returned playlist will contain the actual value of the TagInclusionRule, though it is not
            // accessible via a GET request (i.e. FindAll, FindById, etc.).
            if (TagInclusionRule != TagInclusionRule.None)
            {
                serialized["tagInclusionRule"] = TagInclusionRule.ToBrightcoveName();
            }

            // Smart playlists (i.e. anything but an Explicit playlist) should not have the VideoIds
            // populated, as 1) Brightcove determines which video Ids belong in a smart playlist, and
            // 2) serializing this property for a smart playlists results in an error.
            //
            // It is still the case that you cannot switch from a smart playlist to an explicit playlist,
            // and attempting to do so will result in an error. A workaround in this case is detailed @
            // https://github.com/BrightcoveOS/.NET-MAPI-Wrapper/wiki/Known-Issues#wiki-convert-smart-playlist-to-explicit.
            if (PlaylistType == PlaylistType.Explicit && VideoIds != null && VideoIds.Any())
            {
                serialized["videoIds"] = VideoIds;
            }

            return(serialized);
        }