feat!: GetRequiredBehaviour/HierarchyObject methods added for cleaner null handling

This commit is contained in:
2025-04-13 12:52:27 +03:00
parent bfbcfdce4f
commit 86b8cd9b55
21 changed files with 140 additions and 73 deletions

View File

@@ -14,10 +14,10 @@ public class BehaviourControllerFactory
T behaviourController = TypeFactory.Get<T>(args);
if (!hierarchyObject.Assign(behaviourController))
throw AssignException.From(hierarchyObject, behaviourController);
throw AssignFailedException.From(hierarchyObject, behaviourController);
if (!behaviourController.Assign(hierarchyObject))
throw AssignException.From(behaviourController, hierarchyObject);
throw AssignFailedException.From(behaviourController, hierarchyObject);
return behaviourController;
}

View File

@@ -15,12 +15,12 @@ public class BehaviourFactory
stateEnable ??= TypeFactory.Get<StateEnable>();
if (!stateEnable.Assign(behaviour))
throw AssignException.From(stateEnable, behaviour);
throw AssignFailedException.From(stateEnable, behaviour);
if (!behaviour.Assign(stateEnable))
throw AssignException.From(behaviour, stateEnable);
throw AssignFailedException.From(behaviour, stateEnable);
if (!behaviour.Assign(hierarchyObject.BehaviourController))
throw AssignException.From(behaviour, hierarchyObject.BehaviourController);
throw AssignFailedException.From(behaviour, hierarchyObject.BehaviourController);
return behaviour;
}

View File

@@ -23,14 +23,14 @@ public class HierarchyObjectFactory
stateEnable ??= TypeFactory.Get<StateEnable>();
if (!behaviourController.Assign(hierarchyObject))
throw AssignException.From(behaviourController, hierarchyObject);
throw AssignFailedException.From(behaviourController, hierarchyObject);
if (!stateEnable.Assign(hierarchyObject))
throw AssignException.From(stateEnable, hierarchyObject);
throw AssignFailedException.From(stateEnable, hierarchyObject);
if (!hierarchyObject.Assign(behaviourController))
throw AssignException.From(hierarchyObject, behaviourController);
throw AssignFailedException.From(hierarchyObject, behaviourController);
if (!hierarchyObject.Assign(stateEnable))
throw AssignException.From(hierarchyObject, stateEnable);
throw AssignFailedException.From(hierarchyObject, stateEnable);
return hierarchyObject;
}

View File

@@ -12,10 +12,10 @@ public class StateEnableFactory
T stateEnable = TypeFactory.Get<T>(args);
if (!entity.Assign(stateEnable))
throw AssignException.From(entity, stateEnable);
throw AssignFailedException.From(entity, stateEnable);
if (!stateEnable.Assign(entity))
throw AssignException.From(stateEnable, entity);
throw AssignFailedException.From(stateEnable, entity);
return stateEnable;
}