本文整理汇总了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);
}
}
示例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();
}
}
}
示例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");
}
}
示例4: MainViewModel
public MainViewModel(IDataService dataService)
{
IEnumerable<Person> people = dataService.GetItems();
People = new ObservableCollection<Person>(people);
}