protected MptxInstanceContext(
     IMptxStateProvider stateProvider,
     MptxInstance instance)
 {
     StateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider));
     Instance      = instance ?? throw new ArgumentNullException(nameof(instance));
 }
        public MptxInstanceContext CreateContext(MptxInstance instance, Type stateType, Type parentStateType)
        {
            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }

            if (stateType == null)
            {
                throw new ArgumentNullException(nameof(stateType));
            }

            var contextType = parentStateType != null ?
                              typeof(MptxInstanceContext <,>).MakeGenericType(stateType, parentStateType) :
                              typeof(MptxInstanceContext <>).MakeGenericType(stateType);

            return((MptxInstanceContext)ActivatorUtilities.CreateInstance(
                       provider: null,
                       contextType,
                       _stateProvider,
                       instance));
        }
 public MptxInstanceFeature(MptxInstance instance)
 {
     Instance = instance ?? throw new ArgumentNullException(nameof(instance));
 }