コード例 #1
0
ファイル: FlacTagReader.cs プロジェクト: Galad/musicmirror
		public TagLibReaderWriterBase(
			string witnessFileName,
			TagTypes tagTypes)
		{
			_witnessFilename = Guard.ForNullOrWhiteSpace(witnessFileName, nameof(witnessFileName));
			_tagTypes = tagTypes;
		}
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public override void Parse(Stream input, TagTypes caller)
        {
            BinaryReader br = new BinaryReader(input);

            this._fillStyleCount = br.ReadByte();

            if (this._fillStyleCount.Equals(0xFF))
            {
                this._fillStyleCountExtended = br.ReadUInt16();

                this._fillStyles = new MorphFillStyle[this._fillStyleCountExtended];

                for (UInt16 i = 0; i < this._fillStyleCountExtended; i++)
                {
                    MorphFillStyle temp = new MorphFillStyle(this._SwfVersion);
                    temp.Parse(input);
                    this._fillStyles[i] = temp;
                }
            }
            else
            {
                this._fillStyles = new MorphFillStyle[this._fillStyleCount];

                for (byte i = 0; i < this._fillStyleCount; i++)
                {
                    MorphFillStyle temp = new MorphFillStyle(this._SwfVersion);
                    temp.Parse(input);
                    this._fillStyles[i] = temp;
                }
            }
        }
コード例 #3
0
 public TagLib.Tag AddTag(TagTypes type, TagLib.Tag copy)
 {
     TagLib.Tag target = null;
     if (type == (TagTypes.None | TagTypes.Id3v1))
     {
         target = new TagLib.Id3v1.Tag();
     }
     else if (type == (TagTypes.None | TagTypes.Id3v2))
     {
         TagLib.Id3v2.Tag tag2;
         target = new TagLib.Id3v2.Tag {
             Version = 4,
             Flags = (byte) (tag2.Flags | HeaderFlags.FooterPresent)
         };
     }
     else if (type == (TagTypes.None | TagTypes.Ape))
     {
         target = new TagLib.Ape.Tag();
     }
     if (target != null)
     {
         if (copy != null)
         {
             copy.CopyTo(target, true);
         }
         if (type == (TagTypes.None | TagTypes.Id3v1))
         {
             base.AddTag(target);
             return target;
         }
         base.InsertTag(0, target);
     }
     return target;
 }
コード例 #4
0
ファイル: FILLSTYLE.cs プロジェクト: rtezli/Blitzableiter
 /// <summary>
 /// The way how object like lines and shapes get filled.
 /// </summary>
 /// <param name="InitialVersion">The version of the Swf file using this object.</param>
 public FillStyle(byte InitialVersion)
     : base(InitialVersion)
 {
     this._color = new Rgb(this._SwfVersion);
     this._gradientMatrix = new Matrix(this._SwfVersion);
     this._gradient = new Gradient(this._SwfVersion);
     this._bitmapMatrix = new Matrix(this._SwfVersion);
     this._caller = TagTypes.DefineShape;
 }
コード例 #5
0
ファイル: File.cs プロジェクト: Lolle2000la/Aurora.Music
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagLib.Tag tag = null;

            switch (type)
            {
            case TagTypes.Id3v2:
                if (id32_tag == null && create)
                {
                    id32_tag         = new Id3v2.Tag();
                    id32_tag.Version = 4;
                    id32_tag.Flags  |= Id3v2.HeaderFlags
                                       .FooterPresent;
                    this.tag.CopyTo(id32_tag, true);
                }

                tag = id32_tag;
                break;

            case TagTypes.RiffInfo:
                if (info_tag == null && create)
                {
                    info_tag = new InfoTag();
                    this.tag.CopyTo(info_tag, true);
                }

                tag = info_tag;
                break;

            case TagTypes.MovieId:
                if (mid_tag == null && create)
                {
                    mid_tag = new MovieIdTag();
                    this.tag.CopyTo(mid_tag, true);
                }

                tag = mid_tag;
                break;

            case TagTypes.DivX:
                if (divx_tag == null && create)
                {
                    divx_tag = new DivXTag();
                    this.tag.CopyTo(divx_tag, true);
                }

                tag = divx_tag;
                break;
            }

            this.tag.SetTags(id32_tag, info_tag, mid_tag, divx_tag);
            return(tag);
        }
コード例 #6
0
		// Get the Apple Tag.
		public override TagLib.Tag FindTag(TagTypes type, bool create)
		{
			if (type == TagTypes.Apple)
			{
				if (tag == null && create)
					tag = new Mpeg4AppleTag(this);

				return tag;
			}

			return null;
		}
コード例 #7
0
ファイル: File.cs プロジェクト: windygu/alexandrialibrary
        /// <summary>
        ///    Removes a set of tag types from the current instance.
        /// </summary>
        /// <param name="types">
        ///    A bitwise combined <see cref="TagLib.TagTypes" /> value
        ///    containing tag types to be removed from the file.
        /// </param>
        /// <remarks>
        ///    In order to remove all tags from a file, pass <see
        ///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
        /// </remarks>
        public override void RemoveTags(TagTypes types)
        {
            if ((types & TagTypes.Apple) != TagTypes.Apple ||
                apple_tag == null)
            {
                return;
            }

            apple_tag.DetachIlst();
            apple_tag = null;
            tag.SetTags();
        }
コード例 #8
0
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override Tag GetTag(TagTypes type, bool create)
        {
            if (type == TagTypes.Xiph)
            {
                foreach (var comment in tag.Comments)
                {
                    return(comment);
                }
            }

            return(null);
        }
コード例 #9
0
ファイル: StartTag.cs プロジェクト: git-thinh/MediaPortal-2
        /// <summary>
        ///    Removes a set of tag types from the current instance.
        /// </summary>
        /// <param name="types">
        ///    A bitwise combined <see cref="TagLib.TagTypes" /> value
        ///    containing tag types to be removed from the file.
        /// </param>
        /// <remarks>
        ///    In order to remove all tags from a file, pass <see
        ///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
        /// </remarks>
        public void RemoveTags(TagTypes types)
        {
            for (int i = Tags.Length - 1; i >= 0; i--)
            {
                TagLib.Tag t = Tags[i];
                if ((t.TagTypes & types) != t.TagTypes && types != TagTypes.AllTags)
                {
                    continue;
                }

                RemoveTag(t);
            }
        }
