39 lines
1.6 KiB
C#
39 lines
1.6 KiB
C#
using C4IT.FASD.Base;
|
|
using FasdDesktopUi.Basics.Services.RelationService;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
|
|
namespace FasdDesktopUi.Basics.Services.SupportCase
|
|
{
|
|
public static class SupportCaseFactory
|
|
{
|
|
private static readonly Dictionary<Guid, ISupportCase> _supportCases = new Dictionary<Guid, ISupportCase>();
|
|
|
|
private static ISupportCase Create(cF4sdIdentityEntry primaryIdentity, IRelationService relationService, cSupportCaseDataProvider supportCaseDataProvider)
|
|
{
|
|
SupportCase supportCase = new SupportCase(primaryIdentity.Id, relationService.Clone(), supportCaseDataProvider);
|
|
_supportCases.Add(primaryIdentity.Id, supportCase);
|
|
supportCase.Initialize();
|
|
return supportCase;
|
|
}
|
|
|
|
public static ISupportCase Get(cF4sdIdentityEntry primaryIdentity, IRelationService relationService, cSupportCaseDataProvider supportCaseDataProvider)
|
|
{
|
|
if (primaryIdentity is null)
|
|
throw new InvalidEnumArgumentException($"{nameof(primaryIdentity)} must not be null.");
|
|
|
|
if (primaryIdentity.Class != enumFasdInformationClass.User)
|
|
throw new InvalidEnumArgumentException($"{nameof(primaryIdentity)} must be of class {nameof(enumFasdInformationClass.User)}.");
|
|
|
|
if (_supportCases.TryGetValue(primaryIdentity.Id, out var supportCase))
|
|
{
|
|
supportCase.Initialize();
|
|
return supportCase;
|
|
}
|
|
|
|
return Create(primaryIdentity, relationService, supportCaseDataProvider);
|
|
}
|
|
}
|
|
}
|