/// <summary>
        /// Initializes a new instance of the <see cref="DynamicPropertyPathSegmentTemplate"/> class.
        /// </summary>
        /// <param name="dynamicPropertyPathSegment">The path template segment to be parsed as a template.</param>
        public DynamicPropertyPathSegmentTemplate(DynamicPropertyPathSegment dynamicPropertyPathSegment)
        {
            if (dynamicPropertyPathSegment == null)
            {
                throw Error.ArgumentNull("dynamicPropertyPathSegment");
            }

            PropertyName = dynamicPropertyPathSegment.PropertyName;
            TreatPropertyNameAsParameterName = false;

            if (IsRouteParameter(PropertyName))
            {
                PropertyName = PropertyName.Substring(1, PropertyName.Length - 2);
                TreatPropertyNameAsParameterName = true;

                if (String.IsNullOrEmpty(PropertyName))
                {
                    throw new ODataException(
                        Error.Format(SRResources.EmptyParameterAlias, PropertyName, dynamicPropertyPathSegment));
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DynamicPropertyPathSegmentTemplate"/> class.
        /// </summary>
        /// <param name="dynamicPropertyPathSegment">The path template segment to be parsed as a template.</param>
        public DynamicPropertyPathSegmentTemplate(DynamicPropertyPathSegment dynamicPropertyPathSegment)
        {
            if (dynamicPropertyPathSegment == null)
            {
                throw Error.ArgumentNull("dynamicPropertyPathSegment");
            }

            PropertyName = dynamicPropertyPathSegment.PropertyName;
            TreatPropertyNameAsParameterName = false;

            if (IsRouteParameter(PropertyName))
            {
                PropertyName = PropertyName.Substring(1, PropertyName.Length - 2);
                TreatPropertyNameAsParameterName = true;

                if (String.IsNullOrEmpty(PropertyName))
                {
                    throw new ODataException(
                              Error.Format(SRResources.EmptyParameterAlias, PropertyName, dynamicPropertyPathSegment));
                }
            }
        }