ipjohnson / Grace

Grace is a feature rich dependency injection container library
MIT License
337 stars 33 forks source link

ExportInstance<T> requires lifestyle singleton ? #86

Closed crystalbyte closed 7 years ago

crystalbyte commented 7 years ago

I was surprised that I need to specify the singleton lifestyle for an instance export in order to not receive a new copy. I assume this is a bug ?

ipjohnson commented 7 years ago

Not a bug persay it's the behavior that it's always been. Consider it maybe misnaming on my part as the original method was ExportInstance<T>(T value) which didn't need a lifestyle at all. Then came the function versions I'm assuming you are speaking about.

I actually was thinking about deprecating it as they have been superseded by the ExportFactory<...> methods and as you mentioned the naming convention is kind of awkward as well.

Since it is a long running behavior, I'm hesitant to change it quickly. While it is more verbose is it possible to add a Lifestyle.Singleton() and when it does change to default to Singleton lifestyle? Once the change is implemented I'd say roughly 4-6 months (I want to give some lead time for this as I have some production apps that expect this behavior)

crystalbyte commented 7 years ago

Thanks for the quick response. In anticipation of future changes I will stick to the ExportFactory<T> then.