예제 #1
0
        public KeySegment(IEnumerable <KeyValuePair <string, object> > keys, IEdmEntityType edmType, IEdmNavigationSource navigationSource)
        {
            this.keys             = new ReadOnlyCollection <KeyValuePair <string, object> >(keys.ToList());
            this.edmType          = edmType;
            this.navigationSource = navigationSource;
            this.SingleResult     = true;

            // Check that the type they gave us is related to the type of the set
            if (navigationSource != null)
            {
                ExceptionUtil.ThrowIfTypesUnrelated(edmType, navigationSource.EntityType(), "KeySegments");
            }
        }
예제 #2
0
        /// <summary>
        /// Build the type segment based on the giving <paramref name="actualType"/> and <paramref name="expectedType"/>
        /// </summary>
        /// <param name="actualType">The actual type of this segment passed from Uri, which may be collection type.</param>
        /// <param name="expectedType">The type reflected from model.</param>
        /// <param name="navigationSource">The navigation source containing the entity or complex that we are casting. This can be null.</param>
        /// <exception cref="System.ArgumentNullException">Throws if the actual or expected edmType is null.</exception>
        /// <exception cref="ODataException">Throws if the actual edmType is not related to the expected type of elements in the input navigationSource.</exception>
        public TypeSegment(IEdmType actualType, IEdmType expectedType, IEdmNavigationSource navigationSource)
        {
            ExceptionUtils.CheckArgumentNotNull(actualType, "actualType");
            ExceptionUtils.CheckArgumentNotNull(expectedType, "expectedType");

            this.edmType          = actualType;
            this.navigationSource = navigationSource;

            this.TargetEdmType             = expectedType;
            this.TargetEdmNavigationSource = navigationSource;

            // Check that the type they gave us is related to the type of the set
            if (navigationSource != null)
            {
                ExceptionUtil.ThrowIfTypesUnrelated(actualType, expectedType, "TypeSegments");
            }
        }
예제 #3
0
        /// <summary>
        /// Build a BatchReferenceSegment
        /// </summary>
        /// <param name="contentId">The contentId of this segment is referring to</param>
        /// <param name="edmType">The <see cref="IEdmType"/> of the resource that this placeholder <see cref="BatchReferenceSegment"/> represents.</param>
        /// <param name="entitySet">The resulting entity set</param>
        /// <exception cref="System.ArgumentNullException">Throws if the input edmType of contentID is null.</exception>
        /// <exception cref="ODataException">Throws if the contentID is not in the right format.</exception>
        public BatchReferenceSegment(string contentId, IEdmType edmType, IEdmEntitySetBase entitySet)
        {
            ExceptionUtils.CheckArgumentNotNull(edmType, "resultingType");
            ExceptionUtils.CheckArgumentNotNull(contentId, "contentId");
            if (!ODataPathParser.ContentIdRegex.IsMatch(contentId))
            {
                throw new ODataException(ODataErrorStrings.BatchReferenceSegment_InvalidContentID(contentId));
            }

            this.edmType   = edmType;
            this.entitySet = entitySet;
            this.contentId = contentId;

            this.Identifier                = this.ContentId;
            this.TargetEdmType             = edmType;
            this.TargetEdmNavigationSource = this.EntitySet;
            this.SingleResult              = true;
            this.TargetKind                = RequestTargetKind.Resource;

            if (entitySet != null)
            {
                ExceptionUtil.ThrowIfTypesUnrelated(edmType, entitySet.EntityType(), "BatchReferenceSegments");
            }
        }