Exemplo n.º 1
0
        /// <summary>
        /// Tries to bind a given token as an a declared structural or navigation property.
        /// </summary>
        /// <param name="tokenIn">Token to bind.</param>
        /// <param name="edmType">the type to search for this property</param>
        /// <param name="resolver">Resolver for uri parser.</param>
        /// <param name="segment">Bound segment if the token was bound to a declared property successfully, or null.</param>
        /// <returns>True if the token was bound successfully, or false otherwise.</returns>
        private static bool TryBindAsDeclaredProperty(PathSegmentToken tokenIn, IEdmStructuredType edmType, ODataUriResolver resolver, out ODataPathSegment segment)
        {
            IEdmProperty prop = resolver.ResolveProperty(edmType, tokenIn.Identifier);

            if (prop == null)
            {
                segment = null;
                return(false);
            }

            if (prop.PropertyKind == EdmPropertyKind.Structural)
            {
                segment = new PropertySegment((IEdmStructuralProperty)prop);
                return(true);
            }

            if (prop.PropertyKind == EdmPropertyKind.Navigation)
            {
                segment = new NavigationPropertySegment((IEdmNavigationProperty)prop, null /*TODO: set*/);
                return(true);
            }

            throw new ODataException(ODataErrorStrings.SelectExpandBinder_UnknownPropertyType(prop.Name));
        }
 /// <summary>
 /// Translate a PropertySegment
 /// </summary>
 /// <param name="segment">the segment to Translate</param>
 /// <returns>Defined by the implementer.</returns>
 public override string Translate(PropertySegment segment)
 {
     Debug.Assert(segment != null, "segment != null");
     return("/" + segment.Property.Name);
 }
 /// <summary>
 /// Translate a PropertySegment
 /// </summary>
 /// <param name="segment">the segment to Translate</param>
 /// <returns>UserDefinedValue</returns>
 /// <exception cref="System.ArgumentNullException">Throws if the input segment is null.</exception>
 public override bool Translate(PropertySegment segment)
 {
     ExceptionUtils.CheckArgumentNotNull(segment, "segment");
     return(false);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Handle a PropertySegment
 /// </summary>
 /// <param name="segment">the segment to Handle</param>
 public virtual void Handle(PropertySegment segment)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
        /// <summary>
        /// Build a segment representing a property.
        /// </summary>
        /// <param name="path">Path to perform the computation on.</param>
        /// <param name="property">The property this segment represents.</param>
        /// <returns>>A new ODataPath with property segment appended to the end.</returns>
        public static ODataPath AddPropertySegment(this ODataPath path, IEdmStructuralProperty property)
        {
            PropertySegment propertySegment = new PropertySegment(property);

            return(path.AddSegment(propertySegment));
        }
 /// <summary>
 /// Handle a PropertySegment
 /// </summary>
 /// <param name="segment">the segment to Handle</param>
 public override void Handle(PropertySegment segment)
 {
     CommonHandler(segment);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Translate a PropertySegment
 /// </summary>
 /// <param name="segment">the segment to Translate</param>
 /// <returns>Defined by the implementer.</returns>
 public virtual T Translate(PropertySegment segment)
 {
     throw new NotImplementedException();
 }