EchoTex_Payroll/Ease.Core/Model/Services.cs

69 lines
2.2 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
/*
|-------------------------------------------------------------------------------|
| Copyright © Computer Ease Limited |
| Address: 1/9 Bloack-A Lalmatia, Dhaka-1207, Bangladesh |
| Email: info@celimited.com, cease@bol-online.com, web: www.celimited.com |
| Unauthorized copy or distribution is strictly prohibited |
| Author: S. M. Russel, Last modified date: 18/04/2009 |
|-------------------------------------------------------------------------------|
*/
using System;
using System.Collections.Generic;
namespace Ease.Core.Model
{
#region Services
/// <summary>
///This class returns the appropriate service factory according to configuration
/// </summary>
public class Services
{
private static ServiceFactory _factory;
private const string defaultKey = "serviceHandler";
private static Dictionary<string, ServiceFactory> _keyBaseServices;
static Services()
{
_keyBaseServices = new Dictionary<string, ServiceFactory>();
_factory = new ServiceFactory(defaultKey);
}
/// <summary>
/// Return default service facory
/// </summary>
public static ServiceFactory Factory
{
get { return _factory; }
}
/// <summary>
/// Crete an instance of services.
/// </summary>
/// <param name="serviceHandlerKey">Key is used handle services</param>
public Services(string serviceHandlerKey)
{
if (_keyBaseServices.ContainsKey(serviceHandlerKey))
return;
ServiceFactory svc = new ServiceFactory(serviceHandlerKey);
_keyBaseServices.Add(serviceHandlerKey, svc);
}
/// <summary>
/// Return Service factory according to parameter.
/// </summary>
/// <param name="svcKey">Valid key of existing services</param>
/// <returns></returns>
public ServiceFactory KeyBaseFactory(string svcKey)
{
if (_keyBaseServices != null && _keyBaseServices.ContainsKey(svcKey))
return _keyBaseServices[svcKey];
return null;
}
}
#endregion
}