Пример #1
0
        public static void OnViewAppearing(this IMvxElement element)
        {
            var cache  = Mvx.Resolve <IMvxChildViewModelCache>();
            var cached = cache.Get(element.FindAssociatedViewModelTypeOrNull());

            element.OnViewCreate(() => cached ?? element.LoadViewModel());
        }
        private static void LoadViewModelForElement(IMvxElement element)
        {
            IMvxViewModel cached = null;

            if (!MvxDesignTimeChecker.IsDesignTime)
            {
                var cache = Mvx.IoCProvider.Resolve <IMvxChildViewModelCache>();
                cached = cache.Get(element.FindAssociatedViewModelTypeOrNull());
            }

            element.OnViewCreate(() => cached ?? element.LoadViewModel());
        }
Пример #3
0
        private static async ValueTask LoadViewModelForElementAsync(IMvxElement element)
        {
            IMvxViewModel?cached = null;

            if (!MvxDesignTimeChecker.IsDesignTime)
            {
                var cache = Mvx.IoCProvider.Resolve <IMvxChildViewModelCache>();
                cached = cache.Get(element.FindAssociatedViewModelTypeOrNull());
            }

            await element.OnViewCreate(async() =>
            {
                return(cached ?? await element.LoadViewModel().ConfigureAwait(false));
            }
                                       ).ConfigureAwait(false);
        }