Copy public class Installer : GameObjectInstaller
{
public override void Install ( DIContainer container)
{
container .BindFactory < FooItem . Factory > ();
container .BindFactory < FooItemWithoutParam . Factory > ();
}
}
public class SampleClass : MonoInjecter
{
[ Inject ]
private readonly FooItem . Factory _fooItemFactory;
[ Inject ]
private readonly FooItemWithoutParam . Factory _fooItemWithoutParamFactory;
protected override void Awake ()
{
base.Awake();
FooItem fooItem = _fooItemFactory .Create( 26 );
FooItemWithoutParam fooItemWithoutParam = _fooItemWithoutParamFactory .Create();
}
}
public class FooItem : IFactorable < int >
{
private readonly Foo _foo;
public FooItem ( Foo foo)
{
_foo = foo;
}
public void InitializeFactory ( int variable)
{
Debug .Log( $"{ _foo . index }: int variable is: {variable}" );
}
public class Factory : SeparatedObjectFactory < FooItem , int > { }
}
public class FooItemWithoutParam : IFactorable
{
private readonly Foo _foo;
public FooItemWithoutParam ( Foo foo)
{
_foo = foo;
}
public class Factory : SeparatedObjectFactory < FooItemWithoutParam > { }
}