示例#1
0
        public override Frame Clone()
        {
            TextInformationFrame frame = new TextInformationFrame(
                FrameId, encoding);

            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
        public override ByteVector Render(byte version)
        {
            if (version != 3 || FrameId != FrameType.TDRC)
            {
                return(base.Render(version));
            }

            string text = ToString();

            if (text.Length < 10 || text [4] != '-' ||
                text [7] != '-')
            {
                return(base.Render(version));
            }

            ByteVector           output = new ByteVector();
            TextInformationFrame f;

            f      = new TextInformationFrame(FrameType.TYER, encoding);
            f.Text = new string [] { text.Substring(0, 4) };
            output.Add(f.Render(version));

            f      = new TextInformationFrame(FrameType.TDAT, encoding);
            f.Text = new string [] {
                text.Substring(5, 2) + text.Substring(8, 2)
            };
            output.Add(f.Render(version));

            if (text.Length < 16 || text [10] != 'T' ||
                text [13] != ':')
            {
                return(output);
            }

            f      = new TextInformationFrame(FrameType.TIME, encoding);
            f.Text = new string [] {
                text.Substring(11, 2) + text.Substring(14, 2)
            };
            output.Add(f.Render(version));

            return(output);
        }
示例#3
0
        /// <summary>
        ///    Gets a <see cref="TextInformationFrame" /> 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="encoding">
        ///    A <see cref="StringType" /> value specifying the encoding
        ///    to use if a new frame is created.
        /// </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="TextInformationFrame" /> object containing
        ///    the frame found in or added to <paramref name="tag" /> or
        ///    <see langref="null" /> if no value was found <paramref
        ///    name="create" /> is <see langref="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 langref="null" />.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///    <paramref name="type" /> is not exactly four bytes long.
        /// </exception>
        public static TextInformationFrame Get(Tag tag,
                                               ByteVector ident,
                                               StringType encoding,
                                               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 (TextInformationFrame frame in
                     tag.GetFrames <TextInformationFrame> (ident))
            {
                return(frame);
            }

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

            TextInformationFrame new_frame =
                new TextInformationFrame(ident, encoding);

            tag.AddFrame(new_frame);
            return(new_frame);
        }
		public override Frame Clone ()
		{
			TextInformationFrame frame = new TextInformationFrame (
				FrameId, encoding);
			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;
		}
		/// <summary>
		///    Gets a <see cref="TextInformationFrame" /> 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="encoding">
		///    A <see cref="StringType" /> value specifying the encoding
		///    to use if a new frame is created.
		/// </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="TextInformationFrame" /> object containing
		///    the frame found in or added to <paramref name="tag" /> or
		///    <see langref="null" /> if no value was found <paramref
		///    name="create" /> is <see langref="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 langref="null" />.
		/// </exception>
		/// <exception cref="ArgumentException">
		///    <paramref name="type" /> is not exactly four bytes long.
		/// </exception>
		public static TextInformationFrame Get (Tag tag,
		                                        ByteVector ident,
		                                        StringType encoding,
		                                        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 (TextInformationFrame frame in
				tag.GetFrames<TextInformationFrame> (ident))
				return frame;
			
			if (!create)
				return null;
			
			TextInformationFrame new_frame =
				new TextInformationFrame (ident, encoding);
			tag.AddFrame (new_frame);
			return new_frame;
		}
		public override ByteVector Render (byte version)
		{
			if (version != 3 || FrameId != FrameType.TDRC)
				return base.Render (version);
			
			string text = ToString ();
			if (text.Length < 10 || text [4] != '-' ||
				text [7] != '-')
				return base.Render (version);
			
			ByteVector output = new ByteVector ();
			TextInformationFrame f;
			
			f = new TextInformationFrame (FrameType.TYER, encoding);
			f.Text = new string [] {text.Substring (0, 4)};
			output.Add (f.Render (version));
			
			f = new TextInformationFrame (FrameType.TDAT, encoding);
			f.Text = new string [] {
				text.Substring (5, 2) + text.Substring (8, 2)
			};
			output.Add (f.Render (version));
			
			if (text.Length < 16 || text [10] != 'T' ||
				text [13] != ':')
				return output;
			
			f = new TextInformationFrame (FrameType.TIME, encoding);
			f.Text = new string [] {
				text.Substring (11, 2) + text.Substring (14, 2)
			};
			output.Add (f.Render (version));
			
			return output;
		}