This class extends TextInformationFrame to provide support for ID3v2 User Text Information (TXXX) Frames.
Inheritance: TextInformationFrame
Exemplo n.º 1
0
        private string GetUserTextAsString(string description, bool caseSensitive)
        {
            UserTextInformationFrame frame = UserTextInformationFrame.Get(this, description, Tag.DefaultEncoding, false, caseSensitive);
            string result = frame == null?null:string.Join(";", frame.Text);

            return(string.IsNullOrEmpty(result)?null:result);
        }
Exemplo n.º 2
0
        public static UserTextInformationFrame Get(Tag tag, string description, StringType type, bool create, bool caseSensitive)
        {
            if (tag == null)
            {
                throw new ArgumentNullException("tag");
            }
            if (description == null)
            {
                throw new ArgumentNullException("description");
            }
            if (description.Length == 0)
            {
                throw new ArgumentException("Description must not be empty.", "description");
            }
            StringComparison stringComparison = caseSensitive?StringComparison.InvariantCulture:StringComparison.InvariantCultureIgnoreCase;

            foreach (UserTextInformationFrame frame in tag.GetFrames <UserTextInformationFrame>(FrameType.TXXX))
            {
                if (description.Equals(frame.Description, stringComparison))
                {
                    return(frame);
                }
            }
            if (!create)
            {
                return(null);
            }
            UserTextInformationFrame new_frame = new UserTextInformationFrame(description, type);

            tag.AddFrame(new_frame);
            return(new_frame);
        }
Exemplo n.º 3
0
        private void SetUserTextAsString(string description, string text, bool caseSensitive)
        {
            UserTextInformationFrame frame = UserTextInformationFrame.Get(this, description, Tag.DefaultEncoding, true, caseSensitive);

            if (!string.IsNullOrEmpty(text))
            {
                frame.Text = text.Split(';');
            }
            else
            {
                RemoveFrame(frame);
            }
        }
 public static UserTextInformationFrame Get(TagLib.Id3v2.Tag tag, string description, StringType type, bool create)
 {
     if (tag == null)
     {
         throw new ArgumentNullException("tag");
     }
     if (description == null)
     {
         throw new ArgumentNullException("description");
     }
     if (description.Length == 0)
     {
         throw new ArgumentException("Description must not be empty.", "description");
     }
     IEnumerator<UserTextInformationFrame> enumerator = tag.GetFrames<UserTextInformationFrame>(FrameType.TXXX).GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             UserTextInformationFrame current = enumerator.Current;
             if (description.Equals(current.Description))
             {
                 return current;
             }
         }
     }
     finally
     {
         if (enumerator == null)
         {
         }
         enumerator.Dispose();
     }
     if (!create)
     {
         return null;
     }
     UserTextInformationFrame frame2 = new UserTextInformationFrame(description, type);
     tag.AddFrame(frame2);
     return frame2;
 }
		public static UserTextInformationFrame Get (Tag tag,
		                                            string description,
		                                            StringType type,
		                                            bool create)
		{
			if (tag == null)
				throw new ArgumentNullException ("tag");
			
			if (description == null)
				throw new ArgumentNullException ("description");
			
			if (description.Length == 0)
				throw new ArgumentException (
					"Description must not be empty.",
					"description");
			
			foreach (UserTextInformationFrame frame in
				tag.GetFrames<UserTextInformationFrame> (
					FrameType.TXXX))
				if (description.Equals (frame.Description))
					return frame;
			
			if (!create)
				return null;
			
			UserTextInformationFrame new_frame =
				new UserTextInformationFrame (description,
					type);
			tag.AddFrame (new_frame);
			return new_frame;
		}
Exemplo n.º 6
0
		public void TestUserTextInformationFrame ()
		{
			UserTextInformationFrame frame = new UserTextInformationFrame (val_sing);
			frame.Text = val_mult;
			
			FrameTest (frame, 2,
				delegate (Frame f, StringType e) {
					(f as UserTextInformationFrame).TextEncoding = e;
				},
				
				delegate (ByteVector d, byte v) {
					return new UserTextInformationFrame (d, v);
				},
				
				delegate (Frame f, string m) {
					UserTextInformationFrame g = (f as UserTextInformationFrame);
					Assert.AreEqual (val_sing, g.Description, m);
					Assert.AreEqual (val_mult.Length, g.Text.Length, m);
					for (int i = 0; i < val_mult.Length; i ++) {
						Assert.AreEqual (val_mult [i], g.Text [i], m);
					}
				});
		}