fix: some factories not assigning fields correctly

This commit is contained in:
2025-08-04 22:02:48 +03:00
parent e00319d7ff
commit 63bc94c7a6
3 changed files with 41 additions and 20 deletions

View File

@@ -12,12 +12,15 @@ public class BehaviourFactory
{
T behaviour = TypeFactory.Get<T>(args);
stateEnable ??= TypeFactory.Get<StateEnable>();
if (!stateEnable.Assign(behaviour))
throw AssignFailedException.From(stateEnable, behaviour);
if (!behaviour.Assign(stateEnable))
throw AssignFailedException.From(behaviour, stateEnable);
if (stateEnable is not null)
{
if (!stateEnable.Assign(behaviour))
throw AssignFailedException.From(stateEnable, behaviour);
if (!behaviour.Assign(stateEnable))
throw AssignFailedException.From(behaviour, stateEnable);
}
else
StateEnableFactory.Instantiate(behaviour);
return behaviour;
}