do not require method classes to actually be defined, and simplify GetInstanceTextHack
This commit is contained in:
parent
dd91aac0db
commit
b417342093
@ -59,13 +59,7 @@ public abstract class Oms
|
|||||||
MethodImplementation[] methodImplementations = MBS.Core.Reflection.TypeLoader.GetAvailableTypes<MethodImplementation>(new System.Reflection.Assembly[] { Assembly.GetExecutingAssembly() });
|
MethodImplementation[] methodImplementations = MBS.Core.Reflection.TypeLoader.GetAvailableTypes<MethodImplementation>(new System.Reflection.Assembly[] { Assembly.GetExecutingAssembly() });
|
||||||
foreach (MethodImplementation impl in methodImplementations)
|
foreach (MethodImplementation impl in methodImplementations)
|
||||||
{
|
{
|
||||||
if (TryGetInstance(impl.MethodClassGuid, out InstanceHandle methodClassInstance))
|
RegisterMethodImplementation(impl.MethodClassGuid, impl);
|
||||||
{
|
|
||||||
RegisterMethodImplementation(methodClassInstance, impl);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Console.WriteLine("failed to load method type '{0}' from instance {1} (inst not found)", impl.GetType().FullName, impl.MethodClassGuid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -669,10 +663,10 @@ public abstract class Oms
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<InstanceHandle, MethodImplementation> methodImplementations = new Dictionary<InstanceHandle, MethodImplementation>();
|
private Dictionary<Guid, MethodImplementation> methodImplementations = new Dictionary<Guid, MethodImplementation>();
|
||||||
private void RegisterMethodImplementation(InstanceHandle methodClass, MethodImplementation implementation)
|
private void RegisterMethodImplementation(Guid methodClassId, MethodImplementation implementation)
|
||||||
{
|
{
|
||||||
methodImplementations[methodClass] = implementation;
|
methodImplementations[methodClassId] = implementation;
|
||||||
implementation.Initialize(this);
|
implementation.Initialize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,6 +699,8 @@ public abstract class Oms
|
|||||||
public InstanceHandle Execute(OmsContext context, InstanceHandle methodOrMethodBinding, InstanceHandle? targetInstance = null)
|
public InstanceHandle Execute(OmsContext context, InstanceHandle methodOrMethodBinding, InstanceHandle? targetInstance = null)
|
||||||
{
|
{
|
||||||
InstanceHandle parentClass = GetParentClass(methodOrMethodBinding);
|
InstanceHandle parentClass = GetParentClass(methodOrMethodBinding);
|
||||||
|
Guid parentClassId = GetGlobalIdentifier(parentClass);
|
||||||
|
|
||||||
if (IsInstanceOf(methodOrMethodBinding, GetInstance(KnownInstanceGuids.Classes.MethodBinding)))
|
if (IsInstanceOf(methodOrMethodBinding, GetInstance(KnownInstanceGuids.Classes.MethodBinding)))
|
||||||
/*
|
/*
|
||||||
if (IsInstanceOf(methodOrMethodBinding, GetInstance(KnownInstanceGuids.Classes.ReturnAttributeMethodBinding))
|
if (IsInstanceOf(methodOrMethodBinding, GetInstance(KnownInstanceGuids.Classes.ReturnAttributeMethodBinding))
|
||||||
@ -728,7 +724,7 @@ public abstract class Oms
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (methodImplementations.ContainsKey(parentClass))
|
if (methodImplementations.ContainsKey(parentClassId))
|
||||||
{
|
{
|
||||||
if (targetInstance != null)
|
if (targetInstance != null)
|
||||||
{
|
{
|
||||||
@ -736,7 +732,7 @@ public abstract class Oms
|
|||||||
InstanceHandle pclassInstance = GetParentClass(hh);
|
InstanceHandle pclassInstance = GetParentClass(hh);
|
||||||
context.SetWorkData(pclassInstance, hh);
|
context.SetWorkData(pclassInstance, hh);
|
||||||
}
|
}
|
||||||
return methodImplementations[parentClass].Execute(this, context, methodOrMethodBinding);
|
return methodImplementations[parentClassId].Execute(this, context, methodOrMethodBinding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new NotImplementedException(String.Format("method implementation not found for method class {0}", GetGlobalIdentifier(parentClass)));
|
throw new NotImplementedException(String.Format("method implementation not found for method class {0}", GetGlobalIdentifier(parentClass)));
|
||||||
@ -837,17 +833,7 @@ public abstract class Oms
|
|||||||
private string _GetInstanceTextHack(InstanceHandle inst)
|
private string _GetInstanceTextHack(InstanceHandle inst)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (IsInstanceOf(inst, GetInstance(KnownInstanceGuids.Classes.Class)))
|
if (IsInstanceOf(inst, GetInstance(KnownInstanceGuids.Classes.Relationship)))
|
||||||
{
|
|
||||||
string name = GetAttributeValue<string>(inst, GetInstance(KnownAttributeGuids.Text.Name));
|
|
||||||
sb.Append(name);
|
|
||||||
}
|
|
||||||
else if (IsInstanceOf(inst, GetInstance(KnownInstanceGuids.Classes.Attribute)))
|
|
||||||
{
|
|
||||||
string name = GetAttributeValue<string>(inst, GetInstance(KnownAttributeGuids.Text.Name));
|
|
||||||
sb.Append(name);
|
|
||||||
}
|
|
||||||
else if (IsInstanceOf(inst, GetInstance(KnownInstanceGuids.Classes.Relationship)))
|
|
||||||
{
|
{
|
||||||
InstanceHandle sourceClass = GetRelatedInstance(inst, GetInstance(KnownRelationshipGuids.Relationship__has_source__Class));
|
InstanceHandle sourceClass = GetRelatedInstance(inst, GetInstance(KnownRelationshipGuids.Relationship__has_source__Class));
|
||||||
string relationshipType = GetAttributeValue<string>(inst, GetInstance(KnownAttributeGuids.Text.RelationshipType));
|
string relationshipType = GetAttributeValue<string>(inst, GetInstance(KnownAttributeGuids.Text.RelationshipType));
|
||||||
@ -892,6 +878,14 @@ public abstract class Oms
|
|||||||
sb.Append(GetInstanceText(executesMethod));
|
sb.Append(GetInstanceText(executesMethod));
|
||||||
sb.Append("[rsmb]");
|
sb.Append("[rsmb]");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string name = GetAttributeValue<string>(inst, GetInstance(KnownAttributeGuids.Text.Name));
|
||||||
|
if (name != null)
|
||||||
|
{
|
||||||
|
sb.Append(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user