Example #1
0
        public DirectoryEnumerator <T> Translate <T>(TranslatorContext context)
        {
            var directorySearch = context.DirectorySearcher;

            directorySearch.Filter = Parse(context).ToString();
            return(new DirectoryEnumerator <T>(context, ResultMapper, context.FindAll()));
        }
Example #2
0
 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);
     }
 }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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()));
        }
Example #6
0
        public object TranslateOne(Type elementType, DirectorySearcher searcher)
        {
            var context = new TranslatorContext(searcher);

            return(ResultMapper.Map(elementType, context.FindOne()));
        }
Example #7
0
        public T TranslateOne <T>(DirectorySearcher searcher)
        {
            var context = new TranslatorContext(searcher);

            return(ResultMapper.Map <T>(context.FindOne()));
        }
Example #8
0
        public DirectoryEnumerator <T> Translate <T>(DirectorySearcher searcher)
        {
            var context = new TranslatorContext(searcher);

            return(new DirectoryEnumerator <T>(context, ResultMapper, context.FindAll()));
        }