You can use the Forward<,>() registration to tell StructureMap to resolve a type using the resolution of a different type. This should do what you expect:
ObjectFactory.Initialize(x =>
{
x.For<IInterface1>().Singleton().Use<MyClass>();
x.Forward<IInterface1, IInterface2>();
});
I would register the MyClass itself and then pull that out of the context for the Use statements of the individual interfaces.
ForSingletonOf<MyClass>().Use<MyClass>();
For<IInterface1>().Use(ctx => ctx.GetInstance<MyClass>());
For<IInterface2>().Use(ctx => ctx.GetInstance<MyClass>());
Try looking at the different overloads to Use, especially Func overload. From there you can tell how StructureMap should create your instance with another object already registred.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With