public DirectoryEnumerator <T> Translate <T>(TranslatorContext context) { var directorySearch = context.DirectorySearcher; directorySearch.Filter = Parse(context).ToString(); return(new DirectoryEnumerator <T>(context, ResultMapper, context.FindAll())); }
private static void ParseOrderBy(TranslatorContext context, OrderByExpression orderBy) { if (orderBy != null) { var sortOption = context.DirectorySearcher.Sort; sortOption.Direction = (SortDirection)orderBy.Direction; sortOption.PropertyName = GetName(orderBy.OrderByProperty.Member); } }
private static FilterBuilder Parse(TranslatorContext context) { var expression = context.Expression; var builder = new FilterBuilder(expression.GetOrigionalType()); ParseWhereClause(builder, expression); ParseOrderBy(context, expression.OrderBy); return(builder); }
public T TranslateOne <T>(TranslatorContext context) { var result = TranslateOne(context); var select = context.Expression.Select; if (!(result is int) && select != null) { var origionalType = context.Expression.GetOrigionalType(); if (origionalType != typeof(T)) { var projection = select.Projection.Compile(); result = projection.DynamicInvoke(result); } } return((T)result); }
public object TranslateOne(TranslatorContext context) { var directorySearch = context.DirectorySearcher; var origionalType = context.Expression.GetOrigionalType(); directorySearch.Filter = Parse(context).ToString(); if (context.Expression.NodeType.Is(DirectoryExpressionType.SingleResult)) { var singleResultExpression = (SingleResultExpression)context.Expression; if (singleResultExpression.SingleResultType == SingleResultType.Count) { return(((SearchResults)context.FindAll()).Count); } } return(ResultMapper.Map(origionalType, context.FindOne())); }
public object TranslateOne(Type elementType, DirectorySearcher searcher) { var context = new TranslatorContext(searcher); return(ResultMapper.Map(elementType, context.FindOne())); }
public T TranslateOne <T>(DirectorySearcher searcher) { var context = new TranslatorContext(searcher); return(ResultMapper.Map <T>(context.FindOne())); }
public DirectoryEnumerator <T> Translate <T>(DirectorySearcher searcher) { var context = new TranslatorContext(searcher); return(new DirectoryEnumerator <T>(context, ResultMapper, context.FindAll())); }