How ASFTagInfo class works ?

Introduction
Professional Tag Editor
Features Overview
What is ID3 Tagging ?
What is WMA Tagging ?
Download
For Developer
Features
ID3 Controls
WMA Controls
Samples
How it works (ID3v1)
How it works (ID3v2)
How it works (WMA)
WMA vs. MP3
About
Version History
About / Permissions
Awards
Working with WMA (ASF) is very similar to working with ID3 v2. As ASF files consist of objects there is a class named ASFObject to provide basic information of all objects.

Each object type such as "Content Description" have it own class that inherited ASFObject. And provide methods and properties to read/write this object.

ASFObject Class support reading GUID and size of object then inherited class read data structure and provide properties to edit object properties easy.

In ASF tagging if Professional Tag Editor found an object that is unknown it will store as General Object. General Object provide some method to read/write unknown object. In fact they load into general objects and then store without any changes.

ASF object class diagram in visual studio 2008
This is ASF (WMA) objects class diagram in visual studio 2008

As is clear in the diagram, to support new type of object the object class must define and add to ASF file reader.

The main job in reading ASF file did with ASFTagInfo class. This class start reading ASF file and find suitable class object to read that object or if there were no suitable class read it with General Object and store all frames in an array and finally save them all.

ASFTagInfo contains exception array (as ID3 v2 contains) to provide list of occurred error while tried to reading file.

Error contains level that indicate how harmful this error is.

This is part of code inside Load method of ASFTagInfo class (In Tag Project, ASF classes folder). This part of code shows how ASFTagInfo call suitable object for each object and if object was unknown read with General object.

ASFObject Object = null;
switch (g.ToString().ToUpper())
{
   
case ContentDescriptionOb.GUIDst:
        Object =
new ContentDescriptionOb(Data, BlockSize);
       
break;
   
case ExContentDescriptionOb.GUIDst:
        Object =
new ExContentDescriptionOb(Data, BlockSize);
       
break;
   
case ContentBrandingOb.GUIDst:
        Object =
new ContentBrandingOb(Data, BlockSize);
       
break;
   
default:
        Object =
new GeneralObject(Data, BlockSize, g.ToString());
        _Unknown.Add(Object);
       
break;
}

foreach (Exception Ob in Object.Exceptions)
    _Exceptions.Add(Ob);

if (Object.GetType() != typeof(GeneralObject))
    _List.Add(Object.GUID, Object);

The code below is the part of Save method of ASFTagInfo class:

foreach (GeneralObject GO in UnknowsObjects)
    GO.WriteData(TempFile);

foreach (ASFObject Ob in _List.Values)
    Ob.WriteData(TempFile);

As you can see in save method first all unknown frames wrote in file stream and then all edited data add to files. Also in save method provided some codes to use ASF tagging as template and reuse them for other files.

All the methods in project have description and there is more comment for each method and properties in project.

ASF have theirs own controls to make professional tag editor in just a minute. Take a look at WMA Controls