Advertisement
uurha

Untitled

Apr 12th, 2023 (edited)
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. public class ProjectInstaller : ScriptableObjectInstaller
  2. {
  3.     public override void InstallBindings()
  4.     {
  5.         Container.BindFactory<AppStateMachine, Type, IExitableState, StatePlaceholderFactory>().FromFactory<StateFactory>();
  6.     }
  7. }
  8.  
  9. public class StatePlaceholderFactory : PlaceholderFactory<AppStateMachine, Type, IExitableState>
  10. {
  11. }
  12.  
  13. public class StateFactory : IFactory<AppStateMachine, Type, IExitableState>
  14. {
  15.     private readonly DiContainer diContainer;
  16.  
  17.     [Inject]
  18.     private void Construct(/*Here some services*/)
  19.     {
  20.            
  21.     }
  22.        
  23.     public StateFactory(DiContainer container)
  24.     {
  25.         diContainer = container;
  26.     }
  27.  
  28.     public IExitableState Create(AppStateMachine param, Type type)
  29.     {
  30.         return (IExitableState)diContainer.Instantiate(type, new[] { param });
  31.     }
  32. }
  33.  
  34. public class Test : IExitableState
  35. {
  36.     public Test(AppStateMachine stateMachine)
  37.     {
  38.     }
  39. }
  40.  
  41. public interface IExitableState
  42. {
  43. }
  44.  
  45. public class AppStateMachine
  46. {
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement