/// <summary>
        /// Repeats the provided traversal until the provided condition is met
        /// </summary>
        /// <returns>The repeat.</returns>
        /// <param name="traversal">The sub query to repeat</param>
        /// <param name="condition">The condition that must be met to end the loop</param>
        /// <param name="type">Specifies a do-while or while-do loop</param>
        public Query Repeat <TOutput>(ITraversalQuery <T, TOutput> traversal, ITraversalQuery <T> condition, RepeatTypeEnum type)
        {
            if (traversal.Steps.Count < 1)
            {
                throw new ArgumentException("Provided traversal must contain at least one step");
            }
            if (condition.Steps.Count < 1)
            {
                throw new ArgumentException("Provided condition must have at least one step");
            }
            string until  = "until(" + condition.ToString() + ")";
            string repeat = "repeat(" + traversal.ToString() + ")";

            switch (type)
            {
            case RepeatTypeEnum.DoWhile:
                Steps.Add(repeat + "." + until);
                break;

            case RepeatTypeEnum.WhileDo:
                Steps.Add(until + "." + repeat);
                break;
            }
            return(this as Query);
        }
 internal TraversalQuery(ITraversalQuery query)
 {
     if (query is null)
     {
         throw new ArgumentNullException("Step list cannot be null");
     }
     Steps = query.Steps;
 }
 protected CollectionQueryTemplate(ITraversalQuery <From> query)
 {
     if (query is null)
     {
         throw new ArgumentException("Step list cannot be null");
     }
     Steps = query.Steps;
 }
 /// <summary>
 /// Repeats the provided traversal
 /// </summary>
 /// <param name="traversal">The sub query to repeat</param>
 /// <param name="count">The number of times to repeat the sub query</param>
 public CollectionQuery <TOutput, From> Repeat <TOutput>(ITraversalQuery <T, TOutput> traversal, int count)
 {
     if (count < 1)
     {
         throw new ArgumentException("Repeat count must be greater than 0");
     }
     if (traversal.Steps.Count < 1)
     {
         throw new ArgumentException("Provided traversal must contain at least one step");
     }
     Steps.Add("repeat(" + traversal.ToString() + ").times(" + count.ToString() + ")");
     return(new CollectionQuery <TOutput, From>(this));
 }
Beispiel #5
0
 protected DictionaryQueryTemplate(ITraversalQuery <From> query) : base(query)
 {
 }
Beispiel #6
0
 internal IntegerQuery(ITraversalQuery <From> query) : base(query)
 {
 }
Beispiel #7
0
 internal StringQuery(ITraversalQuery <From> query) : base(query)
 {
 }
Beispiel #8
0
 internal ValueQuery(ITraversalQuery <From> query) : base(query)
 {
 }
 internal DictionaryQuery(ITraversalQuery <From> query) : base(query)
 {
 }
 internal PropertyQuery(ITraversalQuery <From> query) : base(query)
 {
 }
Beispiel #11
0
 internal EdgeQuery(ITraversalQuery <From> query) : base(query)
 {
 }
 /// <summary>
 /// Returns the result of the specified traversal if it yields a result else it returns the calling element
 /// </summary>
 public Query Optional(ITraversalQuery <T, T> subquery)
 {
     Steps.Add("optional(" + subquery.ToString() + ")");
     return(this as Query);
 }
        /*
         * public Query Next()
         * {
         *  Steps.Add("next()");
         *  return this as Query;
         * }
         */

        /*
         * public Query Next(int count)
         * {
         *  if (count < 1)
         *      throw new ArgumentException("Count must be greater than zero");
         *  Steps.Add(string.Format("next({0})", count));
         *  return this as Query;
         * }
         */

        /// <summary>
        /// Removes objects from the traversal stream when the traversal provided as an argument does not return any objects
        /// </summary>
        public Query Not(ITraversalQuery <T, T> subquery)
        {
            Steps.Add("not(" + subquery.ToString() + ")");
            return(this as Query);
        }
 /// <summary>
 /// Executes the provided query on each incoming item
 /// </summary>
 /// <param name="localQuery">The query to execute on each incoming item</param>
 public CollectionQuery <TOutput, From> Local <TOutput>(ITraversalQuery <T, TOutput> localQuery)
 {
     Steps.Add("local(" + localQuery.ToString() + ")");
     return(new CollectionQuery <TOutput, From>(this));
 }
 /// <summary>
 /// Routes the current traverser to a particular traversal branch option
 /// </summary>
 /// <returns>The choose.</returns>
 /// <param name="condition">Condition to evaluate</param>
 /// <param name="TrueQuery">Path executed if the condition yields a result</param>
 /// <param name="FalseQuery">Path executed if the condition does not yields a result</param>
 public CollectionQuery <TOutput, From> Choose <TOutput>(ITraversalQuery <T> condition, ITraversalQuery <T, TOutput> TrueQuery, ITraversalQuery <T, TOutput> FalseQuery)
 {
     Steps.Add("choose(" + condition.ToString() + ", __." + TrueQuery.ToString() + ", __." + FalseQuery + ")");
     return(new CollectionQuery <TOutput, From>(this));
 }
Beispiel #16
0
 internal TraversalBuilder(IDomainModel domain)
 {
     _query = new TraversalQuery(domain);
 }
Beispiel #17
0
 internal ListQuery(ITraversalQuery <From> query) : base(query)
 {
 }
Beispiel #18
0
 internal VertexQuery(ITraversalQuery <From> query) : base(query)
 {
 }
Beispiel #19
0
 ///-------------------------------------------------------------------------------------------------
 /// <summary>
 ///  Initializes this instance.
 /// </summary>
 /// <param name="query">
 ///  The query.
 /// </param>
 ///-------------------------------------------------------------------------------------------------
 void IGraphPathTraverser.Initialize(ITraversalQuery query)
 {
     Contract.Requires(query, "query");
     _query = query;
 }
 /// <summary>
 /// Filters results based on a sub query
 /// </summary>
 public Query Where(ITraversalQuery <T> condition)
 {
     Steps.Add("where(" + condition.ToString() + ")");
     return(this as Query);
 }
 protected PropertyQueryTemplate(ITraversalQuery <From> query) : base(query)
 {
 }
 protected EdgeQueryTemplate(ITraversalQuery <From> query) : base(query)
 {
 }
 internal TerminalQuery(ITraversalQuery query) : base(query)
 {
 }
 internal CollectionQuery(ITraversalQuery <From> query) : base(query)
 {
 }
Beispiel #25
0
 protected VertexQueryTemplate(ITraversalQuery <From> query) : base(query)
 {
 }