About .NET, ASP.NET, MVC, C#, WPF, WCF and everything related to .NET and more.

Mugen Injection [Running code at startup]

There are two automatic activation mechanisms available:

  • Startable components
  • Initializable components

Startable Components

The key is to implement the MugenInjection.Interface.IStartable interface. When the binding is activating, the component will be activated and the IStartable.Start() method will be called. When the binding will be disposed, the component will be deactivated and the IStartable.Stop() method will be called.
Startable components must implement the MugenInjection.Interface.IStartable interface. Startable components are just regular components, that can be registered in the usual way and can take constructor dependencies as needed.
public class Startable : IStartable
{

    #region Implementation of IStartable

    /// <summary>
    /// Starts this instance. Called during activation.
    /// </summary>
    public void Start()
    {
    }

    /// <summary>
    /// Stops this instance. Called during deactivation.
    /// </summary>
    public void Stop()
    {
        throw new NotImplementedException();
    }

    #endregion
}

Initializable components

The key is to implement the MugenInjection.Interface.IInitializable interface. When the binding is activating, the component will be activated and the IInitializable.Initialize() method will be called.
Initializable components must implement the MugenInjection.Interface.IInitializable interface. Initializable components are just regular components, that can be registered in the usual way and can take constructor dependencies as needed.
public class Initializable:IInitializable
{

    #region Implementation of IInitializable

    /// <summary>
    /// Initializes the instance. Called during activation.
    /// </summary>
    public void Initialize()
    {
        throw new NotImplementedException();
    }

    #endregion
}

Comments
Leave a Reply
*bold*
_italics_
+underline+
* Bullet List
** Bullet List 2
# Number List
## Number List 2
{"Do not apply formatting"}
{code:language} code here {code:language}.
Supports: aspx c#, c#, c++, html, sql, xml
[url:http://www.example.com]