Beispiel #1
0
        /// <summary>
        ///    Gets a specified unique file identifer 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="owner">
        ///    A <see cref="string" /> specifying the owner 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="UserTextInformationFrame" /> 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 UniqueFileIdentifierFrame Get(Tag tag,
                                                    string owner,
                                                    bool create)
        {
            UniqueFileIdentifierFrame ufid;

            foreach (Frame frame in tag.GetFrames(FrameType.UFID))
            {
                ufid = frame as UniqueFileIdentifierFrame;

                if (ufid == null)
                {
                    continue;
                }

                if (ufid.Owner == owner)
                {
                    return(ufid);
                }
            }

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

            ufid = new UniqueFileIdentifierFrame(owner, null);
            tag.AddFrame(ufid);
            return(ufid);
        }
Beispiel #2
0
        private string GetUfidText(string owner)
        {
            UniqueFileIdentifierFrame frame = UniqueFileIdentifierFrame.Get(this, owner, false);
            string result = frame == null?null:frame.Identifier.ToString();

            return(string.IsNullOrEmpty(result)?null:result);
        }
 public static UniqueFileIdentifierFrame Get(TagLib.Id3v2.Tag tag, string owner, bool create)
 {
     UniqueFileIdentifierFrame frame;
     IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.UFID).GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             Frame current = enumerator.Current;
             frame = current as UniqueFileIdentifierFrame;
             if ((frame != null) && (frame.Owner == owner))
             {
                 return frame;
             }
         }
     }
     finally
     {
         if (enumerator == null)
         {
         }
         enumerator.Dispose();
     }
     if (!create)
     {
         return null;
     }
     frame = new UniqueFileIdentifierFrame(owner, null);
     tag.AddFrame(frame);
     return frame;
 }
 public override Frame Clone()
 {
     UniqueFileIdentifierFrame frame = new UniqueFileIdentifierFrame(this.owner);
     if (this.identifier != null)
     {
         frame.identifier = new ByteVector(this.identifier);
     }
     return frame;
 }
Beispiel #5
0
        public override Frame Clone()
        {
            UniqueFileIdentifierFrame frame = new UniqueFileIdentifierFrame(owner);

            if (identifier != null)
            {
                frame.identifier = new ByteVector(identifier);
            }
            return(frame);
        }
        /// <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()
        {
            var frame = new UniqueFileIdentifierFrame(Owner);

            if (Identifier != null)
            {
                frame.Identifier = new ByteVector(Identifier);
            }
            return(frame);
        }
Beispiel #7
0
        private void SetUfidText(string owner, string text)
        {
            UniqueFileIdentifierFrame frame = UniqueFileIdentifierFrame.Get(this, owner, true);

            if (!string.IsNullOrEmpty(text))
            {
                ByteVector identifier = ByteVector.FromString(text, StringType.UTF8);
                frame.Identifier = identifier;
            }
            else
            {
                RemoveFrame(frame);
            }
        }
        public static UniqueFileIdentifierFrame Get(Tag tag, string owner, bool create)
        {
            foreach (Frame f in tag.GetFrames(FrameType.UFID))
            {
                if (f is UniqueFileIdentifierFrame && (f as UniqueFileIdentifierFrame).Owner == owner)
                {
                    return(f as UniqueFileIdentifierFrame);
                }
            }

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

            UniqueFileIdentifierFrame frame = new UniqueFileIdentifierFrame(owner, null);

            tag.AddFrame(frame);
            return(frame);
        }
		/// <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 ()
		{
			UniqueFileIdentifierFrame frame =
				new UniqueFileIdentifierFrame (owner);
			if (identifier != null)
				frame.identifier = new ByteVector (identifier);
			return frame;
		}
		/// <summary>
		///    Gets a specified unique file identifer 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="owner">
		///    A <see cref="string" /> specifying the owner 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="UserTextInformationFrame" /> 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 UniqueFileIdentifierFrame Get (Tag tag,
		                                             string owner,
		                                             bool create)
		{
			UniqueFileIdentifierFrame ufid;
			
			foreach (Frame frame in tag.GetFrames (FrameType.UFID)) {
				ufid = frame as UniqueFileIdentifierFrame;
				
				if (ufid == null)
					continue;
				
				if (ufid.Owner == owner)
					return ufid;
			}
			
			if (!create)
				return null;
			
			ufid = new UniqueFileIdentifierFrame (owner, null);
			tag.AddFrame (ufid);
			return ufid;
		}
Beispiel #11
0
		public void TestUniqueFileIdentifierFrame ()
		{
			ByteVector data = val_sing;
			data.Add (data); data.Add (data); data.Add (data);
			data.Add (data); data.Add (data); data.Add (data);
			data.Add (data); data.Add (data); data.Add (data);
			data.Add (data); data.Add (data); data.Add (data);
			// data.Add (data); data.Add (data); data.Add (data);
			
			UniqueFileIdentifierFrame frame = new UniqueFileIdentifierFrame (val_sing);
			frame.Identifier = data;
			
			FrameTest (frame, 2, null,
				delegate (ByteVector d, byte v) {
					return new UniqueFileIdentifierFrame (d, v);
				},
				
				delegate (Frame f, string m) {
					UniqueFileIdentifierFrame g = (f as UniqueFileIdentifierFrame);
					Assert.AreEqual (val_sing, g.Owner, m);
					Assert.AreEqual (data, g.Identifier, m);
				});
		}
 public static UniqueFileIdentifierFrame Get (Tag tag, string owner, bool create)
 {
    foreach (Frame f in tag.GetFrames (FrameType.UFID))
       if (f is UniqueFileIdentifierFrame && (f as UniqueFileIdentifierFrame).Owner == owner)
          return f as UniqueFileIdentifierFrame;
    
    if (!create) return null;
    
    UniqueFileIdentifierFrame frame = new UniqueFileIdentifierFrame (owner, null);
    tag.AddFrame (frame);
    return frame;
 }