Ejemplo n.º 1
0
		public void CtorName()
		{
			var s = new ExpandSegment ("name", null);
			Assert.AreEqual ("name", s.Name);
			Assert.AreEqual (null, s.Filter);
			Assert.IsFalse (s.HasFilter);
		}
Ejemplo n.º 2
0
		public void CtorFilter()
		{
			var param = Expression.Parameter (typeof (bool), "b");
			var filter = Expression.Lambda (param, param);
			var s = new ExpandSegment ("name", filter);

			Assert.AreEqual ("name", s.Name);
			Assert.AreEqual (filter, s.Filter);
			Assert.IsTrue (s.HasFilter);
		}
Ejemplo n.º 3
0
		public void HasFilterAddWithFilter()
		{
			var esc = new ExpandSegmentCollection();
			esc.Add (new ExpandSegment ("first", null));

			var param = Expression.Parameter (typeof (bool), "b");
			var filter = Expression.Lambda (param, param);
			var filteredSegment = new ExpandSegment ("second", filter);
			esc.Add (filteredSegment);
			Assert.IsTrue (esc.HasFilter);
		}
Ejemplo n.º 4
0
 internal ExpandedProjectionNode AddExpandedNode(ExpandSegment segment)
 {
     ExpandedProjectionNode node = (ExpandedProjectionNode) this.FindNode(segment.Name);
     if ((node != null) && (node.Property == segment.ExpandedProperty))
     {
         if (segment.TargetResourceType.IsAssignableFrom(node.TargetResourceType))
         {
             node.TargetResourceType = segment.TargetResourceType;
         }
         return node;
     }
     node = new ExpandedProjectionNode(segment.Name, segment.ExpandedProperty, segment.TargetResourceType, segment.Container, segment.OrderingInfo, segment.Filter, null, (segment.Container.PageSize != 0) ? new int?(segment.Container.PageSize) : null, (segment.MaxResultsExpected != 0x7fffffff) ? new int?(segment.MaxResultsExpected) : null);
     this.AddNode(node);
     return node;
 }
Ejemplo n.º 5
0
 private void CheckExpandPaths()
 {
     if (this.expandPathsAsText.Count > 0)
     {
         if (this.queryExpression == null)
         {
             throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestQueryProcessor_QueryExpandOptionNotApplicable);
         }
         if (this.description.TargetResourceType.ResourceTypeKind == ResourceTypeKind.Collection)
         {
             throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestQueryProcessor_QueryExpandOptionNotApplicable);
         }
     }
     this.expandPaths = new List <ExpandSegmentCollection>(this.expandPathsAsText.Count);
     for (int i = this.expandPathsAsText.Count - 1; i >= 0; i--)
     {
         ExpandSegmentCollection item = this.CheckSingleExpandPath(this.expandPathsAsText[i]);
         if (item == null)
         {
             this.expandPathsAsText.RemoveAt(i);
         }
         else
         {
             this.expandPaths.Add(item);
             ExpandedProjectionNode rootProjectionNode = this.GetRootProjectionNode();
             for (int j = 0; j < item.Count; j++)
             {
                 ExpandSegment          segment = item[j];
                 ExpandedProjectionNode node2   = rootProjectionNode.AddExpandedNode(segment);
                 this.GetRootProjectionNode().ExpansionOnDerivedTypesSpecified |= rootProjectionNode.HasExpandedPropertyOnDerivedType;
                 rootProjectionNode = node2;
             }
             this.GetRootProjectionNode().ExpansionsSpecified = true;
         }
     }
 }