Additional Features

Logging the AppBuilder

Especially while developing an application, it’s useful to log the assembling / building the application. The AppBuilder is able to generate a simple logfile. You can configure this by using a different constructor of the AppBuilder:
AppBuilder tAppBuilder = new AppBuilder(logFilePathName, logLevel);

The first parameter defines the location and name of the logfile. The second parameter defines the content. Loglevel “0” only writes errors. In loglevel “1” you can see the finishing of each internal step of the AppBuilder. If you want to log everything the AppBuilder does use loglevel “3”. That’s the highest loglevel.

Configure and initialize the steps

As mentioned before, the AppBuilder creates the instances by itself. Sometimes however, you want to configure the steps by additional objects. You can do this by implementing the two interfaces IConfigure and IInitialize:
namespace AB3.Interfaces
{
    /// <summary>Interface to mark a step that needs to be configured
    /// </summary>
    public interface IConfigure
    {
        /// <summary>This will be called to configure your part
        /// </summary>
        /// <param name="args">the configuration</param>
        void Configure(object args);
    }
}

namespace AB3.Interfaces
{
    /// <summary>Interface to mark a step that needs to be initialized
    /// </summary>
    public interface IInitialize
    {
        /// <summary>This will be called to initialize your part
        /// </summary>
        /// <param name="args">the configuration</param>
        void Initialize(object args);
    }
}

You can send the arguments by BuildApp:
tAppBuilder.BuildApp(object configureArg, object initializeArg);

It’s up to the developer to handle the args. That’s why data type object is used.

First, all steps that implement IConfigure are configured by configureArg. Second, all steps that implement IInitialize are initialized by initializeArg. If there are no special arguments use “null” as argument:
tAppBuilder.BuildApp(nullnull);

Last edited Apr 19, 2013 at 5:38 PM by InneHo, version 1

Comments

No comments yet.