43 lines
2.0 KiB
C#
43 lines
2.0 KiB
C#
// Copyright (C) 2024 Michael Becker <alcexhim@gmail.com>
|
|
//
|
|
// This file is part of Mocha.NET.
|
|
//
|
|
// Mocha.NET is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Mocha.NET is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Mocha.NET. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
namespace Mocha.Core.MethodImplementations;
|
|
|
|
public class GetSpecifiedInstancesMethodImplementation : MethodImplementation
|
|
{
|
|
public override Guid ClassGuid => KnownInstanceGuids.MethodClasses.GetSpecifiedInstancesMethod;
|
|
|
|
|
|
protected override InstanceHandle ExecuteInternal(Oms oms, OmsContext context, InstanceHandle method)
|
|
{
|
|
InstanceHandle r_Method__for__Class = oms.GetInstance(KnownRelationshipGuids.Method__for__Class);
|
|
InstanceHandle r_Get_Specified_Instances_Method__returns__Work_Set = oms.GetInstance(KnownRelationshipGuids.Get_Specified_Instances_Method__returns__Work_Set);
|
|
InstanceHandle r_Get_Specified_Instances_Method__uses__Instance = oms.GetInstance(KnownRelationshipGuids.Get_Specified_Instances_Method__uses__Instance);
|
|
|
|
InstanceHandle irForClass = oms.GetRelatedInstance(method, r_Method__for__Class);
|
|
InstanceHandle returnsWorkSet = oms.GetRelatedInstance(method, r_Get_Specified_Instances_Method__returns__Work_Set);
|
|
IReadOnlyCollection<InstanceHandle> irUsesInstance = oms.GetRelatedInstances(method, r_Get_Specified_Instances_Method__uses__Instance);
|
|
|
|
if (returnsWorkSet == InstanceHandle.Empty)
|
|
{
|
|
throw new InvalidOperationException("no Work Set specified for method");
|
|
}
|
|
|
|
context.SetWorkData(returnsWorkSet, irUsesInstance);
|
|
return returnsWorkSet;
|
|
}
|
|
} |