in Forge.TreeWalker/src/TreeWalkerSession.cs [1194:1241]
public static void GetActionsMapFromAssembly(Assembly forgeActionsAssembly, out Dictionary<string, ActionDefinition> actionsMap)
{
actionsMap = new Dictionary<string, ActionDefinition>
{
// Add native ForgeActions: SubroutineAction.
{ nameof(SubroutineAction), new ActionDefinition() { ActionType = typeof(SubroutineAction), InputType = typeof(SubroutineInput) } }
};
if (forgeActionsAssembly == null)
{
return;
}
foreach (Type type in forgeActionsAssembly.GetExportedTypes())
{
// Find all classes with the applied ForgeActionAttribute.
ForgeActionAttribute forgeAction = (ForgeActionAttribute) type.GetCustomAttribute(typeof(ForgeActionAttribute), false);
if (forgeAction != null)
{
// Confirm that ForgeActionAttribute is attached to only BaseAction classes and there are no duplicates.
Type derived = type;
bool isBaseAction = false;
do
{
if (derived == typeof(BaseAction))
{
isBaseAction = true;
break;
}
derived = derived.BaseType;
} while (derived != null);
if (isBaseAction)
{
actionsMap.Add(type.Name, new ActionDefinition() { ActionType = type, InputType = forgeAction.InputType });
continue;
}
else
{
throw new CustomAttributeFormatException(
string.Format(
"The given type: {0} must implement the BaseAction abstract class in order to apply the ForgeActionAttribute.",
type.ToString()));
}
}
}
}