major updates to ensure all tests are passing again
This commit is contained in:
parent
dabe028bb6
commit
1b5a856dc3
@ -1 +1 @@
|
||||
Subproject commit 59c2b49e97059f18b7ef5388b0cc00345d8e1bfc
|
||||
Subproject commit ae2379b2afe380774f8a26815045d34d1f45c29e
|
||||
8
mocha-dotnet/src/lib/Mocha.Core/IInstanceReference.cs
Normal file
8
mocha-dotnet/src/lib/Mocha.Core/IInstanceReference.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace Mocha.Core;
|
||||
|
||||
public interface IInstanceReference
|
||||
{
|
||||
InstanceHandle GetHandle();
|
||||
}
|
||||
@ -44,11 +44,13 @@ namespace Mocha.Core
|
||||
/// <summary>
|
||||
/// Represents an opaque handle to an instance in a Mocha object management system (OMS).
|
||||
/// </summary>
|
||||
public struct InstanceHandle : IEquatable<InstanceHandle>
|
||||
public struct InstanceHandle : IEquatable<InstanceHandle>, IInstanceReference
|
||||
{
|
||||
private NanoId _ID;
|
||||
private bool isNotEmpty;
|
||||
|
||||
public InstanceHandle GetHandle() { return this; }
|
||||
|
||||
public static InstanceHandle Create()
|
||||
{
|
||||
InstanceHandle handle = new InstanceHandle();
|
||||
|
||||
@ -204,9 +204,9 @@ namespace Mocha.Core
|
||||
}
|
||||
public static class ConditionalSelectAttribute
|
||||
{
|
||||
// public static Guid Method__get__Method_Abbreviation { get; } = new Guid("{f0c64709-385d-481b-8f58-83e507fb261c}");
|
||||
public static Guid Method__get__Method_Abbreviation { get; } = new Guid("{ddb62bd1-df5a-4c9d-9991-ff9a827717e9}");
|
||||
public static Guid Method_Binding__get__Method_Binding_Abbreviation { get; } = new Guid("{7154cb08-0f80-4af4-bca5-c2c12e54479a}");
|
||||
// public static Guid Method__get__Abbreviation { get; } = new Guid("{f0c64709-385d-481b-8f58-83e507fb261c}");
|
||||
public static Guid Method__get__Abbreviation { get; } = new Guid("{ddb62bd1-df5a-4c9d-9991-ff9a827717e9}");
|
||||
public static Guid Method_Binding__get__Abbreviation { get; } = new Guid("{4c7a3419-7ed3-4b0b-99ab-f499807871a1}"); // {7154cb08-0f80-4af4-bca5-c2c12e54479a}
|
||||
}
|
||||
public static class GetAttributeBySystemRoutine
|
||||
{
|
||||
|
||||
@ -155,8 +155,9 @@ namespace Mocha.Core
|
||||
public static Guid System_Instance_Set_Routine__used_by__Get_Instance_Set_by_System_Routine_Method { get; } = new Guid("{6fb6534c-2a46-4d6d-b9df-fd581f19efed}");
|
||||
|
||||
|
||||
public static Guid Get_Referenced_Instance_Set_Method__loop_on__Instance_Set { get; } = new Guid("{2978238f-7cb0-4ba3-8c6f-473df782cfef}");
|
||||
public static Guid Get_Referenced_Instance_Set_Method__has_relationship__Method { get; } = new Guid("{6a65819e-c8cb-4575-9af8-ee221364049b}");
|
||||
public static Guid Get_Referenced_Instance_Set_Method__returns__Work_Set { get; } = new Guid("{72057f5b-9b49-497d-852f-cd7e5e258d6c}");
|
||||
public static Guid Get_Referenced_Instance_Set_Method__uses_reference__Executable_returning_Instance_Set { get; } = new Guid("{2978238f-7cb0-4ba3-8c6f-473df782cfef}");
|
||||
public static Guid Get_Referenced_Instance_Set_Method__uses_answer__Executable_returning_Instance_Set { get; } = new Guid("{6a65819e-c8cb-4575-9af8-ee221364049b}");
|
||||
|
||||
public static Guid Get_Referenced_Attribute_Method__returns__Attribute { get; } = new Guid("{87f90fe9-5ec6-4b09-8f51-b8a4d1544cae}");
|
||||
public static Guid Attribute__returned_by__Get_Referenced_Attribute_Method { get; } = new Guid("{80e4ffd8-77d8-4835-a4e0-73a176e7f646}");
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
// along with Mocha.NET. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
using System.Formats.Asn1;
|
||||
using System.Security.Cryptography;
|
||||
using MBS.Core.Collections;
|
||||
|
||||
namespace Mocha.Core.MethodImplementations;
|
||||
@ -56,6 +57,10 @@ public class EvaluateBooleanExpressionMethodImplementation : MethodImplementatio
|
||||
{
|
||||
rsource_value = (InstanceHandle[])rsource_valueraw;
|
||||
}
|
||||
else if (rsource_valueraw is InstanceHandle)
|
||||
{
|
||||
rsource_value = new InstanceHandle[] { (InstanceHandle)rsource_valueraw };
|
||||
}
|
||||
|
||||
if (oms.IsInstanceOf(target, c_Class))
|
||||
{
|
||||
@ -76,6 +81,34 @@ public class EvaluateBooleanExpressionMethodImplementation : MethodImplementatio
|
||||
value = true;
|
||||
}
|
||||
}
|
||||
else if (comparison == oms.GetInstance(KnownInstanceGuids.RelationalOperators.ExactMatchWithSelectionList))
|
||||
{
|
||||
if (rtarget_value.Length == rsource_value.Length)
|
||||
{
|
||||
List<InstanceHandle> l1 = new List<InstanceHandle>(rsource_value);
|
||||
List<InstanceHandle> l2 = new List<InstanceHandle>(rtarget_value);
|
||||
l1.Sort();
|
||||
l2.Sort();
|
||||
|
||||
value = true;
|
||||
for (int i = 0; i < l1.Count; i++)
|
||||
{
|
||||
if (!l1[i].Equals(l2[i]))
|
||||
{
|
||||
value = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException(String.Format("relational operator '{0}' not implemented", comparison));
|
||||
}
|
||||
|
||||
context.SetWorkData(returnsAttribute, value);
|
||||
return returnsAttribute;
|
||||
|
||||
@ -0,0 +1,78 @@
|
||||
// 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 GetReferencedInstanceSetMethodImplementation : MethodImplementation
|
||||
{
|
||||
public override Guid MethodClassGuid => KnownInstanceGuids.MethodClasses.GetReferencedInstanceSetMethod;
|
||||
protected override InstanceHandle ExecuteInternal(Oms oms, OmsContext context, InstanceHandle method)
|
||||
{
|
||||
Guid methodId = oms.GetGlobalIdentifier(method);
|
||||
|
||||
InstanceHandle irForClass = oms.GetRelatedInstance(method, oms.GetInstance(KnownRelationshipGuids.Method__for__Class));
|
||||
|
||||
InstanceHandle returnsWorkSet = oms.GetRelatedInstance(method, oms.GetInstance(KnownRelationshipGuids.Get_Referenced_Instance_Set_Method__returns__Work_Set));
|
||||
InstanceHandle referenceInstanceSet = oms.GetRelatedInstance(method, oms.GetInstance(KnownRelationshipGuids.Get_Referenced_Instance_Set_Method__uses_reference__Executable_returning_Instance_Set));
|
||||
InstanceHandle answerInstanceSet = oms.GetRelatedInstance(method, oms.GetInstance(KnownRelationshipGuids.Get_Referenced_Instance_Set_Method__uses_answer__Executable_returning_Instance_Set));
|
||||
|
||||
if (returnsWorkSet == InstanceHandle.Empty)
|
||||
{
|
||||
throw new InvalidOperationException(String.Format("no return Work Set specified for method {0}", methodId));
|
||||
}
|
||||
|
||||
InstanceHandle referenceInstanceSetWS = referenceInstanceSet;
|
||||
if (oms.IsInstanceOf(referenceInstanceSet, oms.GetInstance(KnownInstanceGuids.Classes.Executable)))
|
||||
{
|
||||
referenceInstanceSetWS = oms.Execute(context, referenceInstanceSet);
|
||||
}
|
||||
|
||||
object? referenceInstanceSetValue = context.GetWorkData(referenceInstanceSetWS);
|
||||
if (referenceInstanceSetValue is InstanceHandle)
|
||||
{
|
||||
// singular
|
||||
referenceInstanceSetValue = new InstanceHandle[] { (InstanceHandle)referenceInstanceSetValue };
|
||||
}
|
||||
|
||||
if (referenceInstanceSetValue is IReadOnlyCollection<InstanceHandle>)
|
||||
{
|
||||
IReadOnlyCollection<InstanceHandle> list = (IReadOnlyCollection<InstanceHandle>)referenceInstanceSetValue;
|
||||
object? retval = null;
|
||||
|
||||
foreach (InstanceHandle inst in list)
|
||||
{
|
||||
InstanceHandle pclass = oms.GetParentClass(inst);
|
||||
context.SetWorkData(pclass, inst);
|
||||
|
||||
InstanceHandle answerInstanceSetWD = answerInstanceSet;
|
||||
if (oms.IsInstanceOf(answerInstanceSet, oms.GetInstance(KnownInstanceGuids.Classes.Executable)))
|
||||
{
|
||||
answerInstanceSetWD = oms.Execute(context, answerInstanceSet);
|
||||
}
|
||||
|
||||
object? answerInstanceSetValue = context.GetWorkData(answerInstanceSetWD);
|
||||
retval = answerInstanceSetValue;
|
||||
}
|
||||
context.SetWorkData(returnsWorkSet, retval);
|
||||
}
|
||||
|
||||
// 1$12740 NIM - Native Instance Set Method
|
||||
// 1$12741 NAM - Native Attribute Method
|
||||
// 1$12742 NUM - Native Update Method
|
||||
return returnsWorkSet;
|
||||
}
|
||||
}
|
||||
@ -60,20 +60,27 @@ public class SelectFromInstanceSetMethodImplementation : MethodImplementation
|
||||
IEnumerable<InstanceWrapper> vals = (IEnumerable<InstanceWrapper>)instanceSetValues;
|
||||
foreach (InstanceWrapper inst in vals)
|
||||
{
|
||||
OrderableData od = new OrderableData();
|
||||
od.Data = inst.Handle;
|
||||
if (orderAttribute != InstanceHandle.Empty)
|
||||
if (inst != null)
|
||||
{
|
||||
InstanceHandle ihWorkData = oms.Execute(context, orderAttribute, inst.Handle);
|
||||
string order = context.GetWorkData<string>(ihWorkData);
|
||||
OrderableData od = new OrderableData();
|
||||
od.Data = inst.Handle;
|
||||
if (orderAttribute != InstanceHandle.Empty)
|
||||
{
|
||||
InstanceHandle ihWorkData = oms.Execute(context, orderAttribute, inst.Handle);
|
||||
string order = context.GetWorkData<string>(ihWorkData);
|
||||
|
||||
od.Order = order;
|
||||
od.Order = order;
|
||||
}
|
||||
else
|
||||
{
|
||||
od.Order = String.Empty;
|
||||
}
|
||||
list.Add(od);
|
||||
}
|
||||
else
|
||||
{
|
||||
od.Order = String.Empty;
|
||||
|
||||
}
|
||||
list.Add(od);
|
||||
}
|
||||
|
||||
list.Sort((c, d) => c.Order.CompareTo(d.Order));
|
||||
|
||||
@ -64,10 +64,39 @@ public abstract class Oms
|
||||
{
|
||||
InitializeInternal();
|
||||
|
||||
AccessModifier.Private = new AccessModifier(GetInstance(KnownInstanceGuids.AccessModifiers.Private));
|
||||
AccessModifier.Protected = new AccessModifier(GetInstance(KnownInstanceGuids.AccessModifiers.Protected));
|
||||
AccessModifier.Public = new AccessModifier(GetInstance(KnownInstanceGuids.AccessModifiers.Public));
|
||||
AccessModifier.RootA2 = new AccessModifier(GetInstance(KnownInstanceGuids.AccessModifiers.RootA2));
|
||||
|
||||
PropertyInfo[] pis = typeof(RelationalOperator).GetProperties(BindingFlags.Static | BindingFlags.Public);
|
||||
foreach (PropertyInfo pi in pis)
|
||||
{
|
||||
PropertyInfo pi2 = typeof(KnownInstanceGuids.RelationalOperators).GetProperty(pi.Name, BindingFlags.Public | BindingFlags.Static);
|
||||
Guid guid = (Guid)pi2.GetValue(null);
|
||||
|
||||
pi.SetValue(null, new RelationalOperator(GetInstance(guid)));
|
||||
}
|
||||
|
||||
RegisterSystemRoutine(KnownInstanceGuids.SystemAttributeRoutines.GetRuntimeVersion, new SystemAttributeRoutine<string>(this, KnownInstanceGuids.SystemAttributeRoutines.GetRuntimeVersion, delegate (Oms oms, OmsContext context)
|
||||
{
|
||||
return RuntimeVersion.ToString();
|
||||
}));
|
||||
RegisterSystemRoutine(KnownInstanceGuids.SystemAttributeRoutines.GetRandomNumber, new SystemAttributeRoutine<decimal>(this, KnownInstanceGuids.SystemAttributeRoutines.GetRuntimeVersion, delegate (Oms oms, OmsContext context)
|
||||
{
|
||||
object? oSeed = context.GetWorkData(oms.GetInstance(KnownAttributeGuids.Numeric.Seed));
|
||||
|
||||
Random r;
|
||||
if (oSeed != null)
|
||||
{
|
||||
r = new Random((int)((decimal)oSeed));
|
||||
}
|
||||
else
|
||||
{
|
||||
r = new Random();
|
||||
}
|
||||
return (decimal)r.NextDouble();
|
||||
}));
|
||||
|
||||
DebugOms = this;
|
||||
}
|
||||
@ -239,11 +268,16 @@ public abstract class Oms
|
||||
ConcreteInstanceWrapper ci = (ConcreteInstanceWrapper) tType.Assembly.CreateInstance(tType.FullName, false, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { ih }, null, null);
|
||||
if (ci != null)
|
||||
{
|
||||
// Conditional Select Attribute Method !== Return Attribute Method Binding
|
||||
if (ci.ClassId == GetGlobalIdentifier(parentClass))
|
||||
{
|
||||
instance = (T)ci;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("cannot cast inst");
|
||||
}
|
||||
}
|
||||
}
|
||||
instance = null;
|
||||
@ -373,6 +407,21 @@ public abstract class Oms
|
||||
value = (T)val;
|
||||
return true;
|
||||
}
|
||||
else if (val is string && typeof(T) == typeof(bool))
|
||||
{
|
||||
// HACK HACK HACK - fix the underlying assignment so it assigns boolean true instead of string "True"
|
||||
// !!! !!! !!! it's probably in the yaml2mcl compiler somewhere
|
||||
if (val.ToString().ToLower().Equals("true"))
|
||||
{
|
||||
value = (T)((object)true);
|
||||
return true;
|
||||
}
|
||||
else if (val.ToString().ToLower().Equals("false"))
|
||||
{
|
||||
value = (T)((object)false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
value = default(T);
|
||||
@ -682,6 +731,16 @@ public abstract class Oms
|
||||
methodImplementations[methodClassId] = implementation;
|
||||
}
|
||||
|
||||
public InstanceHandle Execute(OmsContext context, MethodBinding methodBinding, IInstanceWrapper? targetInstance = null)
|
||||
{
|
||||
InstanceHandle? targetInstanceHandle = null;
|
||||
if (targetInstance != null)
|
||||
{
|
||||
targetInstanceHandle = targetInstance.Handle;
|
||||
}
|
||||
return Execute(context, methodBinding, targetInstanceHandle);
|
||||
}
|
||||
|
||||
public InstanceHandle Execute(OmsContext context, MethodBinding methodBinding, InstanceHandle? targetInstance = null)
|
||||
{
|
||||
return Execute(context, methodBinding.Handle, targetInstance);
|
||||
@ -1200,4 +1259,24 @@ public abstract class Oms
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool TryGetSingularInstance(object? oih, out InstanceHandle ih)
|
||||
{
|
||||
ih = InstanceHandle.Empty;
|
||||
if (oih == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (oih is InstanceHandle)
|
||||
{
|
||||
ih = (InstanceHandle)oih;
|
||||
return true;
|
||||
}
|
||||
else if (oih is InstanceHandle[] && ((InstanceHandle[])oih).Length > 0)
|
||||
{
|
||||
ih = ((InstanceHandle[])oih)[0];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,67 +262,5 @@ public class MethodsModule : MiniOmsModule
|
||||
}
|
||||
return (decimal)(new Random()).NextDouble();
|
||||
})));
|
||||
|
||||
CreateGetMethodAbbreviation(oms);
|
||||
CreateGetMethodBindingAbbreviation(oms);
|
||||
}
|
||||
|
||||
private void CreateGetMethodAbbreviation(Oms oms)
|
||||
{
|
||||
OmsMethodBuilder mb = new OmsMethodBuilder(oms);
|
||||
GetRelationshipMethod Instance__get__Parent_Class = oms.GetInstance<GetRelationshipMethod>(KnownInstanceGuids.Methods.GetRelationship.Instance__get__Parent_Class);
|
||||
|
||||
ReturnInstanceSetMethodBinding Instance__get__Parent_Class_rsmb = Instance__get__Parent_Class.CreateMethodBinding(oms, new KeyValuePair<InstanceHandle, object?>[]
|
||||
{
|
||||
new KeyValuePair<InstanceHandle, object?>(c_Instance, c_Method)
|
||||
});
|
||||
|
||||
BuildAttributeMethod Method__get__SAC_Method_Suffix = mb.CreateBuildAttributeMethod(c_Method, "get", "SAC Method Suffix", AccessModifier.Public, true, a_Value, "SAC");
|
||||
EvaluateBooleanExpressionMethod Method__is__Conditional_Select_Attribute_Method = mb.CreateEvaluateBooleanExpressionMethod(c_Method, "is", "SAC", AccessModifier.Public, false, oms.GetInstance(KnownAttributeGuids.Boolean.MethodIsOfTypeSpecified), Instance__get__Parent_Class_rsmb.Handle, RelationalOperator.InSelectionList, oms.GetInstance(KnownInstanceGuids.MethodClasses.ConditionalSelectAttributeMethod));
|
||||
|
||||
BuildAttributeMethod Method__get__GAS_Method_Suffix = mb.CreateBuildAttributeMethod(c_Method, "get", "GAS Method Suffix", AccessModifier.Public, true, a_Value, "GAS");
|
||||
EvaluateBooleanExpressionMethod Method__is__Get_Attribute_by_System_Routine_Method = mb.CreateEvaluateBooleanExpressionMethod(c_Method, "is", "GAS", AccessModifier.Public, false, oms.GetInstance(KnownAttributeGuids.Boolean.MethodIsOfTypeSpecified), Instance__get__Parent_Class_rsmb.Handle, RelationalOperator.InSelectionList, oms.GetInstance(KnownInstanceGuids.MethodClasses.GetAttributeBySystemRoutineMethod));
|
||||
|
||||
BuildAttributeMethod Method__get__GR_Method_Suffix = mb.CreateBuildAttributeMethod(c_Method, "get", "GR Method Suffix", AccessModifier.Public, true, a_Value, "GR");
|
||||
EvaluateBooleanExpressionMethod Method__is__Get_Relationship_Method = mb.CreateEvaluateBooleanExpressionMethod(c_Method, "is", "GR", AccessModifier.Public, false, oms.GetInstance(KnownAttributeGuids.Boolean.MethodIsOfTypeSpecified), Instance__get__Parent_Class_rsmb.Handle, RelationalOperator.InSelectionList, oms.GetInstance(KnownInstanceGuids.MethodClasses.GetRelationshipMethod));
|
||||
|
||||
mb.CreateConditionalSelectAttributeMethod(c_Method, "get", "Method Abbreviation", AccessModifier.Public, false, KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Method_Abbreviation, a_Value, new ConditionalSelectAttributeCase[]
|
||||
{
|
||||
new ConditionalSelectAttributeCase(new IExecutableReturningAttribute[] { Method__is__Get_Attribute_by_System_Routine_Method.CreateMethodBinding(oms) }, null, false, Method__get__GAS_Method_Suffix.CreateMethodBinding(oms)),
|
||||
new ConditionalSelectAttributeCase(new IExecutableReturningAttribute[] { Method__is__Get_Relationship_Method.CreateMethodBinding(oms) }, null, false, Method__get__GR_Method_Suffix.CreateMethodBinding(oms)),
|
||||
new ConditionalSelectAttributeCase(new IExecutableReturningAttribute[] { Method__is__Conditional_Select_Attribute_Method.CreateMethodBinding(oms) }, null, false, Method__get__SAC_Method_Suffix.CreateMethodBinding(oms))
|
||||
});
|
||||
}
|
||||
|
||||
private void CreateGetMethodBindingAbbreviation(Oms oms)
|
||||
{
|
||||
OmsMethodBuilder mb = new OmsMethodBuilder(oms);
|
||||
|
||||
GetRelationshipMethod Instance__get__Parent_Class = oms.GetInstance<GetRelationshipMethod>(KnownInstanceGuids.Methods.GetRelationship.Instance__get__Parent_Class);
|
||||
ReturnInstanceSetMethodBinding Instance__get__Parent_Class_rsmb = Instance__get__Parent_Class.CreateMethodBinding(oms, new KeyValuePair<InstanceHandle, object?>[]
|
||||
{
|
||||
new KeyValuePair<InstanceHandle, object?>(c_Instance, c_MethodBinding)
|
||||
});
|
||||
KnownInstanceGuids.Methods.GetRelationship.Instance__get__Parent_Class__for__Method_Binding__HACK = oms.GetGlobalIdentifier(Instance__get__Parent_Class_rsmb.Handle);
|
||||
|
||||
// RAMB
|
||||
BuildAttributeMethod Method_Binding__get__RAMB_Method_Binding_Suffix = mb.CreateBuildAttributeMethod(c_MethodBinding, "get", "RAMB Method Suffix", AccessModifier.Public, true, a_Value, "ramb");
|
||||
ReturnAttributeMethodBinding Method_Binding__get__RAMB_Method_Binding_Suffix_ramb = Method_Binding__get__RAMB_Method_Binding_Suffix.CreateMethodBinding(oms);
|
||||
|
||||
EvaluateBooleanExpressionMethod Method_Binding__is__Return_Attribute_Method_Binding = mb.CreateEvaluateBooleanExpressionMethod(c_MethodBinding, "is", "RAMB", AccessModifier.Public, false, oms.GetInstance(KnownAttributeGuids.Boolean.MethodIsOfTypeSpecified), Instance__get__Parent_Class_rsmb.Handle, RelationalOperator.InSelectionList, oms.GetInstance(KnownInstanceGuids.Classes.ReturnAttributeMethodBinding));
|
||||
ReturnAttributeMethodBinding Method_Binding__is__Return_Attribute_Method_Binding_ramb = Method_Binding__is__Return_Attribute_Method_Binding.CreateMethodBinding(oms);
|
||||
|
||||
// RSMB
|
||||
BuildAttributeMethod Method_Binding__get__RSMB_Method_Binding_Suffix = mb.CreateBuildAttributeMethod(c_MethodBinding, "get", "RSMB Method Suffix", AccessModifier.Public, true, a_Value, "rsmb");
|
||||
ReturnAttributeMethodBinding Method_Binding__get__RSMB_Method_Binding_Suffix_ramb = Method_Binding__get__RSMB_Method_Binding_Suffix.CreateMethodBinding(oms);
|
||||
|
||||
EvaluateBooleanExpressionMethod Method_Binding__is__Return_Instance_Set_Method_Binding = mb.CreateEvaluateBooleanExpressionMethod(c_MethodBinding, "is", "RSMB", AccessModifier.Public, false, oms.GetInstance(KnownAttributeGuids.Boolean.MethodIsOfTypeSpecified), Instance__get__Parent_Class_rsmb.Handle, RelationalOperator.InSelectionList, oms.GetInstance(KnownInstanceGuids.Classes.ReturnInstanceSetMethodBinding));
|
||||
ReturnAttributeMethodBinding Method_Binding__is__Return_Instance_Set_Method_Binding_ramb = Method_Binding__is__Return_Instance_Set_Method_Binding.CreateMethodBinding(oms);
|
||||
|
||||
ConditionalSelectAttributeMethod sac = mb.CreateConditionalSelectAttributeMethod(c_MethodBinding, "get", "Method Binding Abbreviation", AccessModifier.Public, false, KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method_Binding__get__Method_Binding_Abbreviation, a_Value, new ConditionalSelectAttributeCase[]
|
||||
{
|
||||
new ConditionalSelectAttributeCase(new IExecutableReturningAttribute[] { Method_Binding__is__Return_Attribute_Method_Binding_ramb }, null, false, Method_Binding__get__RAMB_Method_Binding_Suffix_ramb),
|
||||
new ConditionalSelectAttributeCase(new IExecutableReturningAttribute[] { Method_Binding__is__Return_Instance_Set_Method_Binding_ramb }, null, false, Method_Binding__get__RSMB_Method_Binding_Suffix_ramb)
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -66,18 +66,18 @@ public class UserInterfaceModule : MiniOmsModule
|
||||
oms.CreateRelationship(c_ControlTransactionMethod, "uses", c_BuildResponseMethodBinding, KnownRelationshipGuids.Control_Transaction_Method__uses__Build_Response_Method_Binding, true, "used by", KnownRelationshipGuids.Build_Response_Method_Binding__used_by__Control_Transaction_Method);
|
||||
oms.AddSuperClass(c_ControlTransactionMethod, c_Method);
|
||||
|
||||
InstanceHandle i_Method__get__Method_Abbreviation = oms.GetInstance(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Method_Abbreviation);
|
||||
InstanceHandle i_Method__get__Abbreviation = oms.GetInstance(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Abbreviation);
|
||||
|
||||
OmsMethodBuilder mb = new OmsMethodBuilder(oms);
|
||||
|
||||
InstanceHandle Method_Binding__get__Method_Binding_Abbreviation = oms.GetInstance(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method_Binding__get__Method_Binding_Abbreviation);
|
||||
// InstanceHandle Method_Binding__get__Method_Binding_Abbreviation = oms.GetInstance(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method_Binding__get__Method_Binding_Abbreviation);
|
||||
InstanceHandle a_Value = oms.GetInstance(KnownAttributeGuids.Text.Value);
|
||||
InstanceHandle Instance__get__Parent_Class_rsmb = oms.GetInstance(KnownInstanceGuids.Methods.GetRelationship.Instance__get__Parent_Class__for__Method_Binding__HACK);
|
||||
BuildAttributeMethod Method__get__CT_Method_Suffix = mb.CreateBuildAttributeMethod(c_Method, "get", "CT Method Suffix", AccessModifier.Public, true, a_Value, "CT");
|
||||
EvaluateBooleanExpressionMethod Method__is__CT = mb.CreateEvaluateBooleanExpressionMethod(c_Method, "is", "CT", AccessModifier.Public, false, oms.GetInstance(KnownAttributeGuids.Boolean.MethodIsOfTypeSpecified), Instance__get__Parent_Class_rsmb, RelationalOperator.InSelectionList, oms.GetInstance(KnownInstanceGuids.MethodClasses.ControlTransactionMethod));
|
||||
|
||||
ConditionalSelectAttributeCase i_CT_Case = new ConditionalSelectAttributeCase(new IExecutableReturningAttribute[] { Method__is__CT.CreateMethodBinding(oms) }, null, false, Method__get__CT_Method_Suffix.CreateMethodBinding(oms));
|
||||
mb.AddConditionalSelectAttributeCase(new ConditionalSelectAttributeMethod(Method_Binding__get__Method_Binding_Abbreviation), i_CT_Case);
|
||||
// ConditionalSelectAttributeCase i_CT_Case = new ConditionalSelectAttributeCase(new IExecutableReturningAttribute[] { Method__is__CT.CreateMethodBinding(oms) }, null, false, Method__get__CT_Method_Suffix.CreateMethodBinding(oms));
|
||||
// mb.AddConditionalSelectAttributeCase(new ConditionalSelectAttributeMethod(Method_Binding__get__Method_Binding_Abbreviation), i_CT_Case);
|
||||
|
||||
InstanceHandle c_Menu = oms.CreateClass("Menu", KnownInstanceGuids.Classes.Menu);
|
||||
InstanceHandle c_MenuItem = oms.CreateClass("Menu Item", KnownInstanceGuids.Classes.MenuItem);
|
||||
|
||||
@ -35,12 +35,14 @@ public class ConditionalSelectAttributeMethodTests : MethodTestsBase
|
||||
public string Get_Method_Abbreviation(Guid instanceGuid)
|
||||
{
|
||||
InstanceHandle c_Method = Oms.GetInstance(KnownInstanceGuids.Classes.Method);
|
||||
|
||||
InstanceHandle i_c_Method = Oms.CreateInstanceOf(Oms.GetInstance(instanceGuid));
|
||||
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Method_Abbreviation);
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Abbreviation);
|
||||
ReturnAttributeMethodBinding ramb = sac.CreateMethodBinding(Oms);
|
||||
|
||||
OmsContext context = Oms.CreateContext();
|
||||
context.SetWorkData(c_Method, sac);
|
||||
context.SetWorkData(c_Method, i_c_Method);
|
||||
|
||||
InstanceHandle wd = Oms.Execute(context, ramb);
|
||||
object? value = context.GetWorkData(wd);
|
||||
@ -60,7 +62,7 @@ public class ConditionalSelectAttributeMethodTests : MethodTestsBase
|
||||
{
|
||||
InstanceHandle c_Method = Oms.GetInstance(KnownInstanceGuids.Classes.Method);
|
||||
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Method_Abbreviation);
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Abbreviation);
|
||||
ReturnAttributeMethodBinding ramb = sac.CreateMethodBinding(Oms);
|
||||
|
||||
OmsContext context = Oms.CreateContext();
|
||||
@ -78,7 +80,7 @@ public class ConditionalSelectAttributeMethodTests : MethodTestsBase
|
||||
{
|
||||
InstanceHandle c_Method = Oms.GetInstance(KnownInstanceGuids.Classes.Method);
|
||||
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Method_Abbreviation);
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Abbreviation);
|
||||
ReturnAttributeMethodBinding ramb = sac.CreateMethodBinding(Oms);
|
||||
|
||||
GetRelationshipMethod Instance__get__Class = Oms.GetInstance<GetRelationshipMethod>(KnownInstanceGuids.Methods.GetRelationship.Instance__get__Parent_Class);
|
||||
@ -98,7 +100,7 @@ public class ConditionalSelectAttributeMethodTests : MethodTestsBase
|
||||
{
|
||||
InstanceHandle c_Method = Oms.GetInstance(KnownInstanceGuids.Classes.Method);
|
||||
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Method_Abbreviation);
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Abbreviation);
|
||||
ReturnAttributeMethodBinding ramb = sac.CreateMethodBinding(Oms);
|
||||
|
||||
GetAttributeBySystemRoutineMethod OMS__get__Runtime_Version = Oms.GetInstance<GetAttributeBySystemRoutineMethod>(KnownInstanceGuids.Methods.GetAttributeBySystemRoutine.OMS__get__Runtime_Version);
|
||||
@ -118,7 +120,7 @@ public class ConditionalSelectAttributeMethodTests : MethodTestsBase
|
||||
{
|
||||
InstanceHandle c_MethodBinding = Oms.GetInstance(KnownInstanceGuids.Classes.MethodBinding);
|
||||
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method_Binding__get__Method_Binding_Abbreviation);
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method_Binding__get__Abbreviation);
|
||||
ReturnAttributeMethodBinding ramb = sac.CreateMethodBinding(Oms);
|
||||
|
||||
OmsContext context = Oms.CreateContext();
|
||||
@ -136,7 +138,7 @@ public class ConditionalSelectAttributeMethodTests : MethodTestsBase
|
||||
{
|
||||
InstanceHandle c_MethodBinding = Oms.GetInstance(KnownInstanceGuids.Classes.MethodBinding);
|
||||
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method_Binding__get__Method_Binding_Abbreviation);
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method_Binding__get__Abbreviation);
|
||||
ReturnAttributeMethodBinding ramb = sac.CreateMethodBinding(Oms);
|
||||
|
||||
GetRelationshipMethod Instance__get__Class = Oms.GetInstance<GetRelationshipMethod>(KnownInstanceGuids.Methods.GetRelationship.Instance__get__Parent_Class);
|
||||
|
||||
@ -37,10 +37,8 @@ public class EvaluateBooleanExpressionMethodTests : MethodTestsBase
|
||||
context.SetWorkData(c_Instance, Instance__get__Parent_Class);
|
||||
InstanceHandle wsRet = Oms.Execute(context, Instance__get__Parent_Class);
|
||||
|
||||
// FIXME: this should be singular
|
||||
InstanceHandle[] pclass = (InstanceHandle[])context.GetWorkData(wsRet);
|
||||
|
||||
Assert.That(pclass[0], Is.EqualTo(Oms.GetInstance(KnownInstanceGuids.MethodClasses.GetRelationshipMethod)));
|
||||
InstanceHandle pclass = (InstanceHandle)context.GetWorkData(wsRet);
|
||||
Assert.That(pclass, Is.EqualTo(Oms.GetInstance(KnownInstanceGuids.MethodClasses.GetRelationshipMethod)));
|
||||
|
||||
|
||||
EvaluateBooleanExpressionMethod Method__is__Conditional_Select_Attribute_Method = methodBuilder.CreateEvaluateBooleanExpressionMethod(c_Method, "is", "SAC", AccessModifier.Public, false, Oms.GetInstance(KnownAttributeGuids.Boolean.MethodIsOfTypeSpecified), Instance__get__Parent_Class_rsmb.Handle, RelationalOperator.InSelectionList, Oms.GetInstance(KnownInstanceGuids.MethodClasses.ConditionalSelectAttributeMethod));
|
||||
@ -73,10 +71,8 @@ public class EvaluateBooleanExpressionMethodTests : MethodTestsBase
|
||||
context.SetWorkData(c_Instance, Instance__get__Parent_Class);
|
||||
InstanceHandle wsRet = Oms.Execute(context, Instance__get__Parent_Class);
|
||||
|
||||
// FIXME: this should be singular
|
||||
InstanceHandle[] pclass = (InstanceHandle[]) context.GetWorkData(wsRet);
|
||||
|
||||
Assert.That(pclass[0], Is.EqualTo(Oms.GetInstance(KnownInstanceGuids.MethodClasses.GetRelationshipMethod)));
|
||||
InstanceHandle pclass = (InstanceHandle) context.GetWorkData(wsRet);
|
||||
Assert.That(pclass, Is.EqualTo(Oms.GetInstance(KnownInstanceGuids.MethodClasses.GetRelationshipMethod)));
|
||||
|
||||
EvaluateBooleanExpressionMethod Method__is__Conditional_Select_Attribute_Method = methodBuilder.CreateEvaluateBooleanExpressionMethod(c_Method, "is", "SAC", AccessModifier.Public, false, Oms.GetInstance(KnownAttributeGuids.Boolean.MethodIsOfTypeSpecified), Instance__get__Parent_Class_rsmb.Handle, RelationalOperator.InSelectionList, Oms.GetInstance(KnownInstanceGuids.MethodClasses.ConditionalSelectAttributeMethod));
|
||||
ReturnAttributeMethodBinding Method__is__Conditional_Select_Attribute_Method_ramb = Method__is__Conditional_Select_Attribute_Method.CreateMethodBinding(Oms);
|
||||
|
||||
@ -61,4 +61,30 @@ public class GetRelationshipTests : MethodTestsBase
|
||||
object? value = context.GetWorkData(workSet);
|
||||
Assert.That(value, Is.EqualTo(c_TestClass));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetMethodType()
|
||||
{
|
||||
ConditionalSelectAttributeMethod sac = Oms.GetInstance<ConditionalSelectAttributeMethod>(KnownInstanceGuids.Methods.ConditionalSelectAttribute.Method__get__Abbreviation);
|
||||
ReturnAttributeMethodBinding ramb = sac.CreateMethodBinding(Oms);
|
||||
|
||||
GetRelationshipMethod m_GetParentClass = Oms.GetInstance<GetRelationshipMethod>(KnownInstanceGuids.Methods.GetRelationship.Instance__get__Parent_Class);
|
||||
ReturnInstanceSetMethodBinding rsmb = m_GetParentClass.CreateMethodBinding(Oms);
|
||||
|
||||
OmsContext context = Oms.CreateContext();
|
||||
context.SetWorkData(Oms.GetInstance(KnownInstanceGuids.Classes.Instance), sac);
|
||||
|
||||
InstanceHandle ihResult = Oms.Execute(context, rsmb, sac);
|
||||
|
||||
object? oih = context.GetWorkData(ihResult);
|
||||
if (Oms.TryGetSingularInstance(oih, out InstanceHandle ih))
|
||||
{
|
||||
InstanceHandle ihRealParent = Oms.GetParentClass(sac.Handle);
|
||||
Assert.That(ih, Is.EqualTo(ihRealParent));
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Fail("Method did not return at least one InstanceHandle");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -52,7 +52,7 @@ public class SelectFromInstanceSetMethodTests : MethodTestsBase
|
||||
AccessModifier.RootA2
|
||||
});
|
||||
|
||||
InstanceHandle workData = Oms.Execute(context, rsmb, null);
|
||||
InstanceHandle workData = Oms.Execute(context, rsmb);
|
||||
object? value = context.GetWorkData(workData);
|
||||
|
||||
Assert.That(value is InstanceHandle);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user