implement AddLibraryReferenceInternal
This commit is contained in:
parent
569f76f6c8
commit
c22e8f0291
@ -194,7 +194,8 @@ public class MemoryOms : Oms
|
||||
|
||||
private Dictionary<TenantHandle, _Tenant> _tenantData = new Dictionary<TenantHandle, _Tenant>();
|
||||
|
||||
private _Tenant _CurrentTenant = null;
|
||||
private _Tenant _CurrentTenantData = null;
|
||||
private TenantHandle _CurrentTenant = TenantHandle.Empty;
|
||||
|
||||
protected override TenantHandle CreateTenantInternal(string tenantName)
|
||||
{
|
||||
@ -204,26 +205,42 @@ public class MemoryOms : Oms
|
||||
}
|
||||
protected override void SelectTenantInternal(TenantHandle tenant)
|
||||
{
|
||||
_CurrentTenant = _tenantData[tenant];
|
||||
_CurrentTenantData = _tenantData[tenant];
|
||||
_CurrentTenant = tenant;
|
||||
}
|
||||
protected override void ReleaseTenantInternal()
|
||||
{
|
||||
_CurrentTenant = null;
|
||||
_CurrentTenantData = null;
|
||||
}
|
||||
|
||||
private Dictionary<TenantHandle, List<LibraryHandle>> _libraryReferences = new Dictionary<TenantHandle, List<LibraryHandle>>();
|
||||
|
||||
protected override void AddLibraryReferenceInternal(LibraryHandle library)
|
||||
{
|
||||
if (!_libraryReferences.ContainsKey(_CurrentTenant))
|
||||
{
|
||||
_libraryReferences[_CurrentTenant] = new List<LibraryHandle>();
|
||||
}
|
||||
if (!_libraryReferences[_CurrentTenant].Contains(library))
|
||||
{
|
||||
// please don't reference the same library multiple times
|
||||
_libraryReferences[_CurrentTenant].Add(library);
|
||||
}
|
||||
}
|
||||
|
||||
protected override Guid GetGlobalIdentifierInternal(InstanceHandle instance)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
return _CurrentTenant.GetGlobalIdentifier(instance);
|
||||
return _CurrentTenantData.GetGlobalIdentifier(instance);
|
||||
}
|
||||
protected override InstanceKey GetInstanceKeyInternal(InstanceHandle instance)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
InstanceKey ik = _CurrentTenant.GetInstanceKey(instance);
|
||||
InstanceKey ik = _CurrentTenantData.GetInstanceKey(instance);
|
||||
if (ik == InstanceKey.Empty)
|
||||
{
|
||||
// create a new instance key for this instance
|
||||
@ -248,86 +265,86 @@ public class MemoryOms : Oms
|
||||
|
||||
InstanceKey ikParentInst = GetInstanceKey(parent);
|
||||
ik = new InstanceKey(ikParentInst.InstanceIndex, i);
|
||||
_CurrentTenant.SetInstanceKey(instance, ik);
|
||||
_CurrentTenantData.SetInstanceKey(instance, ik);
|
||||
}
|
||||
return ik;
|
||||
}
|
||||
|
||||
protected override bool TryGetInstanceInternal(Guid globalIdentifier, out InstanceHandle ih)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
return _CurrentTenant.TryGetInstance(globalIdentifier, out ih);
|
||||
return _CurrentTenantData.TryGetInstance(globalIdentifier, out ih);
|
||||
}
|
||||
protected override bool TryGetInstanceInternal(InstanceKey ik, out InstanceHandle ih)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
return _CurrentTenant.TryGetInstance(ik, out ih);
|
||||
return _CurrentTenantData.TryGetInstance(ik, out ih);
|
||||
}
|
||||
|
||||
protected override void SetInstanceKeyInternal(InstanceHandle source, InstanceKey instanceKey)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
_CurrentTenant.SetInstanceKey(source, instanceKey);
|
||||
_CurrentTenantData.SetInstanceKey(source, instanceKey);
|
||||
}
|
||||
|
||||
protected override InstanceHandle CreateInstanceInternal(Guid guid)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
InstanceHandle ir = _CurrentTenant.CreateInstance(guid);
|
||||
InstanceHandle ir = _CurrentTenantData.CreateInstance(guid);
|
||||
return ir;
|
||||
}
|
||||
|
||||
protected override void ClearRelationshipInternal(InstanceHandle source, InstanceHandle relationship)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
_CurrentTenant.ClearRelationship(source, relationship);
|
||||
_CurrentTenantData.ClearRelationship(source, relationship);
|
||||
}
|
||||
|
||||
protected override void AssignRelationshipInternal(InstanceHandle source, InstanceHandle relationship, IEnumerable<InstanceHandle> targets, DateTime effectiveDate)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
_CurrentTenant.AssignRelationship(source, relationship, targets, effectiveDate);
|
||||
_CurrentTenantData.AssignRelationship(source, relationship, targets, effectiveDate);
|
||||
}
|
||||
protected override IReadOnlyCollection<InstanceHandle> GetRelatedInstancesInternal(InstanceHandle source, InstanceHandle relationship, DateTime effectiveDate)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
return _CurrentTenant.GetRelatedInstances(source, relationship, effectiveDate);
|
||||
return _CurrentTenantData.GetRelatedInstances(source, relationship, effectiveDate);
|
||||
}
|
||||
|
||||
protected override bool HasAttributeValueInternal(InstanceHandle source, InstanceHandle attribute, DateTime effectiveDate)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
return _CurrentTenant.HasAttributeValue(source, attribute, effectiveDate);
|
||||
return _CurrentTenantData.HasAttributeValue(source, attribute, effectiveDate);
|
||||
}
|
||||
protected override object? GetAttributeValueInternal(InstanceHandle source, InstanceHandle attribute, DateTime effectiveDate)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
return _CurrentTenant.GetAttributeValue(source, attribute, effectiveDate);
|
||||
return _CurrentTenantData.GetAttributeValue(source, attribute, effectiveDate);
|
||||
}
|
||||
protected override void SetAttributeValueInternal(InstanceHandle source, InstanceHandle attribute, object value, DateTime effectiveDate)
|
||||
{
|
||||
if (_CurrentTenant == null)
|
||||
if (_CurrentTenantData == null)
|
||||
throw new InvalidOperationException("Please select a tenant first.");
|
||||
|
||||
_CurrentTenant.SetAttributeValue(source, attribute, value, effectiveDate);
|
||||
_CurrentTenantData.SetAttributeValue(source, attribute, value, effectiveDate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user