IEnumerable <EditorDataItem> IDataSource.GetEditorDataItems(int currentId, int parentId, PageMarker pageMarker, out int total) { var editorDataItems = this.GetEditorDataItems(currentId, parentId); total = editorDataItems.Count(); return(editorDataItems.Skip(pageMarker.Skip).Take(pageMarker.Take)); }
IEnumerable <EditorDataItem> IDataSource.GetEditorDataItems(int currentId, int parentId, PageMarker pageMarker, out int total) { var contextId = currentId == 0 ? parentId : currentId; // HACK: workarround to avoid breaking the IDotNetDataSource interface var editorDataItems = Enumerable.Empty <EditorDataItem>(); total = -1; IDotNetDataSource dotNetDataSource = AppDomain.CurrentDomain.CreateInstanceAndUnwrap(Helper.GetAssembly(this.AssemblyName).FullName, this.ClassName) as IDotNetDataSource; if (dotNetDataSource != null) { this.SetProperties(ref dotNetDataSource, contextId); if (dotNetDataSource is IDotNetDataSourcePaged) { ((IDotNetDataSourcePaged)dotNetDataSource).ItemsPerPage = pageMarker.ItemsPerPage; ((IDotNetDataSourcePaged)dotNetDataSource).Page = pageMarker.Page; editorDataItems = dotNetDataSource .GetEditorDataItems(contextId) .Select(x => new EditorDataItem() { Key = x.Key, Label = x.Value }) .ToList(); total = ((IDotNetDataSourcePaged)dotNetDataSource).Total; } else { editorDataItems = dotNetDataSource .GetEditorDataItems(contextId) .Select(x => new EditorDataItem() { Key = x.Key, Label = x.Value }) .ToList(); total = editorDataItems.Count(); editorDataItems = editorDataItems .Skip(pageMarker.Skip) .Take(pageMarker.Take); } } return(editorDataItems); }