コード例 #10
0
ファイル: MpcFile.cs プロジェクト: bossaia/alexandrialibrary
		private Tag FindMpcTag(TagTypes type, bool create)
		{
			switch (type)
			{
				case TagTypes.Id3v2:
					{
						if (create && id3v2Tag == null)
						{
							id3v2Tag = new Id3v2Tag();

							if (tag != null)
								TagLib.Tag.Duplicate(tag, id3v2Tag, true);

							tag.SetTags(apeTag, id3v2Tag, id3v1Tag);
						}
						return id3v2Tag;
					}

				case TagTypes.Id3v1:
					{
						if (create && id3v1Tag == null)
						{
							id3v1Tag = new Id3v1Tag();

							if (tag != null)
								TagLib.Tag.Duplicate(tag, id3v1Tag, true);

							tag.SetTags(apeTag, id3v2Tag, id3v1Tag);
						}
						return id3v1Tag;
					}

				case TagTypes.Ape:
					{
						if (create && apeTag == null)
						{
							apeTag = new ApeTag();

							if (tag != null)
								TagLib.Tag.Duplicate(tag, apeTag, true);

							tag.SetTags(apeTag, id3v2Tag, id3v1Tag);
						}
						return apeTag;
					}

				default:
					return null;
			}
		}
コード例 #11
0
 public override TagLib.Tag GetTag(TagTypes type, bool create)
 {
     TagLib.Tag tag = null;
     if (type != (TagTypes.None | TagTypes.Id3v2))
     {
         return tag;
     }
     if ((this.tag == null) && create)
     {
         this.tag = new TagLib.Id3v2.Tag();
         this.tag.Version = 2;
     }
     return this.tag;
 }
コード例 #12
0
        // Get the Apple Tag.
        public override TagLib.Tag FindTag(TagTypes type, bool create)
        {
            if (type == TagTypes.Apple)
            {
                if (tag == null && create)
                {
                    tag = new Mpeg4AppleTag(this);
                }

                return(tag);
            }

            return(null);
        }
コード例 #13
0
        private static async Task <PartProgress> ProcessMetas(string connectionString, string tagIdName, string tableName, string retentionPolicy,
                                                              string measurement, TagTypes tagType, string defaultTime, bool doAdHocResampling, bool skipLastPoint, int period, List <TsMetadata> metas, int batchSize, int parallelism,
                                                              InfluxQueryExecutor influxQueryExecutor, EntityCreator entityCreator, int previouslyProcessedTags, string statusMessage, int count, int totalCount, TraceWriter log)
        {
            var progress = new PartProgress();

            if (metas.Count == 0)
            {
                return(progress);
            }

            var batchBuilder = new StringBuilder();

            var entities = await LoadEntities(retentionPolicy, measurement, tagType, defaultTime, doAdHocResampling, skipLastPoint, period,
                                              metas, batchBuilder, batchSize, parallelism, progress, influxQueryExecutor, entityCreator, log);

            while (progress.Skip < metas.Count || entities.Count > 0)
            {
                Task bulkInsertTask = Task.CompletedTask;

                if (entities.Count > 0)
                {
                    log.Info($"Entities Created: {entities.Count}");
                    progress.ProcessedPoints += entities.Count;

                    bulkInsertTask = Timer.Time(() => SqlBulkInserter.BulkInsert(connectionString, entities, tagIdName, tableName), $"Bulk insert of {entities.Count}", log);
                }
                else
                {
                    log.Info($"No Entities Found.");
                }

                Task <List <TS> > entitiesTask = Task.FromResult(new List <TS>());

                if (progress.Skip < metas.Count)
                {
                    entitiesTask = LoadEntities(retentionPolicy, measurement, tagType, defaultTime, doAdHocResampling, skipLastPoint, period,
                                                metas, batchBuilder, batchSize, parallelism, progress, influxQueryExecutor, entityCreator, log);
                }

                await Task.WhenAll(bulkInsertTask, entitiesTask);

                entities = entitiesTask.Result;

                log.Info($"{progress.ProcessedTags}/{count} processed of {statusMessage}.");
                log.Info($"{progress.ProcessedTags + previouslyProcessedTags}/{totalCount} processed of total.");
            }

            return(progress);
        }
コード例 #14
0
        /// <summary>
        ///    Removes a set of tag types from the current instance.
        /// </summary>
        /// <param name="types">
        ///    A bitwise combined <see cref="TagLib.TagTypes" /> value
        ///    containing tag types to be removed from the file.
        /// </param>
        /// <remarks>
        ///    In order to remove all tags from a file, pass <see
        ///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
        /// </remarks>
        public override void RemoveTags(TagTypes types)
        {
            if ((types & TagTypes.Xiph) != 0)
            {
                metadata.RemoveComment();
            }

            if ((types & TagTypes.FlacMetadata) != 0)
            {
                metadata.Clear();
            }

            base.RemoveTags(types);
        }
コード例 #15
0
        public void Remove(TagTypes types)
        {
            if ((types & TagTypes.Id3v1) != 0)
            {
                id3v1Tag = null;
            }

            if ((types & TagTypes.Ape) != 0)
            {
                apeTag = null;
            }

            tag.SetTags(apeTag, id3v1Tag);
        }
コード例 #16
0
 public override TagLib.Tag GetTag(TagTypes type, bool create)
 {
     if (type != TagTypes.Apple)
     {
         return null;
     }
     if ((this.apple_tag == null) && create)
     {
         this.apple_tag = new AppleTag(this.udta_box);
         TagLib.Tag[] tags = new TagLib.Tag[] { this.apple_tag };
         this.tag.SetTags(tags);
     }
     return this.apple_tag;
 }
