should not need to actually realize the InstanceHandle in order to register a SystemRoutine
This commit is contained in:
parent
cf870659d2
commit
9f0832f5fc
@ -1 +1 @@
|
|||||||
Subproject commit 12ac9ab8c068f850ec7a3850e95562accbe91725
|
Subproject commit 276a8c031f0b4c7fcc9a349b15bcd08686a2ae06
|
||||||
@ -81,7 +81,6 @@ public class Program : MochaWebApplication
|
|||||||
{
|
{
|
||||||
// FIXME! : selecting tenant doesn't seem to be working, routes get overwritten / not created
|
// FIXME! : selecting tenant doesn't seem to be working, routes get overwritten / not created
|
||||||
oms.SelectTenant(t_super);
|
oms.SelectTenant(t_super);
|
||||||
oms.AddLibraryReference(l_System);
|
|
||||||
|
|
||||||
InstanceHandle c_Application = oms.GetInstance(KnownInstanceGuids.Classes.Application);
|
InstanceHandle c_Application = oms.GetInstance(KnownInstanceGuids.Classes.Application);
|
||||||
InstanceHandle i_Application = oms.CreateInstanceOf(c_Application, new Guid("{773f6c6e-6cef-4a04-b333-ac097c0ab705}"));
|
InstanceHandle i_Application = oms.CreateInstanceOf(c_Application, new Guid("{773f6c6e-6cef-4a04-b333-ac097c0ab705}"));
|
||||||
|
|||||||
@ -64,13 +64,11 @@ public abstract class Oms
|
|||||||
{
|
{
|
||||||
InitializeInternal();
|
InitializeInternal();
|
||||||
|
|
||||||
if (TryGetInstance(KnownInstanceGuids.SystemAttributeRoutines.GetRuntimeVersion, out InstanceHandle h_RuntimeVersion))
|
RegisterSystemRoutine(KnownInstanceGuids.SystemAttributeRoutines.GetRuntimeVersion, new SystemAttributeRoutine<string>(this, KnownInstanceGuids.SystemAttributeRoutines.GetRuntimeVersion, delegate (Oms oms, OmsContext context)
|
||||||
{
|
|
||||||
RegisterSystemRoutine(h_RuntimeVersion, new SystemAttributeRoutine<string>(h_RuntimeVersion, delegate (Oms oms, OmsContext context)
|
|
||||||
{
|
{
|
||||||
return RuntimeVersion.ToString();
|
return RuntimeVersion.ToString();
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
DebugOms = this;
|
DebugOms = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,15 +901,16 @@ public abstract class Oms
|
|||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<InstanceHandle, SystemRoutine> _systemRoutinesByInstance = new Dictionary<InstanceHandle, SystemRoutine>();
|
public Dictionary<Guid, SystemRoutine> _systemRoutinesByInstance = new Dictionary<Guid, SystemRoutine>();
|
||||||
internal void RegisterSystemRoutine(InstanceHandle handle, SystemRoutine routine)
|
internal void RegisterSystemRoutine(Guid globalIdentifier, SystemRoutine routine)
|
||||||
{
|
{
|
||||||
_systemRoutinesByInstance[handle] = routine;
|
_systemRoutinesByInstance[globalIdentifier] = routine;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object? ExecuteSystemRoutine(OmsContext context, InstanceHandle handle)
|
internal object? ExecuteSystemRoutine(OmsContext context, InstanceHandle handle)
|
||||||
{
|
{
|
||||||
object? value = _systemRoutinesByInstance[handle].Execute(this, context);
|
Guid globalIdentifier = this.GetGlobalIdentifier(handle);
|
||||||
|
object? value = _systemRoutinesByInstance[globalIdentifier].Execute(this, context);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,24 +31,24 @@ public class OmsSystemRoutineBuilder
|
|||||||
{
|
{
|
||||||
InstanceHandle handle = Oms.CreateInstanceOf(Oms.GetInstance(KnownInstanceGuids.Classes.SystemAttributeRoutine), globalIdentifier);
|
InstanceHandle handle = Oms.CreateInstanceOf(Oms.GetInstance(KnownInstanceGuids.Classes.SystemAttributeRoutine), globalIdentifier);
|
||||||
|
|
||||||
SystemAttributeRoutine routine = new SystemAttributeRoutine(handle, func);
|
SystemAttributeRoutine routine = new SystemAttributeRoutine(Oms, globalIdentifier, func);
|
||||||
Oms.RegisterSystemRoutine(handle, routine);
|
Oms.RegisterSystemRoutine(globalIdentifier, routine);
|
||||||
return routine;
|
return routine;
|
||||||
}
|
}
|
||||||
public SystemAttributeRoutine<T> CreateSystemAttributeRoutine<T>(Guid globalIdentifier, Func<Oms, OmsContext, T> func)
|
public SystemAttributeRoutine<T> CreateSystemAttributeRoutine<T>(Guid globalIdentifier, Func<Oms, OmsContext, T> func)
|
||||||
{
|
{
|
||||||
InstanceHandle handle = Oms.CreateInstanceOf(Oms.GetInstance(KnownInstanceGuids.Classes.SystemAttributeRoutine), globalIdentifier);
|
InstanceHandle handle = Oms.CreateInstanceOf(Oms.GetInstance(KnownInstanceGuids.Classes.SystemAttributeRoutine), globalIdentifier);
|
||||||
|
|
||||||
SystemAttributeRoutine<T> routine = new SystemAttributeRoutine<T>(handle, func);
|
SystemAttributeRoutine<T> routine = new SystemAttributeRoutine<T>(Oms, globalIdentifier, func);
|
||||||
Oms.RegisterSystemRoutine(handle, routine);
|
Oms.RegisterSystemRoutine(globalIdentifier, routine);
|
||||||
return routine;
|
return routine;
|
||||||
}
|
}
|
||||||
public SystemInstanceSetRoutine CreateSystemInstanceSetRoutine(Guid globalIdentifier, Func<Oms, OmsContext, IEnumerable<InstanceHandle>> func)
|
public SystemInstanceSetRoutine CreateSystemInstanceSetRoutine(Guid globalIdentifier, Func<Oms, OmsContext, IEnumerable<InstanceHandle>> func)
|
||||||
{
|
{
|
||||||
InstanceHandle handle = Oms.CreateInstanceOf(Oms.GetInstance(KnownInstanceGuids.Classes.SystemInstanceSetRoutine), globalIdentifier);
|
InstanceHandle handle = Oms.CreateInstanceOf(Oms.GetInstance(KnownInstanceGuids.Classes.SystemInstanceSetRoutine), globalIdentifier);
|
||||||
|
|
||||||
SystemInstanceSetRoutine routine = new SystemInstanceSetRoutine(handle, func);
|
SystemInstanceSetRoutine routine = new SystemInstanceSetRoutine(Oms, globalIdentifier, func);
|
||||||
Oms.RegisterSystemRoutine(handle, routine);
|
Oms.RegisterSystemRoutine(globalIdentifier, routine);
|
||||||
return routine;
|
return routine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -19,7 +19,6 @@ namespace Mocha.Core.Oop;
|
|||||||
|
|
||||||
public abstract class ConcreteInstanceWrapper : InstanceWrapper
|
public abstract class ConcreteInstanceWrapper : InstanceWrapper
|
||||||
{
|
{
|
||||||
public abstract Guid ClassId { get; }
|
|
||||||
|
|
||||||
private InstanceHandle TheHandle { get; }
|
private InstanceHandle TheHandle { get; }
|
||||||
internal ConcreteInstanceWrapper(InstanceHandle handle)
|
internal ConcreteInstanceWrapper(InstanceHandle handle)
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
namespace Mocha.Core.Oop;
|
namespace Mocha.Core.Oop;
|
||||||
|
|
||||||
public class DeferredInstanceWrapper : InstanceWrapper
|
public abstract class DeferredInstanceWrapper : InstanceWrapper
|
||||||
{
|
{
|
||||||
private Oms oms;
|
private Oms oms;
|
||||||
private Guid globalIdentifier;
|
private Guid globalIdentifier;
|
||||||
|
|||||||
@ -19,6 +19,8 @@ namespace Mocha.Core.Oop;
|
|||||||
|
|
||||||
public abstract class InstanceWrapper : IInstanceWrapper
|
public abstract class InstanceWrapper : IInstanceWrapper
|
||||||
{
|
{
|
||||||
|
public abstract Guid ClassId { get; }
|
||||||
|
|
||||||
private InstanceHandle _Handle = InstanceHandle.Empty;
|
private InstanceHandle _Handle = InstanceHandle.Empty;
|
||||||
protected abstract InstanceHandle GetHandleInternal();
|
protected abstract InstanceHandle GetHandleInternal();
|
||||||
|
|
||||||
|
|||||||
@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
namespace Mocha.Core.Oop;
|
namespace Mocha.Core.Oop;
|
||||||
|
|
||||||
public abstract class SystemRoutine : ConcreteInstanceWrapper
|
public abstract class SystemRoutine : DeferredInstanceWrapper
|
||||||
{
|
{
|
||||||
internal SystemRoutine(InstanceHandle handle) : base(handle) { }
|
internal SystemRoutine(Oms oms, Guid globalIdentifier) : base(oms, globalIdentifier) { }
|
||||||
|
|
||||||
protected abstract object? ExecuteInternal(Oms oms, OmsContext context);
|
protected abstract object? ExecuteInternal(Oms oms, OmsContext context);
|
||||||
public object? Execute(Oms oms, OmsContext context)
|
public object? Execute(Oms oms, OmsContext context)
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public class SystemAttributeRoutine : SystemRoutine
|
|||||||
{
|
{
|
||||||
public override Guid ClassId => KnownInstanceGuids.Classes.SystemAttributeRoutine;
|
public override Guid ClassId => KnownInstanceGuids.Classes.SystemAttributeRoutine;
|
||||||
private Func<Oms, OmsContext, object?> Func { get; }
|
private Func<Oms, OmsContext, object?> Func { get; }
|
||||||
internal SystemAttributeRoutine(InstanceHandle handle, Func<Oms, OmsContext, object?> func) : base(handle)
|
internal SystemAttributeRoutine(Oms oms, Guid globalIdentifier, Func<Oms, OmsContext, object?> func) : base(oms, globalIdentifier)
|
||||||
{
|
{
|
||||||
Func = func;
|
Func = func;
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ public class SystemAttributeRoutine : SystemRoutine
|
|||||||
}
|
}
|
||||||
public class SystemAttributeRoutine<T> : SystemAttributeRoutine
|
public class SystemAttributeRoutine<T> : SystemAttributeRoutine
|
||||||
{
|
{
|
||||||
internal SystemAttributeRoutine(InstanceHandle handle, Func<Oms, OmsContext, T> func) : base(handle, new Func<Oms, OmsContext, object?>(delegate(Oms oms, OmsContext context) { return func(oms, context); }))
|
internal SystemAttributeRoutine(Oms oms, Guid globalIdentifier, Func<Oms, OmsContext, T> func) : base(oms, globalIdentifier, new Func<Oms, OmsContext, object?>(delegate(Oms oms, OmsContext context) { return func(oms, context); }))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public class SystemInstanceSetRoutine : SystemRoutine
|
|||||||
{
|
{
|
||||||
public override Guid ClassId => KnownInstanceGuids.Classes.SystemInstanceSetRoutine;
|
public override Guid ClassId => KnownInstanceGuids.Classes.SystemInstanceSetRoutine;
|
||||||
private Func<Oms, OmsContext, IEnumerable<InstanceHandle>> Func { get; }
|
private Func<Oms, OmsContext, IEnumerable<InstanceHandle>> Func { get; }
|
||||||
internal SystemInstanceSetRoutine(InstanceHandle handle, Func<Oms, OmsContext, IEnumerable<InstanceHandle>> func) : base(handle)
|
internal SystemInstanceSetRoutine(Oms oms, Guid globalIdentifier, Func<Oms, OmsContext, IEnumerable<InstanceHandle>> func) : base(oms, globalIdentifier)
|
||||||
{
|
{
|
||||||
Func = func;
|
Func = func;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user