Ejemplo n.º 1
0
        /// <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>
        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>());
        }