implement Method Binding.uses super Return Instance Set Method Binding
This commit is contained in:
parent
66c5ede6e0
commit
adf800febc
@ -1 +1 @@
|
|||||||
Subproject commit 569e302f3000e236ba562f17bc83d9e70a54fbf5
|
Subproject commit 6514615b51e61aa43ef54f6a9bc4da048cc37e4e
|
||||||
@ -435,5 +435,6 @@ namespace Mocha.Core
|
|||||||
|
|
||||||
public static Guid Get_Instances_Method__returns__Work_Set { get; } = new Guid("{7d0f93b1-8c93-464e-a44d-d674f910b589}");
|
public static Guid Get_Instances_Method__returns__Work_Set { get; } = new Guid("{7d0f93b1-8c93-464e-a44d-d674f910b589}");
|
||||||
public static Guid Get_Instances_Method__selects_instances_of__Class { get; } = new Guid("{c0b85d90-de8c-44c2-9420-c5e724ccdf2c}");
|
public static Guid Get_Instances_Method__selects_instances_of__Class { get; } = new Guid("{c0b85d90-de8c-44c2-9420-c5e724ccdf2c}");
|
||||||
|
public static Guid Method_Binding__uses_super__Return_Instance_Set_Method_Binding { get; } = new Guid("{444279f1-3bf9-4d1f-848e-e7bf33fa0fd7}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1080,6 +1080,28 @@ public abstract class Oms
|
|||||||
context.SetWorkData(assignsToParm, assignsFromWorkData);
|
context.SetWorkData(assignsToParm, assignsFromWorkData);
|
||||||
}
|
}
|
||||||
retval = ExecuteMethodBinding(context, methodOrMethodBinding);
|
retval = ExecuteMethodBinding(context, methodOrMethodBinding);
|
||||||
|
|
||||||
|
InstanceHandle ihSuperRSMB = GetRelatedInstance(methodOrMethodBinding, GetInstance(KnownRelationshipGuids.Method_Binding__uses_super__Return_Instance_Set_Method_Binding));
|
||||||
|
if (ihSuperRSMB != InstanceHandle.Empty)
|
||||||
|
{
|
||||||
|
if (retval != null)
|
||||||
|
{
|
||||||
|
object? insts = context.GetWorkData(retval.Value);
|
||||||
|
if (insts is IEnumerable<InstanceHandle> ies)
|
||||||
|
{
|
||||||
|
InstanceHandle ws2 = Execute(context, ihSuperRSMB);
|
||||||
|
object? insts2 = context.GetWorkData(ws2);
|
||||||
|
|
||||||
|
if (insts2 is IEnumerable<InstanceHandle> ies2)
|
||||||
|
{
|
||||||
|
List<InstanceHandle> list = new List<InstanceHandle>();
|
||||||
|
list.AddRange(ies2);
|
||||||
|
list.AddRange(ies);
|
||||||
|
context.SetWorkData(retval.Value, (IEnumerable<InstanceHandle>)list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -101,4 +101,39 @@ public class MethodBindingTests : MethodTestsBase
|
|||||||
*/
|
*/
|
||||||
Assert.Ignore();
|
Assert.Ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Method_Binding__uses_super__Return_Instance_Set_Method_Binding()
|
||||||
|
{
|
||||||
|
InstanceHandle c_OMS = Oms.GetInstance(KnownInstanceGuids.Classes.OMS);
|
||||||
|
InstanceHandle i_OMS = Oms.CreateInstanceOf(c_OMS);
|
||||||
|
InstanceHandle i_OMS2 = Oms.CreateInstanceOf(c_OMS);
|
||||||
|
|
||||||
|
WorkSet ws = Oms.CreateWorkSet("Singleton OMS");
|
||||||
|
|
||||||
|
Oop.Methods.GetSpecifiedInstancesMethod m1 = Oms.MethodBuilder.CreateGetSpecifiedInstancesMethod(c_OMS, "get", "Singleton", ws, new InstanceHandle[] { i_OMS });
|
||||||
|
ReturnInstanceSetMethodBinding rsmb1 = m1.CreateMethodBinding(Oms);
|
||||||
|
|
||||||
|
Oop.Methods.GetSpecifiedInstancesMethod m2 = Oms.MethodBuilder.CreateGetSpecifiedInstancesMethod(c_OMS, "get", "Singleton 2", ws, new InstanceHandle[] { i_OMS2 });
|
||||||
|
ReturnInstanceSetMethodBinding rsmb2 = m2.CreateMethodBinding(Oms);
|
||||||
|
|
||||||
|
ReturnInstanceSetMethodBinding rsmb3 = m2.CreateMethodBinding(Oms);
|
||||||
|
Oms.AssignRelationship(rsmb3.Handle, Oms.GetInstance(KnownRelationshipGuids.Method_Binding__uses_super__Return_Instance_Set_Method_Binding), rsmb1.Handle);
|
||||||
|
|
||||||
|
OmsContext context = Oms.CreateContext();
|
||||||
|
InstanceHandle valWS = Oms.Execute(context, rsmb3);
|
||||||
|
|
||||||
|
Assert.That(valWS, Is.Not.EqualTo(InstanceHandle.Empty));
|
||||||
|
|
||||||
|
object? val = context.GetWorkData(valWS);
|
||||||
|
|
||||||
|
Assert.That(val, Is.InstanceOf<IEnumerable<InstanceHandle>>());
|
||||||
|
if (val is IEnumerable<InstanceHandle> ie)
|
||||||
|
{
|
||||||
|
InstanceHandle[] ihs = ie.ToArray();
|
||||||
|
Assert.That(ihs.Length, Is.EqualTo(2));
|
||||||
|
Assert.That(ihs[0], Is.EqualTo(i_OMS));
|
||||||
|
Assert.That(ihs[1], Is.EqualTo(i_OMS2));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user