If you just want to change the naming scheme, the function to overwrite is CreateViewToViewModelNaming
public class Setup : MvxAndroidSetup
{
public Setup(Context applicationContext) : base(applicationContext)
{
}
protected override IMvxNameMapping CreateViewToViewModelNaming()
{
return new ReverseViewModelNaming();
}
protected override IMvxApplication CreateApp()
{
return new Core.App();
}
protected override IMvxTrace CreateDebugTrace()
{
return new DebugTrace();
}
}
class ReverseViewModelNaming : IMvxNameMapping
{
public string Map(string inputName)
{
// MyView is presented by the view model named weiVyM (how useful :P)
return string.Join("", inputName.Reverse());
}
}
If you want to change the mapping, the function to overwrite is InitializeViewLookup. If you just want to add some extra mappings, call base.InitializeViewLookup().
public class Setup : MvxAndroidSetup
{
public Setup(Context applicationContext) : base(applicationContext)
{
}
protected override void InitializeViewLookup()
{
var registry = new Dictionary<Type, Type>()
{
{ typeof(FirstViewModel), typeof(FirstActivity) },
{ typeof(HomeViewModel), typeof(HomeActivity) } ,
{ typeof(DetailViewModel), typeof(DetailActivity) },
{ typeof(UploadViewModel), typeof(UploadActivity) }
};
var container = Cirrious.CrossCore.Mvx.Resolve<IMvxViewsContainer>();
container.AddAll(registry);
}
protected override IMvxApplication CreateApp()
{
return new Core.App();
}
protected override IMvxTrace CreateDebugTrace()
{
return new DebugTrace();
}
}