コード例 #17
0
ファイル: File.cs プロジェクト: JayDown/taglib-sharp
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override Tag GetTag(TagTypes type,
                                   bool create)
        {
            foreach (Tag tag in ImageTag.AllTags)
            {
                if ((tag.TagTypes & type) == type)
                {
                    return(tag);
                }
            }

            if (!create || (type & ImageTag.AllowedTypes) == 0)
            {
                return(null);
            }

            ImageTag new_tag = null;

            switch (type)
            {
            case TagTypes.JpegComment:
                new_tag = new JpegCommentTag();
                break;

            case TagTypes.GifComment:
                new_tag = new GifCommentTag();
                break;

            case TagTypes.Png:
                new_tag = new PngTag();
                break;

            case TagTypes.TiffIFD:
                new_tag = new IFDTag();
                break;

            case TagTypes.XMP:
                new_tag = new XmpTag();
                break;
            }

            if (new_tag != null)
            {
                ImageTag.AddTag(new_tag);
                return(new_tag);
            }

            throw new NotImplementedException($"Adding tag of type {type} not supported!");
        }
コード例 #18
0
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        /// <remarks>
        ///    At the time of this writing, only <see cref="AppleTag" />
        ///    is supported. All other tag types will be ignored.
        /// </remarks>
        public override Tag GetTag(TagTypes type, bool create)
        {
            if (type == TagTypes.Apple)
            {
                if (apple_tag == null && create)
                {
                    apple_tag = new AppleTag(udta_box);
                    tag.SetTags(apple_tag);
                }

                return(apple_tag);
            }

            return(null);
        }
コード例 #19
0
 public ActionResult EditTagType(TagTypes type)
 {
     if (type != null)
     {
         var tagType = _context.TagTypes.Where(x => x.Id == type.Id).FirstOrDefault();
         if (tagType != null)
         {
             tagType.TagType    = type.TagType;
             tagType.fk_Project = type.fk_Project;
             _context.SaveChanges();
         }
     }
     ViewBag.Project = _context.Projects.ToList();
     return(View());
 }
コード例 #20
0
 public override TagLib.Tag GetTag(TagTypes type, bool create)
 {
     TagLib.Tag id32_tag = null;
     switch (type)
     {
     case TagTypes.Id3v2:
         if (tag == null && create)
         {
             tag         = new Id3v2.Tag();
             tag.Version = 2;
         }
         id32_tag = tag;
         break;
     }
     return(id32_tag);
 }
コード例 #21
0
        public override TagLib.Tag FindTag(TagTypes type, bool create)
        {
            if (type == TagTypes.Xiph)
            {
                if (comment == null && create)
                {
                    comment = new OggXiphComment();
                }

                return(comment);
            }
            else
            {
                return(null);
            }
        }
コード例 #22
0
ファイル: GRADRECORD.cs プロジェクト: rtezli/Blitzableiter
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public void Parse( Stream input, TagTypes caller )
        {
            BinaryReader br = new BinaryReader(input);
            this._ratio = br.ReadByte();

            if (caller.Equals(TagTypes.DefineShape3) || caller.Equals(TagTypes.DefineShape4))
            {
                this._color = new Rgba(this._SwfVersion);
                this._color.Parse(input);
            }
            else
            {
                this._color = new Rgb(this._SwfVersion);
                this._color.Parse(input);
            }
        }
コード例 #23
0
        public void Load(EndianBinaryReader reader)
        {
            TagType   = (TagTypes)reader.ReadByte();
            Length    = reader.ReadBytes(3);
            TimeStamp = reader.ReadBytes(4);
            StreamId  = reader.ReadBytes(3);
            Data      = reader.ReadBytes((int)LengthValue);

            //BECAUSE SOMEONE AT ADOBE THOUGHT IT'D BE A GRAND IDEA TO DO MIXED ENDIAN
            //( ͡° ͜ʖ ͡°) comic saaaanssss, comic saaaaaaaaaaaaaaaanssssssss
            TimeStampNormal    = new byte[TimeStamp.Length];
            TimeStampNormal[0] = TimeStamp[3];
            TimeStampNormal[1] = TimeStamp[0];
            TimeStampNormal[2] = TimeStamp[1];
            TimeStampNormal[3] = TimeStamp[2];
        }
コード例 #24
0
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagLib.Tag tag = null;
            switch (type)
            {
                case (TagTypes.None | TagTypes.Id3v2):
                    if ((this.id32_tag == null) && create)
                    {
                        this.id32_tag = new TagLib.Id3v2.Tag();
                        this.id32_tag.Version = 4;
                        this.id32_tag.Flags = (HeaderFlags) ((byte) (this.id32_tag.Flags | HeaderFlags.FooterPresent));
                        this.tag.CopyTo(this.id32_tag, true);
                    }
                    tag = this.id32_tag;
                    break;

                case TagTypes.RiffInfo:
                    if ((this.info_tag == null) && create)
                    {
                        this.info_tag = new InfoTag();
                        this.tag.CopyTo(this.info_tag, true);
                    }
                    tag = this.info_tag;
                    break;

                case TagTypes.MovieId:
                    if ((this.mid_tag == null) && create)
                    {
                        this.mid_tag = new MovieIdTag();
                        this.tag.CopyTo(this.mid_tag, true);
                    }
                    tag = this.mid_tag;
                    break;

                case TagTypes.DivX:
                    if ((this.divx_tag == null) && create)
                    {
                        this.divx_tag = new DivXTag();
                        this.tag.CopyTo(this.divx_tag, true);
                    }
                    tag = this.divx_tag;
                    break;
            }
            TagLib.Tag[] tags = new TagLib.Tag[] { this.id32_tag, this.info_tag, this.mid_tag, this.divx_tag };
            this.tag.SetTags(tags);
            return tag;
        }
コード例 #25
0
ファイル: File.cs プロジェクト: JayDown/taglib-sharp
        /// <summary>
        ///    Removes a set of tag types from the current instance.
        /// </summary>
        /// <param name="types">
        ///    A bitwise combined <see cref="TagLib.TagTypes" /> value
        ///    containing tag types to be removed from the file.
        /// </param>
        /// <remarks>
        ///    In order to remove all tags from a file, pass <see
        ///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
        /// </remarks>
        public override void RemoveTags(TagTypes types)
        {
            List <ImageTag> to_delete = new List <ImageTag> ();

            foreach (ImageTag tag in ImageTag.AllTags)
            {
                if ((tag.TagTypes & types) == tag.TagTypes)
                {
                    to_delete.Add(tag);
                }
            }

            foreach (ImageTag tag in to_delete)
            {
                ImageTag.RemoveTag(tag);
            }
        }
