Search code examples
androidxamarinmvvmcross

Custom MvxAndroidSetupSingleton


There's MvxAndroidSetupSingleton class in MvvmCross what provides several virtual methods but at the same time has private only constructor

public class MvxAndroidSetupSingleton : MvxSingleton<MvxAndroidSetupSingleton>
{
    private MvxAndroidSetupSingleton()
    {
    }

    protected virtual void CreateSetup(Context applicationContext){}

    protected virtual Type FindSetupType(){}
}

I'd like to git rid of reflection-based implementation and to initialize Setup on my own, but don't see any way to do that (due to the private constructor). Is there any way to handle that?

Or at least would be glad to know reason of existing virtual methods in class with private constructor.


Solution

  • For the preset time there's no way to accomplish that. As I've said above, the reason I want to do that is to improve startup performance as much as possible. What I've done already is:

    • overrided FillValueConverters to specify Value Converters explicitly
    • overrided FillViewTypes and filled cache on my own.

    It saved around ~1.5s on start

    Update Thanks to @CheeseBaron, private constructor was changed to protected in next commit