CopyTo() public method

Copies the values from the current instance to another TagLib.Tag, optionally overwriting existing values.

This method only copies the most basic values when copying between different tag formats, however, if target is of the same type as the current instance, more advanced copying may be done. For example, TagLib.Id3v2.Tag will copy all of its frames to another tag.

/// is . ///
public CopyTo ( Tag target, bool overwrite ) : void
target Tag /// A object containing the target tag to /// copy values to. ///
overwrite bool /// A specifying whether or not to copy /// values over existing one. ///
return void
Esempio n. 1
0
 public static void Duplicate(Tag source, Tag target, bool overwrite)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     source.CopyTo(target, overwrite);
 }
Esempio n. 2
0
		public Task WriteTags(CancellationToken ct, Stream stream, Tag tags)
		{
			Guard.ForNull(stream, nameof(stream));
			Guard.ForNull(tags, nameof(tags));
			return Task.Run(() =>
			{
				using (var fileAbstraction = new AlwaysOpenStreamFileAbstraction(_witnessFilename, stream))
				using (var file = TagLib.File.Create(fileAbstraction))
                {
					var fileTags = file.GetTag(_tagTypes, true);
					fileTags.Clear();
					tags.CopyTo(fileTags, true);
					fileTags.Pictures = tags.Pictures;
					file.Save();
				}
			});
		}
Esempio n. 3
0
        private static void CopyTags(Tag source, Tag target)
        {
            source.CopyTo(target, true);
            var l = source.Pictures.Length;
            var pictures = new IPicture[l];
            for (var i = 0; i < source.Pictures.Length; i++)
            {
                pictures[i] = new Picture(source.Pictures[i].Data)
                                  {
                                      MimeType = source.Pictures[i].MimeType,
                                      Description = source.Pictures[i].Description,
                                      Type = source.Pictures[i].Type
                                  };
            }

            target.Pictures = pictures;
        }
Esempio n. 4
0
 public XiphComment GetComment(bool create, Tag copy)
 {
     foreach (Tag tag in this.Tags)
     {
         if (tag is XiphComment)
         {
             return (tag as XiphComment);
         }
     }
     if (!create)
     {
         return null;
     }
     XiphComment target = new XiphComment();
     if (copy != null)
     {
         copy.CopyTo(target, true);
     }
     base.AddTag(target);
     return target;
 }
Esempio n. 5
0
		public static void Duplicate (Tag source, Tag target,
		                              bool overwrite)
		{
			if (source == null)
				throw new ArgumentNullException ("source");
			
			if (target == null)
				throw new ArgumentNullException ("target");
			
			source.CopyTo (target, overwrite);
		}