コード例 #26
0
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override Tag GetTag (TagTypes type, bool create)
        {
            Tag tag = base.GetTag (type, false);
            if (tag != null) {
                return tag;
            }

            if (!create || (type & ImageTag.AllowedTypes) == 0)
                return null;

            if (type != TagTypes.TiffIFD)
                return base.GetTag (type, create);

            ImageTag new_tag = new IFDTag (this);
            ImageTag.AddTag (new_tag);
            return new_tag;
        }
コード例 #27
0
ファイル: File.cs プロジェクト: JayDown/taglib-sharp
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        /// <remarks>
        ///    At the time of this writing, only <see cref="AppleTag" />
        ///    is supported. All other tag types will be ignored.
        /// </remarks>
        public override Tag GetTag (TagTypes type, bool create)
        {
            if (type == TagTypes.Apple) {
                if (apple_tag == null && create) {
                    IsoUserDataBox udtaBox = FindAppleTagUdta ();
                    if (null == udtaBox) {
                        udtaBox = new IsoUserDataBox ();
                    }
                    apple_tag = new AppleTag (udtaBox);
                    tag.SetTags (apple_tag);
                }

                return apple_tag;
            }

            return null;
        }
コード例 #28
0
ファイル: GRADIENT.cs プロジェクト: rtezli/Blitzableiter
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public virtual void Parse( Stream input, TagTypes caller )
        {
            BitStream bits = new BitStream( input );
            GradRecord temp = new GradRecord(this._SwfVersion);

            this._spreadMode = ( SpreadMode )bits.GetBits( 2 );
            this._interpolationMode = ( InterPolation )bits.GetBits( 2 );
            this._numGradients = ( byte )bits.GetBits( 4 );

            bits.Reset();

            for ( int i = 0; i < this._numGradients; i++ )
            {
                temp = new GradRecord( this._SwfVersion );
                temp.Parse( input, caller );
                this._gradientRecords.Add( temp );
            }
        }
コード例 #29
0
        private Tag FindMpegTag(TagTypes type, bool create)
        {
            switch (type)
            {
            case TagTypes.Id3v1:
            {
                if (create && id3v1_tag == null)
                {
                    id3v1_tag = new Id3v1Tag();
                    TagLib.Tag.Duplicate(tag, id3v1_tag, true);
                    tag.SetTags(id3v2_tag, ape_tag, id3v1_tag);
                }

                return(id3v1_tag);
            }

            case TagTypes.Id3v2:
            {
                if (create && id3v2_tag == null)
                {
                    id3v2_tag = new Id3v2Tag();
                    TagLib.Tag.Duplicate(tag, id3v2_tag, true);
                    tag.SetTags(id3v2_tag, ape_tag, id3v1_tag);
                }

                return(id3v2_tag);
            }

            case TagTypes.Ape:
            {
                if (create && ape_tag == null)
                {
                    ape_tag = new ApeTag();
                    TagLib.Tag.Duplicate(tag, ape_tag, true);
                    tag.SetTags(id3v2_tag, ape_tag, id3v1_tag);
                }

                return(ape_tag);
            }

            default:
                return(null);
            }
        }
コード例 #30
0
        public HtmlTag PreRenderProcess(HtmlTag tag, ref WFModelMetaData metadata, TagTypes tagType, string propertyName, System.Reflection.PropertyInfo targetProperty, object model)
        {
            if (tagType == TagTypes.Span ||
                tagType == TagTypes.TextArea ||
                tagType == TagTypes.Label ||
                tagType == TagTypes.ValidationMessage ||
                tagType == TagTypes.ValidationItem)
            {
                if (!String.IsNullOrEmpty(tag.InnerText))
                {
                    tag.InnerText = HttpUtility.HtmlEncode(tag.InnerText);
                }
            }
            else if (new TagTypes[] {
                TagTypes.Checkbox,
                TagTypes.Hidden,
                TagTypes.InputBox,
                TagTypes.RadioButton,
            }.Contains(tagType))
            {
                if (!String.IsNullOrEmpty(tag.Attr("value")))
                {
                    tag.Attr("value", HttpUtility.HtmlEncode(tag.Attr("value")));
                }
            }
            else if (tagType == TagTypes.Select)
            {
                foreach (HtmlTag child in tag.Children)
                {
                    if (!String.IsNullOrEmpty(child.HTMLTagName) &&
                        child.HTMLTagName.ToLower() == "option")
                    {
                        //<option value="encode">encode</option>
                        child.InnerText = HttpUtility.HtmlEncode(child.InnerText);
                        if (!String.IsNullOrEmpty(child.Attr("value")))
                        {
                            child.Attr("value", HttpUtility.HtmlEncode(child.Attr("value")));
                        }
                    }
                }
            }

            return(tag);
        }
コード例 #31
0
 public TagLib.Tag GetTag(TagTypes type)
 {
     foreach (TagLib.Tag t in Tags)
     {
         if (type == TagTypes.Id3v1 && t is TagLib.Id3v1.Tag)
         {
             return(t);
         }
         if (type == TagTypes.Id3v2 && t is TagLib.Id3v2.Tag)
         {
             return(t);
         }
         if (type == TagTypes.Ape && t is TagLib.Ape.Tag)
         {
             return(t);
         }
     }
     return(null);
 }
コード例 #32
0
        private TagLib.Tag ReadTag(ref long start)
        {
            long     end  = start;
            TagTypes type = ReadTagInfo(ref end);

            TagLib.Tag tag = null;
            switch (type)
            {
            case TagTypes.Ape:
                tag = new TagLib.Ape.Tag(file, start);
                break;

            case TagTypes.Id3v2:
                tag = new TagLib.Id3v2.Tag(file, start);
                break;
            }
            start = end;
            return(tag);
        }
