Search code examples
c#androidmvvmcrossviewmodel

View is not opening after implementing new interface in viewModel class in MVVMCross


I am using MVVMCross for creating an android app, I have a viewModel class which is working fine. After I have implemented a new interface into this the view is not opening. The interface and viewmodel is given below.

Viewmodel:

    public sealed class PuCreationViewModel : BaseDataScreenViewModel
        {

            private readonly IProjectPuManager _puManager;

            public PuCreationViewModel(
              IProjectPuManager puManager )
            {

                _puManager = puManager;
            }
       }

Interface:

 public interface IProjectPuManager
    {
        string CreatePu(string projectId, PuEntity entity);

    }

Implementation class:

public class ProjectPuManager : IProjectPuManager
    {
        private readonly IFirebaseRepository<PuEntity> _puRepository;


        public ProjectPuManager(IFirebaseRepository<ProjectPuEntity> puRepository)
        {
            _puRepository = puRepository;
        }


        public string CreatePu(string projectId, PuEntity entity)
        {
            _puRepository.CreateReference(
                $"{AppConstants.Firebase.Key.ProjectPi.Root}/{projectId}");

            return _puRepository.Create(entity, true);
        }
        }

Registered the interface in app.cs

Mvx.RegisterType<IProjectPuManager, ProjectPuManager>();

Solution

  • In my case I missed create the the mapper file for converting the entities. I thought the mapper is not needed to run the app but the mapper is mandatory for the manager. Without that the app doesn't open and it won't show any error to you.