我在Android目标的mvvmcross中的RIO绑定有问题。
我有一个相当简单的模型:
public class RJParagraph : MvxNotifyPropertyChanged
{
public INC<String> Title = new NC<string>();
//public INC<DateTime> LastSeen = new NC<DateTime>();
private DateTime _lastSeen;
public DateTime LastSeen
{
get { return _lastSeen; }
set
{
_lastSeen = value;
RaisePropertyChanged(() => LastSeen);
}
}
// constructor etc
}
我在核心项目中有一个服务,其中包含以下LINQ查询,其中refdate是DateTime.Now.AddDays(-30):
mylist.Where(f => f.LastSeen > refdate).OrderByDescending(f => f.LastSeen)
当我使用带注释的行(RIO Datetime字段)时,Nunit测试可以正常运行,但是在执行此查询时,我的Android应用将触发不支持的接口(比较)。 NUnit测试运行正常。 (注意:使用Rio时,LINQ查询中使用了LastSeen.Value)
当我使用上述非RIO版本时,一切都按预期工作。
我一直在寻找解决方法...也许其他人可以给我一些指导?提前致谢。
(顺便说一句,我对此框架的努力表示赞赏)
更新:完整错误:
System.ArgumentException: does not implement right interface
07-18 11:31:29.730 I/MonoDroid(20500): UNHANDLED EXCEPTION: System.ArgumentException: does not implement right interface
07-18 11:31:29.730 I/MonoDroid(20500): at System.Collections.Generic.Comparer`1/DefaultComparer<Cirrious.MvvmCross.FieldBinding.INC`1<System.DateTime>>.Compare (Cirrious.MvvmCross.FieldBinding.INC`1<System.DateTime>,Cirrious.MvvmCross.FieldBinding.INC`1<System.DateTime>) <0x004e8>
07-18 11:31:29.730 I/MonoDroid(20500): at System.Linq.SortSequenceContext`2<JaarverslaggevingApp.Core.Models.RJParagraph, Cirrious.MvvmCross.FieldBinding.INC`1<System.DateTime>>.Compare (int,int) <0x000e3>
07-18 11:31:29.730 I/MonoDroid(20500): at System.Linq.QuickSort`1<JaarverslaggevingApp.Core.Models.RJParagraph>.CompareItems (int,int) <0x00067>
07-18 11:31:29.730 I/MonoDroid(20500): at System.Linq.QuickSort`1<JaarverslaggevingApp.Core.Models.RJParagraph>.MedianOfThree (int,int) <0x000df>
07-18 11:31:29.730 I/MonoDroid(20500): at System.Linq.QuickSort`1<JaarverslaggevingApp.Core.Models.RJParagraph>.Sort (int,int) <0x000f7>
07-18 11:31:29.730 I/MonoDroid(20500): at System.Linq.QuickSort`1<JaarverslaggevingApp.Core.Models.RJParagraph>.PerformSort () <0x000f7>
07-18 11:31:29.730 I/MonoDroid(20500): at System.Linq.QuickSort`1/<Sort>c__Iterator39<JaarverslaggevingApp.Core.Models.RJParagraph>.MoveNext () <0x0019f>
07-18 11:31:29.730 I/MonoDroid(20500): at System.Linq.Enumerable/<CreateTakeIterator>c__Iterator30`1<JaarverslaggevingApp.Core.Models.RJParagraph>.MoveNext () <0x004cf>
07-18 11:31:29.730 I/MonoDroid(20500): at System.Collections.Generic.List`1<JaarverslaggevingApp.Core.Models.RJParagraph>.AddEnumerable (System.Collections.Generic.IEnumerable`1<JaarverslaggevingApp.Core.Models.RJParagraph>) <0x0016b>
07-18 11:31:29.730 I/MonoDroid(20500): at System.Collections.Generic.List`1<JaarverslaggevingApp.Core.Models.RJParagraph>..ctor (System.Collections.Generic.IEnumerable`1<JaarverslaggevingApp.Core.Models.RJParagraph>) <0x001bb>
07-18 11:31:29.730 I/MonoDroid(20500): at JaarverslaggevingApp.Core.Services.MockTocService.History () <IL 0x000a7, 0x004af>
07-18 11:31:29.730 I/MonoDroid(20500): at JaarverslaggevingApp.Core.ViewModels.IndexHistoryViewModel..ctor (JaarverslaggevingApp.Core.Services.IGetTocService) <IL 0x00016, 0x00113>
07-18 11:31:29.730 I/MonoDroid(20500): at JaarverslaggevingApp.UI.Android.Fragments.IndexHistoryFragment.OnCreateView (Android.Views.LayoutInflater,Android.Views.ViewGroup,Android.OS.Bundle) [0x0000b] in f:\JaarverslaggevingApp\JaarverslaggevingApp\JR_Android\Views\Fragments\IndexHistoryFragment.cs:25
07-18 11:31:29.730 I/MonoDroid(20500): at Android.Support.V4.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (intptr,intptr,intptr,intptr,intptr) [0x00021] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid-bindings/Compatibility-v4/bindings/obj/platform-15/src/generated/Android.Support.V4.App.Fragment.cs:953
07-18 11:31:29.730 I/MonoDroid(20500): at (wrapper dynamic-method) object.bd483370-f096-4010-b752-21dc83bc68f2 (intptr,intptr,intptr,intptr,intptr) <IL 0x00023, 0x00063>
Unhandled Exception:
最佳答案
总是存在人为错误的问题,并且浪费了很多时间:(由于另一个问题,我删除了所有RIO代码(最终根本没有RIO问题)。因此,起初我在各处都添加了.Value,但是还原RIO代码后,我只添加了.Value,编译器报告了错误的代码,报告了与refdate的日期比较,但没有报告.OrderByDescending,因为在编译器时,将INC与INC进行比较没有问题。 ...
在我的存储库中,我只能怪自己:)
感谢Stuart的努力。