コード例 #33
0
ファイル: StartTag.cs プロジェクト: redphx/beat-downloader
        /// <summary>
        ///    Removes a set of tag types from the current instance.
        /// </summary>
        /// <param name="types">
        ///    A bitwise combined <see cref="TagLib.TagTypes" /> value
        ///    containing tag types to be removed from the file.
        /// </param>
        /// <remarks>
        ///    In order to remove all tags from a file, pass <see
        ///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
        /// </remarks>
        public void RemoveTags(TagTypes types)
        {
            for (int i = Tags.Length - 1; i >= 0; i--)
            {
                TagLib.Tag t = Tags [i];

                if ((types & TagTypes.Id3v2) != TagTypes.None &&
                    !(t is TagLib.Id3v2.Tag))
                {
                    continue;
                }

                /*
                 * if ((types & TagTypes.Ape) != TagTypes.None &&
                 *      !(t is TagLib.Ape.Tag))
                 *      continue;
                 */
                RemoveTag(t);
            }
        }
コード例 #34
0
        /// <summary>
        ///  Gets a tag of a specified type from the current instance, optionally creating a
        /// new tag if possible.
        /// </summary>
        public override Tag GetTag(TagTypes type, bool create)
        {
            if (type == TagTypes.XMP)
            {
                foreach (Tag tag in ImageTag.AllTags)
                {
                    if ((tag.TagTypes & type) == type || (tag.TagTypes & TagTypes.IPTCIIM) != 0)
                    {
                        return(tag);
                    }
                }
            }
            if (type == TagTypes.IPTCIIM && create)
            {
                // FIXME: don't know how to create IPTCIIM tags
                return(base.GetTag(type, false));
            }

            return(base.GetTag(type, create));
        }
コード例 #35
0
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagLib.Tag tag = (this.Tag as TagLib.NonContainer.Tag).GetTag(type);
            if ((tag != null) || !create)
            {
                return tag;
            }
            switch (type)
            {
                case (TagTypes.None | TagTypes.Id3v1):
                    return base.EndTag.AddTag(type, this.Tag);

                case (TagTypes.None | TagTypes.Id3v2):
                    return base.StartTag.AddTag(type, this.Tag);

                case (TagTypes.None | TagTypes.Ape):
                    return base.EndTag.AddTag(type, this.Tag);
            }
            return null;
        }
コード例 #36
0
 public override void RemoveTags(TagTypes types)
 {
     if ((types & TagLib.TagTypes.Id3v2) != TagLib.TagTypes.None)
     {
         id32_tag = null;
     }
     if ((types & TagLib.TagTypes.RiffInfo) != TagLib.TagTypes.None)
     {
         info_tag = null;
     }
     if ((types & TagLib.TagTypes.MovieId) != TagLib.TagTypes.None)
     {
         mid_tag = null;
     }
     if ((types & TagLib.TagTypes.DivX) != TagLib.TagTypes.None)
     {
         divx_tag = null;
     }
     tag.SetTags(id32_tag, info_tag, mid_tag, divx_tag);
 }
コード例 #37
0
        public static void RemoveStandardTags(string sample_file, string tmp_file, TagTypes types = TagTypes.AllTags)
        {
            if (System.IO.File.Exists(tmp_file))
            {
                System.IO.File.Delete(tmp_file);
            }

            System.IO.File.Copy(sample_file, tmp_file);

            var tmp = File.Create(tmp_file);

            tmp.RemoveTags(types);
            tmp.Save();

            // Check only if all tags have been removed
            if (types == TagTypes.AllTags)
            {
                tmp = File.Create(tmp_file);
                CheckNoTags(tmp.Tag);
            }
        }
コード例 #38
0
        public HtmlTag PreRenderProcess(HtmlTag tag, ref WFModelMetaData metadata, TagTypes tagType, string markupName, string reflectName, object Model)
        {
            //Ignore tag types that are not tied to a property
            if (!validationTypes.Contains(tagType))
            {
                return(tag);
            }

            if (reflectName == "")
            {
                reflectName = markupName;
            }
            if (Model == null || String.IsNullOrEmpty(markupName) || tag == null || metadata == null)
            {
                return(tag);
            }
            WFModelMetaProperty metaprop = null;
            string lcName = markupName.ToLower();

            for (int i = 0; i < metadata.Properties.Count; i++)
            {
                //if (metadata.Properties[i].ModelObject == Model && metadata.Properties[i].MarkupName.ToLower() == lcName)
                if (metadata.Properties[i].MarkupName.ToLower() == lcName)
                {
                    metaprop = metadata.Properties[i];
                    break;
                }
            }
            if (metaprop == null)
            {
                //Create a meta property if it does not exist
                metaprop = GetMetaProperty(metadata, markupName, Model, reflectName, null);
                metadata.Properties.Add(metaprop);
            }
            if (metaprop.HasError)
            {
                tag.AddClass(WFUtilities.InputValidationErrorClass);
            }
            return(tag);
        }
コード例 #39
0
ファイル: EndTag.cs プロジェクト: redphx/beat-downloader
        /// <summary>
        ///    Adds a tag of a specified type to the current instance,
        ///    optionally copying values from an existing type.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagTypes" /> value specifying the type of
        ///    tag to add to the current instance. At the time of this
        ///    writing, this is limited to <see cref="TagTypes.Ape" />,
        ///    <see cref="TagTypes.Id3v1" />, and <see
        ///    cref="TagTypes.Id3v2" />.
        /// </param>
        /// <param name="copy">
        ///    A <see cref="TagLib.Tag" /> to copy values from using
        ///    <see cref="TagLib.Tag.CopyTo" />, or <see
        ///    langword="null" /> if no tag is to be copied.
        /// </param>
        /// <returns>
        ///    The <see cref="TagLib.Tag" /> object added to the current
        ///    instance, or <see langword="null" /> if it couldn't be
        ///    created.
        /// </returns>
        /// <remarks>
        ///    ID3v2 tags are added at the end of the current instance,
        ///    while other tags are added to the beginning.
        /// </remarks>
        public TagLib.Tag AddTag(TagTypes type, TagLib.Tag copy)
        {
            TagLib.Tag tag = null;

            /*
             * if (type == TagTypes.Id3v1) {
             *      tag = new TagLib.Id3v1.Tag ();
             * } else
             */
            if (type == TagTypes.Id3v2)
            {
                Id3v2.Tag tag32 = new Id3v2.Tag();
                tag32.Version = 4;
                tag32.Flags  |= Id3v2.HeaderFlags.FooterPresent;
                tag           = tag32;
            }

            /*else if (type == TagTypes.Ape) {
             *                  tag = new TagLib.Ape.Tag ();
             *          }*/

            if (tag != null)
            {
                if (copy != null)
                {
                    copy.CopyTo(tag, true);
                }

                if (type == TagTypes.Id3v1)
                {
                    AddTag(tag);
                }
                else
                {
                    InsertTag(0, tag);
                }
            }

            return(tag);
        }
