Пример #1
0
    public void Include(string path)
    {
        Check.NotEmpty(path, "path");
        SpanPath spanPath = new SpanPath(ParsePath(path));

        this.AddSpanPath(spanPath);
    }
Пример #2
0
 // <summary>
 // Adds the path if it does not already exist
 // </summary>
 internal void AddSpanPath(SpanPath spanPath)
 {
     if (ValidateSpanPath(spanPath))
     {
         RemoveExistingSubPaths(spanPath);
         _spanList.Add(spanPath);
     }
 }
Пример #3
0
 internal void AddSpanPath(SpanPath spanPath)
 {
     if (this.ValidateSpanPath(spanPath))
     {
         this.RemoveExistingSubPaths(spanPath);
         this._spanList.Add(spanPath);
     }
 }
Пример #4
0
        // <summary>
        // Adds a path to span into the query.
        // </summary>
        // <param name="path"> The path to span </param>
        public void Include(string path)
        {
            Check.NotEmpty(path, "path");

            var spanPath = new SpanPath(ParsePath(path));

            AddSpanPath(spanPath);
            _cacheKey = null;
        }
Пример #5
0
    private bool ValidateSpanPath(SpanPath spanPath)
    {
        for (int i = 0; i < this._spanList.Count; i++)
        {
            if (spanPath.IsSubPath(this._spanList[i]))
            {
                return(false);
            }
        }

        return(true);
    }
Пример #6
0
 // <summary>
 // Returns true if the path can be added
 // </summary>
 private bool ValidateSpanPath(SpanPath spanPath)
 {
     // Check for dupliacte entries
     for (var i = 0; i < _spanList.Count; i++)
     {
         // make sure spanPath is not a sub-path of anything already in the list
         if (spanPath.IsSubPath(_spanList[i]))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #7
0
        /// <summary>
        /// Adds a path to span into the query.
        /// </summary>
        /// <param name="path">The path to span</param>
        public void Include(string path)
        {
            EntityUtil.CheckStringArgument(path, "path");
            if (path.Trim().Length == 0)
            {
                throw new ArgumentException(System.Data.Entity.Strings.ObjectQuery_Span_WhiteSpacePath, "path");
            }

            SpanPath spanPath = new SpanPath(ParsePath(path));

            AddSpanPath(spanPath);
            _cacheKey = null;
        }
Пример #8
0
        private void RemoveExistingSubPaths(SpanPath spanPath)
        {
            var toDelete = new List <SpanPath>();

            for (var i = 0; i < _spanList.Count; i++)
            {
                // make sure spanPath is not a sub-path of anything already in the list
                if (_spanList[i].IsSubPath(spanPath))
                {
                    toDelete.Add(_spanList[i]);
                }
            }

            foreach (var path in toDelete)
            {
                _spanList.Remove(path);
            }
        }
Пример #9
0
            public bool IsSubPath(SpanPath rhs)
            {
                // this is a subpath of rhs if it has fewer paths, and all the path element values are equal
                if (Navigations.Count > rhs.Navigations.Count)
                {
                    return(false);
                }

                for (int i = 0; i < Navigations.Count; i++)
                {
                    if (!Navigations[i].Equals(rhs.Navigations[i], StringComparison.OrdinalIgnoreCase))
                    {
                        return(false);
                    }
                }

                return(true);
            }
Пример #10
0
        internal string GetCacheKey()
        {
            if (null == _cacheKey)
            {
                if (_spanList.Count > 0)
                {
                    // If there is only a single Include path with a single property,
                    // then simply use the property name as the cache key rather than
                    // creating any new strings.
                    if (_spanList.Count == 1 &&
                        _spanList[0].Navigations.Count == 1)
                    {
                        _cacheKey = _spanList[0].Navigations[0];
                    }
                    else
                    {
                        StringBuilder keyBuilder = new StringBuilder();
                        for (int pathIdx = 0; pathIdx < _spanList.Count; pathIdx++)
                        {
                            if (pathIdx > 0)
                            {
                                keyBuilder.Append(";");
                            }

                            SpanPath thisPath = _spanList[pathIdx];
                            keyBuilder.Append(thisPath.Navigations[0]);
                            for (int propIdx = 1; propIdx < thisPath.Navigations.Count; propIdx++)
                            {
                                keyBuilder.Append(".");
                                keyBuilder.Append(thisPath.Navigations[propIdx]);
                            }
                        }

                        _cacheKey = keyBuilder.ToString();
                    }
                }
            }

            return(_cacheKey);
        }
Пример #11
0
            public bool IsSubPath(SpanPath rhs)
            {
                // this is a subpath of rhs if it has fewer paths, and all the path element values are equal
                if (Navigations.Count
                    > rhs.Navigations.Count)
                {
                    return false;
                }

                for (var i = 0; i < Navigations.Count; i++)
                {
                    if (!Navigations[i].Equals(rhs.Navigations[i], StringComparison.OrdinalIgnoreCase))
                    {
                        return false;
                    }
                }

                return true;
            }
Пример #12
0
        private void RemoveExistingSubPaths(SpanPath spanPath)
        {
            var toDelete = new List<SpanPath>();
            for (var i = 0; i < _spanList.Count; i++)
            {
                // make sure spanPath is not a sub-path of anything already in the list
                if (_spanList[i].IsSubPath(spanPath))
                {
                    toDelete.Add(_spanList[i]);
                }
            }

            foreach (var path in toDelete)
            {
                _spanList.Remove(path);
            }
        }
Пример #13
0
 /// <summary>
 ///     Returns true if the path can be added
 /// </summary>
 /// <param name="spanPath"> </param>
 private bool ValidateSpanPath(SpanPath spanPath)
 {
     // Check for dupliacte entries
     for (var i = 0; i < _spanList.Count; i++)
     {
         // make sure spanPath is not a sub-path of anything already in the list
         if (spanPath.IsSubPath(_spanList[i]))
         {
             return false;
         }
     }
     return true;
 }
Пример #14
0
 /// <summary>
 ///     Adds the path if it does not already exist
 /// </summary>
 /// <param name="spanPath"> </param>
 internal void AddSpanPath(SpanPath spanPath)
 {
     if (ValidateSpanPath(spanPath))
     {
         RemoveExistingSubPaths(spanPath);
         _spanList.Add(spanPath);
     }
 }
Пример #15
0
        /// <summary>
        ///     Adds a path to span into the query.
        /// </summary>
        /// <param name="path"> The path to span </param>
        public void Include(string path)
        {
            Check.NotEmpty(path, "path");

            var spanPath = new SpanPath(ParsePath(path));
            AddSpanPath(spanPath);
            _cacheKey = null;
        }
Пример #16
0
        /// <summary>
        /// Adds a path to span into the query.
        /// </summary>
        /// <param name="path">The path to span</param>
        public void Include(string path)
        {
            EntityUtil.CheckStringArgument(path, "path");
            if (path.Trim().Length == 0)
            {
                throw new ArgumentException(Strings.ObjectQuery_Span_WhiteSpacePath, "path");
            }

            var spanPath = new SpanPath(ParsePath(path));
            AddSpanPath(spanPath);
            _cacheKey = null;
        }