Mobile/CafeLib.Mobile/Extensions/ServiceRegistryExtensions.cs
/// <summary>
/// Add view model type as singleton service registry. 
/// </summary>
/// <typeparam name="T">view model type</typeparam>
/// <param name="serviceRegistry">service registry</param>
/// <param name="transient">register as transient if true; otherwise as singleton</param>
/// <returns>service registry</returns>
Add view model type as singleton service registry.
Add view model type as singleton service registry .
public static IServiceRegistry AddViewModel<T>(this IServiceRegistry serviceRegistry, bool transient = false) where T : BaseViewModel
        {
            var attr = typeof(T).GetTypeInfo().GetCustomAttribute<TransientAttribute>();
            transient = attr != null || transient;
            return !transient ? serviceRegistry.AddViewModelSingleton<T>() : serviceRegistry.AddViewModelTransient<T>();
        }
public static IServiceRegistry AddViewModel < T > ( this IServiceRegistry serviceRegistry , bool transient = false ) where T : BaseViewModel { var attr = typeof ( T ) . GetTypeInfo ( ) . GetCustomAttribute < TransientAttribute > ( ) ; transient = attr != null || transient ; return ! transient ? serviceRegistry . AddViewModelSingleton < T > ( ) : serviceRegistry . AddViewModelTransient < T > ( ) ; }
Add view model type as singleton service registry.
Add view model type as singleton service registry .
None
IServiceRegistry
this
transient
bool
register as transient if true; otherwise as singleton
register as transient if true ; otherwise as singleton
serviceRegistry
None
typeparam
view model type
view model type