init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
72
Kreta.WebApi/Naplo/Kreta.Naplo.WebApi/DependencyContainer.cs
Normal file
72
Kreta.WebApi/Naplo/Kreta.Naplo.WebApi/DependencyContainer.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Kreta.Core.IoC;
|
||||
using Kreta.Naplo.BusinessLogic.Propetries;
|
||||
using Kreta.Naplo.Configuration.Kreta;
|
||||
using Kreta.Naplo.Domain;
|
||||
using Kreta.Naplo.Domain.V3.Enum;
|
||||
using Kreta.Naplo.WebApi.V3.Common.Logic;
|
||||
|
||||
namespace Kreta.Naplo.WebApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Dependency resolver of webapi layer
|
||||
/// </summary>
|
||||
internal class DependencyContainer : Core.IoC.DependencyContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// Unknown user agent
|
||||
/// </summary>
|
||||
public const string UnknownUserAgent = "unknown_user_agent";
|
||||
|
||||
/// <summary>
|
||||
/// Instance
|
||||
/// </summary>
|
||||
public static IDependencyResolver Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetResolver(WebApiLayer.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imported object resolved
|
||||
/// </summary>
|
||||
/// <param name="importedObject">Imported object</param>
|
||||
protected override void OnImportedObjectResolved(object importedObject)
|
||||
{
|
||||
var service = importedObject as IService;
|
||||
|
||||
if (service != null)
|
||||
{
|
||||
service.Context = new ServiceContext
|
||||
(
|
||||
FelhasznaloLogic.GetInstituteCode(),
|
||||
FelhasznaloLogic.GetInstituteUserId(),
|
||||
FelhasznaloLogic.GetRoles().Contains(FelhasznaloSzerepkor.Tanar) ? new List<string>() { "Teacher" } : new List<string>(),
|
||||
KretaNaploApiConfiguration.Instance.BaseUrl,
|
||||
KretaNaploApiConfiguration.Instance.ApiKey,
|
||||
HttpContext.Current?.Request?.UserAgent ?? UnknownUserAgent,
|
||||
FelhasznaloLogic.GetSchoolYearId()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize
|
||||
/// </summary>
|
||||
protected override void Initialize()
|
||||
{
|
||||
#region V2
|
||||
ImportFrom<Domain.V2.Service.ITanarService>(BusinessLogicLayer.Instance);
|
||||
ImportFrom<Domain.V2.Service.IEnumService>(BusinessLogicLayer.Instance);
|
||||
ImportFrom<Domain.V2.Service.ICommonService>(BusinessLogicLayer.Instance);
|
||||
ImportFrom<Domain.V2.Service.IOraService>(BusinessLogicLayer.Instance);
|
||||
ImportFrom<Domain.V2.Service.IErtekelesService>(BusinessLogicLayer.Instance);
|
||||
ImportFrom<Domain.V2.Service.IIskolaorService>(BusinessLogicLayer.Instance);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue