当前位置: 首页>>代码示例>>C#>>正文


C# IDataService.GetItems方法代码示例

本文整理汇总了C#中IDataService.GetItems方法的典型用法代码示例。如果您正苦于以下问题:C# IDataService.GetItems方法的具体用法?C# IDataService.GetItems怎么用?C# IDataService.GetItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataService的用法示例。


在下文中一共展示了IDataService.GetItems方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CourseForXSLT

        /// <summary>
        /// курс для преобразования xslt
        /// </summary>
        /// <param name="_data">провайдер данных для курса</param>
        /// <exception cref="ArgumentNullException"></exception>
        public CourseForXSLT(IDataService _data)
        {
            if (_data == null)
                throw new ArgumentNullException();

            try
            {
                origCourse = _data.Course;

                Title = _data.GetTitle();
                Items = new ObservableCollection<IItemModel>(_data.GetItems());
                flashParam = new FlashSettings(600, 400);

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
开发者ID:Tanvas,项目名称:convertorXML2HTML,代码行数:24,代码来源:CourseModelForXSLT.cs

示例2: Init

        public async void Init(string group, string title)
        {
            var dataSource = DataServiceFactoryHelper.DataSources.FirstOrDefault(ds => ds.ServiceName == group);

            if (dataSource != null)
            {
                _dataService = _dataServiceFactory.GenerateService(dataSource);
                var items = await _dataService.GetItems();
                SelectedGroup.Add(new Group<Item>(dataSource.ServiceName, items));

                if (!string.IsNullOrWhiteSpace(title))
                {
                    SelectedItem = items.FirstOrDefault(i => i.Title == title);
                }

                if (SelectedItem == null)
                {
                    SelectedItem = items.FirstOrDefault();
                }
            }
        }
开发者ID:Rob-Kachmar,项目名称:Bootcamp,代码行数:21,代码来源:GroupDetailsViewModel.cs

示例3: LoadDataService

        private async Task LoadDataService(IDataService dataService, bool overrideCache = false)
        {
            List<Item> currentItems = new List<Item>();

            bool loadedFromCache = false;

            if (fileStore != null)
            {
                string lastRefreshText;
                if (fileStore.TryReadTextFile("LastRefresh-" + dataService.GetType().ToString(), out lastRefreshText))
                {
                    var lastRefreshTime = DateTime.Parse(lastRefreshText);
                    var timeSinceLastRefreshInMinutes = (DateTime.Now - lastRefreshTime).TotalMinutes;

                    //has cache expired?
                    if (overrideCache || timeSinceLastRefreshInMinutes > AppSettings.CacheIntervalInMinutes)
                    {
                        currentItems = await dataService.GetItems();
                    }
                    else //load from cache
                    {
                        string cachedItemsText;
                        pool.WaitOne();
                        try
                        {
                            if (fileStore.TryReadTextFile("CachedItems-" + dataService.GetType().ToString(), out cachedItemsText))
                            {
                                currentItems = mvxJsonConverter.DeserializeObject<List<Item>>(cachedItemsText);
                                loadedFromCache = true;
                            }
                        }
                        catch
                        {
                            ServiceLocator.MessageService.ShowErrorAsync("Error Deserializing " + dataService.GetType().ToString(), "Error loading cache");
                        }
                        finally
                        {
                            pool.Release();
                        }
                    }
                }
                else
                {
                    currentItems = await dataService.GetItems();
                }
            }

            try
            {
                if (!loadedFromCache && currentItems.Count > 0)
                {
                    if (fileStore.Exists("CachedItems-" + dataService.GetType().ToString()))
                        fileStore.DeleteFile("CachedItems-" + dataService.GetType().ToString());

                    if (fileStore.Exists("LastRefresh-" + dataService.GetType().ToString()))
                        fileStore.DeleteFile("LastRefresh-" + dataService.GetType().ToString());

                    fileStore.WriteFile("CachedItems-" + dataService.GetType().ToString(), mvxJsonConverter.SerializeObject(currentItems));
                    fileStore.WriteFile("LastRefresh-" + dataService.GetType().ToString(), DateTime.Now.ToString());
                }

                items.AddRange(currentItems);
            }
            catch
            {
                ServiceLocator.MessageService.ShowErrorAsync("Error retrieving items from " + dataService.GetType().ToString() + "\n\nPossible Causes:\nNo internet connection\nRemote Service unavailable", "Application Error");
            }

        }
开发者ID:jbienzms,项目名称:XPlatformCloudKit,代码行数:69,代码来源:ItemsShowcaseViewModel.cs

示例4: MainViewModel

 public MainViewModel(IDataService dataService)
 {
     IEnumerable<Person> people = dataService.GetItems();
     People = new ObservableCollection<Person>(people);
 }
开发者ID:qmatteoq,项目名称:MSFest-Samples,代码行数:5,代码来源:MainViewModel.cs


注:本文中的IDataService.GetItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。