2017-09-18 65 views
0

錯誤升級MvvmCross從5.1到5.2之後,我CustomAndroidPresenter.cs拋出生成錯誤。這是什麼造成的?升級MvvmCross至5.2顯示了CustomAndroidPresenter

CustomAndroidPresenter.cs:

namespace TestPrjDroid 
{ 
    public class CustomAndroidPresenter : MvxAndroidViewPresenter 
    { 
     public override void Show(MvxViewModelRequest request) 
     { 
      if (request != null && request.PresentationValues != null) 
      { 
       if (request.PresentationValues.ContainsKey("MyCustomFlag")) 
       { 
        // Get intent from request and set flags to clear backstack. 
        var intent = base.CreateIntentForRequest(request); 
        intent.AddFlags(ActivityFlags.ClearTask | ActivityFlags.ClearTop | ActivityFlags.NewTask); 
        base.Show(intent); 
        return; 
       } 
      } 
      base.Show(request); 
     } 
    } 
} 

錯誤:

There is no argument given that corresponds to the required formal parameter 'androidViewAssemblies' of 'MvxAndroidViewPresenter.MvxAndroidViewPresenter(IEnumerable)'

Argument 1: cannot convert from 'Android.Content.Intent' to 'MvvmCross.Core.ViewModels.MvxViewModelRequest'

回答

0

您需要添加一個構造MvxAndroidViewPresenter(IEnumerable)

public class CustomAndroidPresenter : MvxAndroidViewPresenter 
{ 

    public CustomAndroidPresenter(IEnumerable<Assembly> androidViewAssemblies) : base(androidViewAssemblies) 
    { 
    } 

    public override void Show(MvxViewModelRequest request) 
    { 
     if (request != null && request.PresentationValues != null) 
     { 
      if (request.PresentationValues.ContainsKey("MyCustomFlag")) 
      { 
       // Get intent from request and set flags to clear backstack. 
       var intent = base.CreateIntentForRequest(request); 
       intent.AddFlags(ActivityFlags.ClearTask | ActivityFlags.ClearTop | ActivityFlags.NewTask); 
       base.ShowIntent(intent); 
       return; 
      } 
     } 
     base.Show(request); 
    } 
} 
+0

它拋出: 錯誤CS0246:'類型或命名空間名稱「大會」不能found' –

+0

@Mukte Swar Patnaik,嘗試使用'System.Reflection.Assembly'。 –

+0

@ YorkShen-MSFT 我試過太多,它會引發以下錯誤。 錯誤CS7036'沒有給定的參數對應於所要求的形式參數「androidViewAssemblies」「CustomAndroidPresenter.CustomAndroidPresenter(IEnumerable的)」' 錯誤CS1503'參數1:不能從「Android.Content.Intent」轉換到「MvvmCross.Core.ViewModels.MvxViewModelRequest'' –