From 40e5e66fc23d6b4a6255cb40e7d6c0249ef63489 Mon Sep 17 00:00:00 2001 From: Simon Gockner Date: Fri, 5 Jul 2019 11:57:38 +0200 Subject: [PATCH] - add first draft of lifestyle wiki --- Lifestyles.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Lifestyles.md b/Lifestyles.md index e8fb860..76709ad 100644 --- a/Lifestyles.md +++ b/Lifestyles.md @@ -1 +1,17 @@ -There are multiple Lifestyles available. +There are multiple lifestyles available. These are needed for the registration of your classes. Depending on their lifestyle it is decided which instance is returned once you resolve it. + +The following documentation is supposed to help you decide, which `Lifestyle` you want to use for your need. +The lifestyles are part of the enum `Lifestyle`. + +## `Lifestyle.Transient` + +Using the `Transient`-Lifestyle, a new instance gets created every time an instance is resolved. +`Transient` instances are not tracked by the `IocContainer`, so once you don't need them anymore they can be claimed by the garbage collector without leaking memory. +This is the default `Lifestyle` that the [[`RegistrationFactory`|RegistrationFactory]] uses. + +## `Lifestyle.Singleton` + +The `Singleton`-Lifestyle is used to always get the same instance every time an instance is resolved. +This is specifically useful if you have a service that needs to be accesses by multiple components of your application. + +## `Lifestyle.Multiton`