Ejemplo n.º 1
0
        private static void ValidateCount(ODataPathSegment segment, IEdmModel model)
        {
            Contract.Assert(segment != null);
            Contract.Assert(model != null);

            NavigationPathSegment navigationPathSegment = segment as NavigationPathSegment;
            if (navigationPathSegment != null)
            {
                if (EdmLibHelpers.IsNotCountable(navigationPathSegment.NavigationProperty, model))
                {
                    throw new InvalidOperationException(Error.Format(
                        SRResources.NotCountablePropertyUsedForCount,
                        navigationPathSegment.NavigationPropertyName));
                }
                return;
            }

            PropertyAccessPathSegment propertyAccessPathSegment = segment as PropertyAccessPathSegment;
            if (propertyAccessPathSegment != null)
            {
                if (EdmLibHelpers.IsNotCountable(propertyAccessPathSegment.Property, model))
                {
                    throw new InvalidOperationException(Error.Format(
                        SRResources.NotCountablePropertyUsedForCount,
                        propertyAccessPathSegment.PropertyName));
                }
            }
        }
        /// <inheritdoc />
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.UnboundFunction)
            {
                UnboundFunctionPathSegment functionSegment = (UnboundFunctionPathSegment)pathSegment;
                if (_functionName == functionSegment.FunctionName)
                {
                    var enumNames = functionSegment.Function.Function.Parameters.Where(p => p.Type.IsEnum()).Select(p => p.Name);
                    if (KeyValuePathSegmentTemplate.TryMatch(ParameterMappings, functionSegment.Values, values,
                        enumNames))
                    {
                        foreach (KeyValuePair<string, string> nameAndValue in functionSegment.Values)
                        {
                            string name = nameAndValue.Key;
                            object value = functionSegment.GetParameterValue(name);

                            //ProcedureRoutingConventionHelpers.AddFunctionParameters(functionSegment.Function.Function, name,
                            //    value, values, values, ParameterMappings);
                            throw new NotImplementedException("UnboundFunctionPathSegmentTemplate");
                        }

                        return true;
                    }
                }
            }

            return false;
        }
        /// <inheritdoc />
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.DynamicProperty)
            {
                var dynamicPropertyPathSegment = (DynamicPropertyPathSegment)pathSegment;

                // If we're treating the property name as a parameter store the provided name in our values collection
                // using the name from the template as the key.
                if (TreatPropertyNameAsParameterName)
                {
                    //values[PropertyName] = dynamicPropertyPathSegment.PropertyName;
                    //values[ODataParameterValue.ParameterValuePrefix + PropertyName] =
                    //    new ODataParameterValue(dynamicPropertyPathSegment.PropertyName,
                    //        EdmLibHelpers.GetEdmPrimitiveTypeReferenceOrNull(typeof(string)));
                    //return true;
                    throw new NotImplementedException("DynamicPropertyPathSegmentTemplate");
                }

                if (PropertyName == dynamicPropertyPathSegment.PropertyName)
                {
                    return true;
                }
            }

            return false;
        }
        /// <inheritdoc />
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.Key)
            {
                KeyValuePathSegment keySegment = (KeyValuePathSegment)pathSegment;
                return TryMatch(ParameterMappings, keySegment.Values, values, null);
            }

            return false;
        }
Ejemplo n.º 5
0
        /// <inheritdoc/>
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.Action)
            {
                BoundActionPathSegment actionSegment = (BoundActionPathSegment)pathSegment;
                return actionSegment.Action == Action && actionSegment.ActionName == ActionName;
            }

            return false;
        }
Ejemplo n.º 6
0
        /// <inheritdoc/>
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.Singleton)
            {
                SingletonPathSegment singletonSegment = (SingletonPathSegment)pathSegment;
                return singletonSegment.Singleton == Singleton && singletonSegment.SingletonName == SingletonName;
            }

            return false;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Matches the template with an <see cref="ODataPathSegment"/>.
 /// </summary>
 /// <param name="pathSegment">The path segment to match this template with.</param>
 /// <param name="values">The dictionary of matches to be updated if the segment matches the template.</param>
 /// <returns><c>true</c> if the segment matches the template; otherwise, <c>false</c>.</returns>
 public virtual bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
 {
     return false;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Matches the template with an <see cref="ODataPathSegment"/>.
 /// </summary>
 /// <param name="pathSegment">The path segment to match this template with.</param>
 /// <param name="values">The dictionary of matches to be updated if the segment matches the template.</param>
 /// <returns><c>true</c> if the segment matches the template; otherwise, <c>false</c>.</returns>
 public virtual bool TryMatch(ODataPathSegment pathSegment, IDictionary <string, object> values)
 {
     return(false);
 }
Ejemplo n.º 9
0
        /// <inheritdoc/>
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.Property)
            {
                PropertyAccessPathSegment propertySegment = (PropertyAccessPathSegment)pathSegment;
                return propertySegment.Property == Property && propertySegment.PropertyName == PropertyName;
            }

            return false;
        }
Ejemplo n.º 10
0
 /// <inheritdoc/>
 public override bool TryMatch(ODataPathSegment pathSegment, IDictionary <string, object> values)
 {
     return(pathSegment.SegmentKind == ODataSegmentKinds.Ref);
 }
Ejemplo n.º 11
0
        /// <inheritdoc />
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.UnboundFunction)
            {
                UnboundFunctionPathSegment functionSegment = (UnboundFunctionPathSegment)pathSegment;
                return functionSegment.Function == Function && functionSegment.FunctionName == FunctionName;
            }

            return false;
        }
Ejemplo n.º 12
0
        /// <inheritdoc/>
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.Navigation)
            {
                NavigationPathSegment navigationSegment = (NavigationPathSegment)pathSegment;
                return navigationSegment.NavigationProperty == NavigationProperty
                    && navigationSegment.NavigationPropertyName == NavigationPropertyName;
            }

            return false;
        }
Ejemplo n.º 13
0
 /// <inheritdoc/>
 public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
 {
     return
         pathSegment.SegmentKind == ODataSegmentKinds.DynamicProperty &&
         ((DynamicPropertyPathSegment)pathSegment).PropertyName == PropertyName;
 }
Ejemplo n.º 14
0
 /// <inheritdoc/>
 public override bool TryMatch(ODataPathSegment pathSegment, IDictionary <string, object> values)
 {
     return
         (pathSegment.SegmentKind == ODataSegmentKinds.DynamicProperty &&
          ((DynamicPropertyPathSegment)pathSegment).PropertyName == PropertyName);
 }
Ejemplo n.º 15
0
 /// <inheritdoc/>
 public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
 {
     return pathSegment.SegmentKind == ODataSegmentKinds.Value;
 }
Ejemplo n.º 16
0
        /// <inheritdoc/>
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.ComplexCast)
            {
                ComplexCastPathSegment castSegment = (ComplexCastPathSegment)pathSegment;
                return castSegment.CastType == CastType && castSegment.CastTypeName == CastTypeName;
            }

            return false;
        }
Ejemplo n.º 17
0
        /// <inheritdoc/>
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary<string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.EntitySet)
            {
                EntitySetPathSegment entitySetSegment = (EntitySetPathSegment)pathSegment;
                return entitySetSegment.EntitySetBase == EntitySetBase && entitySetSegment.EntitySetName == EntitySetName;
            }

            return false;
        }