public void Include(string path) { Check.NotEmpty(path, "path"); SpanPath spanPath = new SpanPath(ParsePath(path)); this.AddSpanPath(spanPath); }
// <summary> // Adds the path if it does not already exist // </summary> internal void AddSpanPath(SpanPath spanPath) { if (ValidateSpanPath(spanPath)) { RemoveExistingSubPaths(spanPath); _spanList.Add(spanPath); } }
internal void AddSpanPath(SpanPath spanPath) { if (this.ValidateSpanPath(spanPath)) { this.RemoveExistingSubPaths(spanPath); this._spanList.Add(spanPath); } }
// <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; }
private bool ValidateSpanPath(SpanPath spanPath) { for (int i = 0; i < this._spanList.Count; i++) { if (spanPath.IsSubPath(this._spanList[i])) { return(false); } } return(true); }
// <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); }
/// <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; }
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); } }
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); }
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); }
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; }
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); } }
/// <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; }
/// <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); } }
/// <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; }
/// <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; }