Example #1
0
        public override Frame Clone()
        {
            TermsOfUseFrame frame = new TermsOfUseFrame(language, encoding);

            frame.text = text;
            return(frame);
        }
        /// <summary>
        ///    Gets a specified terms of use frame from the specified
        ///    tag, trying to to match the language but accepting one
        ///    with a different language if a match was not found.
        /// </summary>
        /// <param name="tag">
        ///    A <see cref="Tag" /> object to search in.
        /// </param>
        /// <param name="language">
        ///    A <see cref="string" /> specifying the ISO-639-2 language
        ///   code to match.
        /// </param>
        /// <returns>
        ///    A <see cref="TermsOfUseFrame" /> object containing the
        ///    matching frame, or <see langword="null" /> if a match
        ///    wasn't found.
        /// </returns>
        public static TermsOfUseFrame GetPreferred(Tag tag,
                                                   string language)
        {
            TermsOfUseFrame best = null;

            foreach (Frame f in tag.GetFrames(FrameType.USER))
            {
                TermsOfUseFrame cf = f as TermsOfUseFrame;
                if (cf == null)
                {
                    continue;
                }

                if (cf.Language == language)
                {
                    return(cf);
                }

                if (best == null)
                {
                    best = cf;
                }
            }

            return(best);
        }
 public static TermsOfUseFrame Get(TagLib.Id3v2.Tag tag, string language, bool create)
 {
     IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.USER).GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             Frame current = enumerator.Current;
             TermsOfUseFrame frame2 = current as TermsOfUseFrame;
             if ((frame2 != null) && ((language == null) || (language == frame2.Language)))
             {
                 return frame2;
             }
         }
     }
     finally
     {
         if (enumerator == null)
         {
         }
         enumerator.Dispose();
     }
     if (!create)
     {
         return null;
     }
     TermsOfUseFrame frame3 = new TermsOfUseFrame(language);
     tag.AddFrame(frame3);
     return frame3;
 }
Example #4
0
        public static TermsOfUseFrame Get(Tag tag, string language, bool create)
        {
            foreach (Frame f in tag.GetFrames(FrameType.USER))
            {
                TermsOfUseFrame cf = f as TermsOfUseFrame;
                if (cf != null && (language == null || language == cf.Language))
                {
                    return(cf);
                }
            }
            if (!create)
            {
                return(null);
            }
            TermsOfUseFrame frame = new TermsOfUseFrame(language);

            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 ()
		{
			TermsOfUseFrame frame = new TermsOfUseFrame (language, encoding);
			frame.text = text;
			return frame;
		}
		/// <summary>
		///    Gets a specified terms of use 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="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="TermsOfUseFrame" /> 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 TermsOfUseFrame Get (Tag tag, string language,
		                                   bool create)
		{
			foreach (Frame f in tag.GetFrames (FrameType.USER)) {
				TermsOfUseFrame cf = f as TermsOfUseFrame;
				
				if (cf != null && (language == null ||
					language == cf.Language))
					return cf;
			}
			
			if (!create)
				return null;
			
			TermsOfUseFrame frame = new TermsOfUseFrame (language);
			tag.AddFrame (frame);
			return frame;
		}
Example #7
0
		public void TestTermsOfUseFrame ()
		{
			string lang = "ENG";
			TermsOfUseFrame frame = new TermsOfUseFrame (lang);
			frame.Text = val_sing;
			
			FrameTest (frame, 4,
				delegate (Frame f, StringType e) {
					(f as TermsOfUseFrame).TextEncoding = e;
				},
				
				delegate (ByteVector d, byte v) {
					return new TermsOfUseFrame (d, v);
				},
				
				delegate (Frame f, string m) {
					TermsOfUseFrame g = (f as TermsOfUseFrame);
					Assert.AreEqual (lang, g.Language, m);
					Assert.AreEqual (val_sing, g.Text, m);
				});
		}