コード例 #40
0
ファイル: LINESTYLE.cs プロジェクト: rtezli/Blitzableiter
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public virtual void Parse(Stream input, TagTypes caller)
        {
            BinaryReader br = new BinaryReader(input);

            this._width = br.ReadUInt16();

            if (caller.Equals(TagTypes.DefineShape) || caller.Equals(TagTypes.DefineShape2))
            {
                this._color = new Rgb(this._SwfVersion);

                try
                {
                    this._color.Parse(input);
                }
                catch(SwfFormatException e)
                {
                    throw e;
                }

            }
            else if (caller.Equals(TagTypes.DefineShape3))
            {
                this._color = new Rgba(this._SwfVersion);

                try
                {
                    this._color.Parse(input);
                }
                catch (SwfFormatException e)
                {
                    throw e;
                }

            }
            else
            {
                SwfFormatException e = new SwfFormatException("LineStyle was called by illegal TagType (" + caller.ToString() +").");
               Log.Error(this, e.Message);
            }
        }
コード例 #41
0
        private Tag FindWavPackTag(TagTypes type, bool create)
        {
            switch (type)
            {
            case TagTypes.Id3v1:
            {
                if (create && id3v1Tag == null)
                {
                    id3v1Tag = new Id3v1Tag();

                    if (tag != null)
                    {
                        TagLib.Tag.Duplicate(tag, id3v1Tag, true);
                    }

                    tag.SetTags(apeTag, id3v1Tag);
                }
                return(id3v1Tag);
            }

            case TagTypes.Ape:
            {
                if (create && apeTag == null)
                {
                    apeTag = new ApeTag();

                    if (tag != null)
                    {
                        TagLib.Tag.Duplicate(tag, apeTag, true);
                    }

                    tag.SetTags(apeTag, id3v1Tag);
                }
                return(apeTag);
            }

            default:
                return(null);
            }
        }
コード例 #42
0
 public override TagLib.Tag GetTag(TagTypes type, bool create)
 {
     if (type == TagTypes.Xiph)
     {
         IEnumerator<XiphComment> enumerator = this.tag.Comments.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 return enumerator.Current;
             }
         }
         finally
         {
             if (enumerator == null)
             {
             }
             enumerator.Dispose();
         }
     }
     return null;
 }
コード例 #43
0
 public TagLib.Tag AddTag(TagTypes type, TagLib.Tag copy)
 {
     TagLib.Tag tag = null;
     if (type == TagTypes.Id3v2)
     {
         tag = new TagLib.Id3v2.Tag();
     }
     else if (type == TagTypes.Ape)
     {
         tag = new TagLib.Ape.Tag();
         (tag as Ape.Tag).HeaderPresent = true;
     }
     if (tag != null)
     {
         if (copy != null)
         {
             copy.CopyTo(tag, true);
         }
         AddTag(tag);
     }
     return(tag);
 }
コード例 #44
0
        public override void Validate(object value)
        {
            if (value is IEnumerable<TagTypes>)
            {
                return;
            }

            var val = value as string;

            if (val != null)
            {
                var parts = val.Split(',');
                var result = new TagTypes[parts.Length];
                for (var i = 0; i < parts.Length; i++)
                {
                    var part = parts[i];
                    result[i] = (TagTypes)Enum.Parse(typeof(TagTypes), part, true);
                }
            }

            throw new ArgumentException("Invalid input for IList<TagTypes>");
        }
コード例 #45
0
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagLib.Tag t = (Tag as TagLib.NonContainer.Tag).GetTag(type);
            if (t != null || !create)
            {
                return(t);
            }
            switch (type)
            {
            case TagTypes.Id3v1:
                return(EndTag.AddTag(type, Tag));

            case TagTypes.Id3v2:
                return(StartTag.AddTag(type, Tag));

            case TagTypes.Ape:
                return(EndTag.AddTag(type, Tag));

            default:
                return(null);
            }
        }
コード例 #46
0
 public TagLib.Tag AddTag(TagTypes type, TagLib.Tag copy)
 {
     TagLib.Tag target = null;
     if (type == (TagTypes.None | TagTypes.Id3v2))
     {
         target = new TagLib.Id3v2.Tag();
     }
     else if (type == (TagTypes.None | TagTypes.Ape))
     {
         target = new TagLib.Ape.Tag();
         (target as TagLib.Ape.Tag).HeaderPresent = true;
     }
     if (target != null)
     {
         if (copy != null)
         {
             copy.CopyTo(target, true);
         }
         base.AddTag(target);
     }
     return target;
 }
コード例 #47
0
ファイル: LINESTYLE2.cs プロジェクト: rtezli/Blitzableiter
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public override void Parse(Stream input, TagTypes caller)
        {
            BinaryReader br = new BinaryReader(input);

            this._width = br.ReadUInt16();

            BitStream bits = new BitStream(input);

            this._startCapStyle = (CapStyle)(Convert.ToByte(bits.GetBits(2)));
            this._joinstyle = (JoinStyle)(Convert.ToByte(bits.GetBits(2)));

            this._hasFillFlag = (0 != bits.GetBits(1) ? true : false);
            this._noHScale = (0 != bits.GetBits(1) ? true : false);
            this._noVScale = (0 != bits.GetBits(1) ? true : false);
            this._pixelHinting = (0 != bits.GetBits(1) ? true : false);

            bits.GetBits(5); // reserved must be null

            this._noClose = (0 != bits.GetBits(1) ? true : false);

            this._endCapStyle = (CapStyle)bits.GetBits(2);

            if (this._joinstyle.Equals(JoinStyle.Miter))
            {
                bits.Reset();
                this._miterLimtiFactor = br.ReadUInt16();
            }
            if (!this._hasFillFlag)
            {
                bits.Reset();
                this._color.Parse(input);
            }
            if (this._hasFillFlag)
            {
                bits.Reset();
                this._fillStyle.Parse(input, caller);
            }
        }
