Part 1 Part 2 Part 3

The constructor initializes a few needed objects. Among them, we have three regular expressions that will help us parse the flat file. Those regular expressions are not perfect and I am sure anyone can improve them to parse the exact file format:

 

  /// <summary>

  /// Constructor.

  /// </summary>

  /// <remarks>

  /// Custom pipelines components are activated by COM.

  /// As a result, a default constructor is required.

  /// </remarks>

  public TableFormatterDisassembler()

  {

     tablesArray = new ArrayList();

     resMgr      = new ResourceManager(GetType().Namespace + ".Resources", Assembly.GetExecutingAssembly());

 

     // Initialize all regular expressions we will need during parsing

     regExpBlankLine   = new Regex("[A-Za-z0-9_]+", RegexOptions.Compiled | RegexOptions.Singleline);

     regExpTableParser = new Regex("Table[ \\t]*:(?<TableName>[A-Za-z0-9_]+)",

                                   RegexOptions.Compiled | RegexOptions.Singleline);

     regExpLineParser  = new Regex("(?<FieldName>[A-Za-z0-9_]+)"

                                   "(?<Separator>[&@%$\"])(?<FieldValue>[\\-_0-9/:\\. \\tA-Za-z]*)",

                                   RegexOptions.Compiled | RegexOptions.Singleline);

The implementation of IComponent is starighforward. I am grabbing all the strings from the resource file. Remember that if you do not return a valid name (i.e. any string), the custom component will fail to load in Visual Studio's toolbox.

  /// <summary>

  /// Returns a friendly description of this pipeline component.

  /// </summary>

  [Browsable(false)]

  public string Description

  {

     get { return resMgr.GetString(descriptionRsrcID); }

  }

 

  /// <summary>

  /// Returns the name of this pipeline component.

  /// </summary>

  [Browsable(false)]

  public string Name

  {

     get { return resMgr.GetString(nameRsrcID); }

  }

 

  /// <summary>

  /// Returns the version of the component. We get the version of the assembly.

  /// </summary>

  [Browsable(false)]

  public string Version

  {

     get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); }

  }

Since we do not have any custom property in this pipeline component, the implementation of IComponentUI is simple as well. Validate() returns an empty enumerator (i.e. an enumerator that enumerates an empty collection).

  /// <summary>

  /// Validates properties entered at design time.

  /// </summary>

  /// <param name="projectSystem">object: Configuration properties.</param>

  /// <returns>

  /// IEnumerator: Enumerator on a collection of error strings.

  /// An empty enumerator should be returned if no error occured.

  /// </returns>

  public System.Collections.IEnumerator Validate(object projectSystem)

  {

     ArrayList strList = new ArrayList();

 

     // We do not currently expose any properties so return an empty enumerator

     return strList.GetEnumerator();

  }

 

  /// <summary>

  /// Returns the Icon that should be displayed in graphical designers (Visual Studio).

  /// </summary>

  [Browsable(false)]

  public System.IntPtr Icon

  {

     get { return ((Bitmap) resMgr.GetObject(designerIconRsrcID)).GetHicon(); }

  }