public static CommentsFrame Get(TagLib.Id3v2.Tag tag, string description, string language, bool create)
 {
     CommentsFrame frame;
     IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.COMM).GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             Frame current = enumerator.Current;
             frame = current as CommentsFrame;
             if (((frame != null) && (frame.Description == description)) && ((language == null) || (language == frame.Language)))
             {
                 return frame;
             }
         }
     }
     finally
     {
         if (enumerator == null)
         {
         }
         enumerator.Dispose();
     }
     if (!create)
     {
         return null;
     }
     frame = new CommentsFrame(description, language);
     tag.AddFrame(frame);
     return frame;
 }
示例#2
0
		/// <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 ()
		{
			CommentsFrame frame = new CommentsFrame (description,
				language, encoding);
			frame.text = text;
			return frame;
		}
示例#3
0
		/// <summary>
		///    Gets a specified comments frame from the specified tag,
		///    optionally creating it if it does not exist.
		/// </summary>
		/// <param name="tag">
		///    A <see cref="Tag" /> object to search in.
		/// </param>
		/// <param name="description">
		///    A <see cref="string" /> specifying the description to
		///    match.
		/// </param>
		/// <param name="language">
		///    A <see cref="string" /> specifying the ISO-639-2 language
		///   code to match.
		/// </param>
		/// <param name="create">
		///    A <see cref="bool" /> specifying whether or not to create
		///    and add a new frame to the tag if a match is not found.
		/// </param>
		/// <returns>
		///    A <see cref="CommentsFrame" /> object containing the
		///    matching frame, or <see langword="null" /> if a match
		///    wasn't found and <paramref name="create" /> is <see
		///    langword="false" />.
		/// </returns>
		public static CommentsFrame Get (Tag tag, string description,
		                                 string language, bool create)
		{
			CommentsFrame comm;
			foreach (Frame frame in tag.GetFrames (FrameType.COMM)) {
				comm = frame as CommentsFrame;
				
				if (comm == null)
					continue;
				
				if (comm.Description != description)
					continue;
				
				if (language != null && language != comm.Language)
					continue;
				
				return comm;
			}
			
			if (!create)
				return null;
			
			comm = new CommentsFrame (description, language);
			tag.AddFrame (comm);
			return comm;
		}
示例#4
0
		public void TestCommentsFrame ()
		{
			string desc = "description";
			string lang = "ENG";
			CommentsFrame frame = new CommentsFrame (desc, lang);
			frame.Text = val_sing;
			
			FrameTest (frame, 2,
				delegate (Frame f, StringType e) {
					(f as CommentsFrame).TextEncoding = e;
				},
				
				delegate (ByteVector d, byte v) {
					return new CommentsFrame (d, v);
				},
				
				delegate (Frame f, string m) {
					CommentsFrame g = (f as CommentsFrame);
					Assert.AreEqual (desc, g.Description, m);
					Assert.AreEqual (lang, g.Language, m);
					Assert.AreEqual (val_sing, g.Text, m);
				});
		}
示例#5
0
		public void TestComment4Bytes ()
		{
			// Comment data found in the wild, see bgo#607376
			var data = new byte[] { 67, 79, 77, 77, 0, 0, 0, 4, 0, 0, 0, 203, 0, 255 };
			var frame = new CommentsFrame (data, 3);
			Assert.IsEmpty (frame.Description);
			Assert.IsEmpty (frame.Text);
		}