Ejemplo n.º 1
0
        public static void ChangeAllCanExecute(this PageViewModel viewmodel)
        {
            var props    = viewmodel.GetType().GetProperties().Where(q => q.PropertyType.Equals(typeof(Command))).ToArray();
            var commands = props.Select(q => (Command)q.GetValue(viewmodel)).ToArray();

            commands.ForEach(q => q.ChangeCanExecute());
        }
Ejemplo n.º 2
0
        private static Type?GetViewType(PageViewModel vm)
        {
            Type?t = vm.GetType();

            foreach (Type?j in Objects.GetTypes <T>(true))
            {
                if (j.GetAttr <PageViewModelAttribute>()?.ViewType == t)
                {
                    return(j);
                }
            }
            return(vm.GetAttr <ViewAttribute>()?.ViewType is { } tt&& tt.Implements <T>() && tt.IsInstantiable() ? tt : null);
        }
Ejemplo n.º 3
0
        static Fragment GetPageFragment(PageViewModel page)
        {
            switch (page)
            {
            case FirstPageViewModel firstPage:
                return(new FragmentOne());

            case SecondPageViewModel secondPage:
                return(new FragmentTwo());

            case ThirdPageViewModel thirdPage:
                return(new FragmentThree());

            default:
                throw new ArgumentException($"Not supported page {page.GetType().Name}", nameof(page));
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Obtiene una excepción que se produce cuando no se ha podido
 /// localizar un contenedor visual para el <see cref="PageViewModel"/>
 /// especificado.
 /// </summary>
 /// <param name="vm">
 /// <see cref="PageViewModel"/> para el cual no se pudo encontrar un
 /// contenedor visual.
 /// </param>
 /// <returns>
 /// Una nueva instancia de la clase <see cref="MissingTypeException"/>
 /// con un mensaje que describe la excepción ocurrida.
 /// </returns>
 public static Exception VisualHostNotFound(PageViewModel vm)
 {
     return(new MissingTypeException(string.Format(St.VisualHostNotFound,
                                                   vm.UiServices?.VisualHost.Title.OrNull() ??
                                                   vm.GetType().NameOf())));
 }