Files
C4IT-F4SD-Client/FasdDesktopUi/Basics/Services/SupportCase/SupportCaseFactory.cs
2026-01-28 12:08:39 +01:00

36 lines
1.4 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, 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 (_supportCases.TryGetValue(primaryIdentity.Id, out var supportCase))
{
supportCase.Initialize();
return supportCase;
}
return Create(primaryIdentity, relationService, supportCaseDataProvider);
}
}
}