コード例 #1
0
ファイル: UrlLinkFrame.cs プロジェクト: asimshah/Music
        /// <summary>
        ///    Creates a deep copy of the current instance.
        /// </summary>
        /// <returns>
        ///    A new <see cref="Frame" /> object identical to the
        ///    current instance.
        /// </returns>
        public override Frame Clone()
        {
            UrlLinkFrame frame =
                (this is UserUrlLinkFrame) ?
                new UserUrlLinkFrame(null, encoding) :
                new UrlLinkFrame(FrameId);

            frame.text_fields = (string[])text_fields.Clone();
            if (raw_data != null)
            {
                frame.raw_data = new ByteVector(raw_data);
            }
            frame.raw_version = raw_version;
            return(frame);
        }
コード例 #2
0
ファイル: UrlLinkFrame.cs プロジェクト: asimshah/Music
        /// <summary>
        ///    Gets a <see cref="UrlLinkFrame" /> object of a
        ///    specified type from a specified tag, optionally creating
        ///    and adding one with a specified encoding if none is
        ///    found.
        /// </summary>
        /// <param name="tag">
        ///    A <see cref="Tag" /> object to search for the specified
        ///    tag in.
        /// </param>
        /// <param name="ident">
        ///    A <see cref="ByteVector" /> object containing the frame
        ///    identifer to search for.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    create a new frame if an existing frame was not found.
        /// </param>
        /// <returns>
        ///    A <see cref="UrlLinkFrame" /> object containing
        ///    the frame found in or added to <paramref name="tag" /> or
        ///    <see langword="null" /> if no value was found
        ///    <paramref name="create" /> is <see langword="false" />.
        /// </returns>
        /// <remarks>
        ///    To create a frame without having to specify the encoding,
        ///    use <see cref="Get(Tag,ByteVector,bool)" />.
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        ///    <paramref name="tag" /> or <paramref name="type" /> is
        ///    <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///    <paramref name="ident" /> is not exactly four bytes long.
        /// </exception>
        public static UrlLinkFrame Get(Tag tag,
                                       ByteVector ident,
                                       bool create)
        {
            if (tag == null)
            {
                throw new ArgumentNullException("tag");
            }

            if (ident == null)
            {
                throw new ArgumentNullException("ident");
            }

            if (ident.Count != 4)
            {
                throw new ArgumentException(
                          "Identifier must be four bytes long.",
                          "ident");
            }

            foreach (UrlLinkFrame frame in
                     tag.GetFrames <UrlLinkFrame>(ident))
            {
                return(frame);
            }

            if (!create)
            {
                return(null);
            }

            UrlLinkFrame new_frame =
                new UrlLinkFrame(ident);

            tag.AddFrame(new_frame);
            return(new_frame);
        }