コード例 #48
0
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagTypes types;
            switch (type)
            {
                case TagTypes.Xiph:
                    return this.metadata.GetComment(create, this.tag);

                case TagTypes.FlacMetadata:
                    return this.metadata;

                default:
                {
                    TagLib.Tag tag = (base.Tag as TagLib.NonContainer.Tag).GetTag(type);
                    if ((tag != null) || !create)
                    {
                        return tag;
                    }
                    types = type;
                    switch (types)
                    {
                        case (TagTypes.None | TagTypes.Id3v1):
                            return base.EndTag.AddTag(type, this.Tag);

                        case (TagTypes.None | TagTypes.Id3v2):
                            return base.StartTag.AddTag(type, this.Tag);
                    }
                    break;
                }
            }
            if (types == (TagTypes.None | TagTypes.Ape))
            {
                return base.EndTag.AddTag(type, this.Tag);
            }
            return null;
        }
コード例 #49
0
ファイル: File.cs プロジェクト: bossaia/alexandrialibrary
		/// <summary>
		///    Gets a tag of a specified type from the current instance,
		///    optionally creating a new tag if possible.
		/// </summary>
		/// <param name="type">
		///    A <see cref="TagLib.TagTypes" /> value indicating the
		///    type of tag to read.
		/// </param>
		/// <param name="create">
		///    A <see cref="bool" /> value specifying whether or not to
		///    try and create the tag if one is not found.
		/// </param>
		/// <returns>
		///    A <see cref="Tag" /> object containing the tag that was
		///    found in or added to the current instance. If no
		///    matching tag was found and none was created, <see
		///    langref="null" /> is returned.
		/// </returns>
		/// <remarks>
		///    If a <see cref="TagLib.Id3v2.Tag" /> is added to the
		///    current instance, it will be placed at the start of the
		///    file. On the other hand, <see cref="TagLib.Id3v1.Tag" />
		///    <see cref="TagLib.Ape.Tag" /> will be added to the end of
		///    the file. All other tag types will be ignored.
		/// </remarks>
		public override TagLib.Tag GetTag (TagTypes type, bool create)
		{
			Tag t = (Tag as TagLib.NonContainer.Tag).GetTag (type);
			
			if (t != null || !create)
				return t;
			
			switch (type)
			{
			case TagTypes.Id3v1:
				return EndTag.AddTag (type, Tag);
			
			case TagTypes.Id3v2:
				return EndTag.AddTag (type, Tag);
			
			case TagTypes.Ape:
				return EndTag.AddTag (type, Tag);
			
			default:
				return null;
			}
		}
コード例 #50
0
ファイル: FileTest.cs プロジェクト: nuxleus/taglib-sharp
 public override void RemoveTags(TagTypes types)
 {
     throw new System.NotImplementedException ();
 }
コード例 #51
0
ファイル: FileTest.cs プロジェクト: nuxleus/taglib-sharp
 public override Tag GetTag(TagTypes type, bool create)
 {
     throw new System.NotImplementedException ();
 }
コード例 #52
0
ファイル: File.cs プロジェクト: Sirais/taglib-sharp-portable
        /// <summary>
        ///    Removes a set of tag types from the current instance.
        /// </summary>
        /// <param name="types">
        ///    A bitwise combined <see cref="TagLib.TagTypes" /> value
        ///    containing tag types to be removed from the file.
        /// </param>
        /// <remarks>
        ///    In order to remove all tags from a file, pass <see
        ///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
        /// </remarks>
        public override void RemoveTags(TagTypes types)
        {
            if ((types & TagLib.TagTypes.Id3v2) != TagLib.TagTypes.None)
                id32_tag = null;
            if ((types & TagLib.TagTypes.RiffInfo) != TagLib.TagTypes.None)
                info_tag = null;
            if ((types & TagLib.TagTypes.MovieId) != TagLib.TagTypes.None)
                mid_tag  = null;
            if ((types & TagLib.TagTypes.DivX) != TagLib.TagTypes.None)
                divx_tag = null;

            tag.SetTags (id32_tag, info_tag, mid_tag, divx_tag);
        }
コード例 #53
0
ファイル: File.cs プロジェクト: Sirais/taglib-sharp-portable
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagLib.Tag tag = null;

            switch (type)
            {
            case TagTypes.Id3v2:
                if (id32_tag == null && create) {
                    id32_tag = new Id3v2.Tag ();
                    id32_tag.Version = 4;
                    id32_tag.Flags |= Id3v2.HeaderFlags
                        .FooterPresent;
                    this.tag.CopyTo (id32_tag, true);
                }

                tag = id32_tag;
                break;

            case TagTypes.RiffInfo:
                if (info_tag == null && create) {
                    info_tag = new InfoTag ();
                    this.tag.CopyTo (info_tag, true);
                }

                tag = info_tag;
                break;

            case TagTypes.MovieId:
                if (mid_tag == null && create) {
                    mid_tag = new MovieIdTag ();
                    this.tag.CopyTo (mid_tag, true);
                }

                tag = mid_tag;
                break;

            case TagTypes.DivX:
                if (divx_tag == null && create) {
                    divx_tag = new DivXTag ();
                    this.tag.CopyTo (divx_tag, true);
                }

                tag = divx_tag;
                break;
            }

            this.tag.SetTags (id32_tag, info_tag, mid_tag, divx_tag);
            return tag;
        }
コード例 #54
0
 /// <summary>
 ///    Removes a set of tag types from the current instance.
 /// </summary>
 /// <param name="types">
 ///    A bitwise combined <see cref="TagLib.TagTypes" /> value
 ///    containing tag types to be removed from the file.
 /// </param>
 /// <remarks>
 ///    In order to remove all tags from a file, pass <see
 ///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
 /// </remarks>
 public override void RemoveTags(TagTypes types)
 {
     if (types == TagLib.TagTypes.Id3v2 ||
         types == TagLib.TagTypes.AllTags)
     {
         tag = null;
     }
 }
コード例 #55
0
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagLib.Tag id32_tag = null;

            switch (type)
            {
                case TagTypes.Id3v2:
                    if (tag == null && create)
                    {
                        tag = new Id3v2.Tag();
                        tag.Version = 2;
                    }

                    id32_tag = tag;
                    break;
            }

            return id32_tag;
        }
