ManagerHost class

Provides a means to reduce instantiation requirements of classes implementing IManager.

Namespace: ReFlex.Data namespace
Assembly: ReFlex.Data.dll

Syntax

public class ManagerHost : IDisposable

Constructors

ManagerHost();

Remarks

Works with the IManager interface to host instances of manager classes.

ManagerHost checks the IManager.IsHostableStatic property to determine if the manager should be stored in the central static manager dictionary, or in a ManagerHost instance dictionary. This allows you to provide single manager instance per application instance and reduce application memory requirements. If the manager is not marked as IsHostableStatic, this means that an instance of the manager is only created once per request, thus also reducing memory requirements.

Examples

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ReFlex.Data;

/// <summary>
/// Example non-cms page
/// </summary>
public partial class ExampleNonCmsPage : ReFlex.Web.UI.Page
{
    private ManagerHost m_Host = new ManagerHost();

    /// <summary>
    /// Pre init
    /// </summary>
    /// <param name="e"></param>
    protected override void OnPreInit(EventArgs e)
    {
        List<Contact> contacts = m_Host.Manager<ContactManager>().GetItems(null);
        Dictionary<int, Company> companiesDictionary = m_Host.Manager<CompanyManager>().GetItemsDictionary(null);
        List<Contact> jContacts = m_Host.Manager<ContactManager>().GetItems(new Criterion<Contact>(CriteriaOperatorEnum.And)
            .Add("FirstName", "j", ComparisonOperatorEnum.StartsLike, CriteriaOperatorEnum.And));

        base.OnPreInit(e);
    }
}