/// <summary> /// selector: Name,Age,Location /// orderBy: /// - ascending : +Name,+Age /// - descending : -Name,-Age /// - mixed (OrderBy, ThenBy) : +Name,-Age /// query: &(Name=Roy)(Age=18) /// </summary> /// <param name="source"></param> /// <param name="selector"></param> /// <param name="filter"></param> /// <param name="orderBy"></param> /// <returns></returns> public static IQueryable QueryDynamic(this IQueryable source, string selector, string filter, string orderBy = null, int?skip = null, int?take = null) { var outputType = source.ElementType; if (selector != null) { var selectorExpression = SelectorBuilder.Build(source.ElementType, selector, out outputType); if (selectorExpression != null) { source = source.Provider.CreateQuery(Expression.Call(typeof(Queryable), "Select", new[] { source.ElementType, outputType }, source.Expression, selectorExpression)); } } if (filter != null) { var queryExpression = FilterParser.Parse(filter).Build(outputType); if (queryExpression != null) { source = source.Provider.CreateQuery(Expression.Call(typeof(Queryable), "Where", new[] { outputType }, source.Expression, queryExpression)); } } if (orderBy != null) { var isFirstOrder = true; foreach (var orderByField in orderBy.Split(",").Where(of => of.Length > 1)) { var memberName = orderByField[1..];
/// <inheritdoc/> protected override void Make(AppCommandRequest commandRequest) { string whereString = "where"; int whereIndex = commandRequest.Parameters.IndexOf(whereString, StringComparison.CurrentCultureIgnoreCase); string selectSection; IEnumerable <FileCabinetRecord> list; if (whereIndex < 0) { list = this.IsCached(commandRequest.Parameters, this.Service.GetRecords()); selectSection = commandRequest.Parameters; } else { string whereSection = commandRequest.Parameters.Substring(whereIndex + whereString.Length + 1); selectSection = commandRequest.Parameters.Substring(0, whereIndex); var filter = Parser.Parser.Parse(whereSection); list = this.IsCached(commandRequest.Parameters, this.Service.GetRecords().Where(x => filter.Execute(x))); } IEnumerable <string> fields = string.IsNullOrWhiteSpace(selectSection) ? SelectorBuilder.GetFieldsNames() : selectSection.Split(',').Select(x => x.Trim(' ')); Printer printer = new (fields); printer.Print(list); }
private void ProcessGroup(int vkGroupId = 0) { string groupSelector = string.Empty; try { SelectorBuilder selectorBuilder = new SelectorBuilder(); groupSelector = selectorBuilder.BuildSelector(vkGroupId); DataFeed firstCommand = this.ProcessFeedItem(groupSelector); if (firstCommand == null || firstCommand.IsSequenceTerminator) { this.log.InfoFormat("No items for selector = {0} found in the queue. Processing stopped.", groupSelector); return; } if (vkGroupId == 0) { vkGroupId = firstCommand.VkGroupId; } groupSelector = selectorBuilder.BuildSelector(vkGroupId, firstCommand.Type.ToString()); DataFeed processFeedItem = this.ProcessFeedItem(groupSelector, true); if (processFeedItem == null) { this.log.InfoFormat("No items for selector = {0} found in the queue. Processing stopped.", groupSelector); } } catch (Exception exc) { exc.Data.Add("Selector", groupSelector); throw; } }
public GateController NewDut() { _selector = SelectorBuilder.Build(); _pwmController = MockPwmController; _gateStates = GateStatesBuilder.Build(); return(new GateController(_selector, _pwmController, _gateStates.Object)); }
public QuestionPresenter(IQuestionView view) : base(view) { _view = view; if (_builder == null) { _builder = new SelectorBuilder(); } }
private void DefaultSelector <TCompatibleRequest>( CrudRequestConfig <TCompatibleRequest> config) { var requestKey = config.GetRequestKey(); var entityKey = config.GetKeyFor <TEntity>(); if (requestKey != null && entityKey != null) { var builder = new SelectorBuilder <TRequest, TEntity>(); config.SetEntitySelector <TEntity>(builder.Single(requestKey, entityKey)); } }
private void DefaultSelector <TCompatibleRequest>( CrudRequestConfig <TCompatibleRequest> config) { var itemKey = config.GetRequestKey(); var entityKey = config.GetKeyFor <TEntity>(); if (itemKey != null && entityKey != null) { var builder = new SelectorBuilder <TRequest, TEntity>(); config.SetEntitySelector <TEntity>(builder.Collection(_getRequestItems, entityKey, itemKey)); } }
private static ExpressionElement GetField(List <string> words, ref int index) { if (!SelectorBuilder.HasField(words[index])) { throw new ArgumentException($"Field name '{words[index]}' is not correct."); } var result = new ExpressionElement(words[index]); index++; return(result); }
public GateControllerFixture WithSelectedGate(int gateNr) { SelectorBuilder.WithSelected(gateNr); return(this); }