コード例 #56
0
ファイル: File.cs プロジェクト: tigger/tripod
		/// <summary>
		///    Gets a tag of a specified type from the current instance.
		/// </summary>
		/// <param name="type">
		///    A <see cref="TagLib.TagTypes" /> value indicating the
		///    type of tag to read.
		/// </param>
		/// <returns>
		///    A <see cref="Tag" /> object containing the tag that was
		///    found in the current instance. If no matching tag
		///    was found, <see langword="null" /> is returned.
		/// </returns>
		/// <remarks>
		///    <para>This class merely accesses the tag if it exists.
		///    <see cref="GetTag(TagTypes,bool)" /> provides the option
		///    of adding the tag to the current instance if it does not
		///    exist.</para>
		///    <para>It is safe to assume that if <see langword="null"
		///    /> is not returned, the returned tag can be cast to the
		///    appropriate type.</para>
		/// </remarks>
		/// <example>
		///    <para>The following example reads the mood of a file from
		///    several tag types.</para>
		///    <code lang="C#">static string [] GetMoods (TagLib.File file)
		///{
		///   TagLib.Id3v2.Tag id3 = file.GetTag (TagLib.TagTypes.Id3v2);
		///   if (id3 != null) {
		///      TextIdentificationFrame f = TextIdentificationFrame.Get (this, "TMOO");
		///      if (f != null)
		///         return f.FieldList.ToArray ();
		///   }
		///   
		///   TagLib.Asf.Tag asf = file.GetTag (TagLib.TagTypes.Asf);
		///   if (asf != null) {
		///      string [] value = asf.GetDescriptorStrings ("WM/Mood", "Mood");
		///      if (value.Length &gt; 0)
		///         return value;
		///   }
		///   
		///   TagLib.Ape.Tag ape = file.GetTag (TagLib.TagTypes.Ape);
		///   if (ape != null) {
		///      Item item = ape.GetItem ("MOOD");
		///      if (item != null)
		///         return item.ToStringArray ();
		///   }
		///      
		///   // Whatever tag types you want...
		///   
		///   return new string [] {};
		///}</code>
		/// </example>
		public Tag GetTag (TagTypes type)
		{
			return GetTag (type, false);
		}
コード例 #57
0
ファイル: File.cs プロジェクト: tigger/tripod
		/// <summary>
		///    Gets a tag of a specified type from the current instance,
		///    optionally creating a new tag if possible.
		/// </summary>
		/// <param name="type">
		///    A <see cref="TagLib.TagTypes" /> value indicating the
		///    type of tag to read.
		/// </param>
		/// <param name="create">
		///    A <see cref="bool" /> value specifying whether or not to
		///    try and create the tag if one is not found.
		/// </param>
		/// <returns>
		///    A <see cref="Tag" /> object containing the tag that was
		///    found in or added to the current instance. If no
		///    matching tag was found and none was created, <see
		///    langword="null" /> is returned.
		/// </returns>
		/// <remarks>
		///    <para>Passing <see langword="true" /> to <paramref
		///    name="create" /> does not guarantee the tag will be
		///    created. For example, trying to create an ID3v2 tag on an
		///    OGG Vorbis file will always fail.</para>
		///    <para>It is safe to assume that if <see langword="null"
		///    /> is not returned, the returned tag can be cast to the
		///    appropriate type.</para>
		/// </remarks>
		/// <example>
		///    <para>The following example sets the mood of a file to
		///    several tag types.</para>
		///    <code lang="C#">string [] SetMoods (TagLib.File file, params string[] moods)
		///{
		///   TagLib.Id3v2.Tag id3 = file.GetTag (TagLib.TagTypes.Id3v2, true);
		///   if (id3 != null)
		///      id3.SetTextFrame ("TMOO", moods);
		///   
		///   TagLib.Asf.Tag asf = file.GetTag (TagLib.TagTypes.Asf, true);
		///   if (asf != null)
		///      asf.SetDescriptorStrings (moods, "WM/Mood", "Mood");
		///   
		///   TagLib.Ape.Tag ape = file.GetTag (TagLib.TagTypes.Ape);
		///   if (ape != null)
		///      ape.SetValue ("MOOD", moods);
		///      
		///   // Whatever tag types you want...
		///}</code>
		/// </example>
		public abstract Tag GetTag (TagTypes type, bool create);
コード例 #58
0
ファイル: File.cs プロジェクト: tigger/tripod
		/// <summary>
		///    Removes a set of tag types from the current instance.
		/// </summary>
		/// <param name="types">
		///    A bitwise combined <see cref="TagLib.TagTypes" /> value
		///    containing tag types to be removed from the file.
		/// </param>
		/// <remarks>
		///    In order to remove all tags from a file, pass <see
		///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
		/// </remarks>
		public abstract void RemoveTags (TagTypes types);
コード例 #59
0
ファイル: File.cs プロジェクト: Sirais/taglib-sharp-portable
        /// <summary>
        ///    Removes a set of tag types from the current instance.
        /// </summary>
        /// <param name="types">
        ///    A bitwise combined <see cref="TagLib.TagTypes" /> value
        ///    containing tag types to be removed from the file.
        /// </param>
        /// <remarks>
        ///    In order to remove all tags from a file, pass <see
        ///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
        /// </remarks>
        public override void RemoveTags(TagTypes types)
        {
            if ((types & TagTypes.Xiph) != 0)
                metadata.RemoveComment ();

            if ((types & TagTypes.FlacMetadata) != 0)
                metadata.Clear ();

            base.RemoveTags (types);
        }
コード例 #60
0
ファイル: File.cs プロジェクト: Sirais/taglib-sharp-portable
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            switch (type)
            {
            case TagTypes.Xiph:
                return metadata.GetComment (create, tag);

            case TagTypes.FlacMetadata:
                return metadata;
            }

            Tag t = (base.Tag as TagLib.NonContainer.Tag).GetTag (type);

            if (t != null || !create)
                return t;

            switch (type)
            {
            case TagTypes.Id3v1:
                return EndTag.AddTag (type, Tag);

            case TagTypes.Id3v2:
                return StartTag.AddTag (type, Tag);

            case TagTypes.Ape:
                return EndTag.AddTag (type, Tag);

            default:
                return null;
            }
        }