コード例 #1
0
ファイル: GridWindow.cs プロジェクト: borisdj/dextop
		GridModel[] Read(DextopReadFilter filter)
		{
			return new[] {
                new GridModel { Id = 1, Name = "Bill", Age = 30, Height=180 },
                new GridModel { Id = 2, Name = "Bob", Age = 26, Height=175 }               
            };
		}       
コード例 #2
0
ファイル: LinkedCombos.cs プロジェクト: borisdj/dextop
        IEnumerable<ComboModel> GetValues3(DextopReadFilter filter)
        {
            var baseValue = filter.Params.SafeGet("Value2", 0);

            for (var i = baseValue+1; i < 10; i++)
                yield return new ComboModel { Id = i };
        }
コード例 #3
0
        /// <summary>
        /// Creates the paged result by reading the IQueryable source.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">The source.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="fastTotal">Indicates that N+1 paging is used.</param>
        /// <returns></returns>
        public static DextopReadResult <T> CreatePage <T>(IQueryable <T> source, DextopReadFilter filter, bool fastTotal = false) where T : class
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter");
            }

            source = ApplySort(source, filter);

            if (filter.limit.HasValue)
            {
                int limit = filter.GetLimit();
                int start = filter.GetStart();
                if (fastTotal)
                {
                    var data = source.Skip(start).Take(limit + 1).ToArray();
                    return(Create(data.Take(limit).ToArray(), start + data.Length));
                }
                else
                {
                    return(Create(source.Skip(start).Take(limit).ToArray(), source.Count()));
                }
            }
            return(Create(source.ToArray()));
        }
コード例 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 public DextopReadResult <T> Read(DextopReadFilter filter)
 {
     if (Paging)
     {
         return(DextopReadResult.CreatePage(data.Values.AsQueryable(), filter));
     }
     return(DextopReadResult.Sort(data.Values.AsQueryable(), filter));
 }
コード例 #5
0
 /// <summary>
 /// Creates the result by sorting end enumerating the specified source.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source">The source.</param>
 /// <param name="filter">The filter.</param>
 /// <returns></returns>
 public static DextopReadResult <T> Sort <T>(IQueryable <T> source, DextopReadFilter filter) where T : class
 {
     if (filter == null)
     {
         throw new ArgumentNullException("filter");
     }
     source = ApplySort(source, filter);
     return(Create(source.ToArray()));
 }
コード例 #6
0
        CurrencyHistoryRate[] LoadHistory(DextopReadFilter filter)
        {
            String iso;
            filter.Params.TryGet<String>("ISOCode", out iso);
            var baseCurency = filter.Params.SafeGet<String>("BaseCurrencyISOCode", "EUR");

            if (baseCurency == "EUR")
                return CurrencyHistoryDataProvider.GetCurrencyRateHistory(iso);
            else
                return CurrencyHistoryDataProvider.GetCurrencyRateComparisionHistory(iso, baseCurency);
        }
コード例 #7
0
        RateModel[] Load(DextopReadFilter filter)
        {
            var currency = filter.Params.SafeGet("Currency", "EUR");
            var amount = filter.Params.SafeGet("Amount", 100.0m);

            var data = CurrencyDataProvider.GetCurrencyList(currency);
            return data.Rates.Select(a => new RateModel
            {
                Currency = a.Currency,
                ISOCode = a.ISOCode,
                Rate = a.Rate,
                Amount = amount * a.Rate
            }).ToArray();
        }
コード例 #8
0
        RemoteLookupModel[] RemoteLookup(DextopReadFilter filter)
        {
            String query = filter.Params.SafeGet<String>("query");

            var data = new [] {
                new RemoteLookupModel { Code = "Red", Description = "Code Red"},
                new RemoteLookupModel { Code = "Blue", Description = "Code Blue"},
                new RemoteLookupModel { Code = "Green", Description = "Code Green"},
            };

            if (String.IsNullOrWhiteSpace(query))
                return data;

            return data.Where(a => a.Code.StartsWith(query) || a.Description.Contains(query)).ToArray();
        }
コード例 #9
0
        static IQueryable <T> ApplySort <T>(IQueryable <T> source, DextopReadFilter filter) where T : class
        {
            if (filter == null)
            {
                return(source);
            }

            if (filter.sort != null && filter.sort.Length > 0)
            {
                var  sorter = filter.sort[0];
                bool asc    = IsAscendingDirection(sorter.direction);
                source = source.OrderBy(sorter.property, asc);
                for (var i = 1; i < filter.sort.Length; i++)
                {
                    sorter = filter.sort[i];
                    asc    = IsAscendingDirection(sorter.direction);
                    source = source.ThenBy(sorter.property, asc);
                }
            }

            return(source);
        }
コード例 #10
0
 DextopReadResult IDextopReadProxy.Read(DextopReadFilter options)
 {
     return(proxy.Read(options));
 }
コード例 #11
0
 /// <summary>
 /// Reads the data using specified filter.
 /// </summary>
 /// <param name="filter">The filter.</param>
 /// <returns></returns>
 public DextopReadResult <T> Read(DextopReadFilter filter)
 {
     return(d(filter));
 }
コード例 #12
0
ファイル: StocksPanel.cs プロジェクト: borisdj/dextop-pecunia
 Stock[] Load(DextopReadFilter filter)
 {
     var data = StockDataProvider.GetStockData();
     return data.ToArray();
 }
コード例 #13
0
ファイル: GridColumnRenderers.cs プロジェクト: borisdj/dextop
		GridModel[] Read(DextopReadFilter filter)
		{
            return new[] {
                new GridModel { Id = 1, Date = DateTime.Today, Bool = true, Time = DateTime.Now.TimeOfDay, Tooltip = "Hover", TooltipField = "Leave me alone!"}
            };
		}       
コード例 #14
0
 DextopReadResult IDextopReadProxy.Read(DextopReadFilter filter)
 {
     return(proxy.Read(filter));
 }
コード例 #15
0
 /// <summary>
 /// Read records using the specified filter.
 /// </summary>
 /// <param name="filter">The filter.</param>
 /// <returns>Read result.</returns>
 public abstract DextopReadResult <T> Read(DextopReadFilter filter);
コード例 #16
0
ファイル: BufferedGrid.cs プロジェクト: borisdj/dextop
		DextopReadResult<GridModel> Read(DextopReadFilter filter)
		{
			return DextopReadResult.CreatePage(data.AsQueryable(), filter);
		}