Ejemplo n.º 1
0
        /// <summary>Gets a string with methods allowed on the target for the <paramref name="description"/>.</summary>
        /// <param name="configuration">configuration object which has the data</param>
        /// <param name="description">Description with target.</param>
        /// <returns>A string with methods allowed on the description; possibly null.</returns>
        internal static string GetAllowedMethods(DataServiceConfiguration configuration, RequestDescription description)
        {
            Debug.Assert(description != null, "description != null");
            Debug.Assert(
                description.TargetKind != RequestTargetKind.Nothing,
                "description.TargetKind != RequestTargetKind.Void - otherwise it hasn't been determined yet");
            Debug.Assert(
                description.TargetKind != RequestTargetKind.VoidOperation,
                "description.TargetKind != RequestTargetKind.VoidOperation - this method is only for containers");
            if (description.TargetKind == RequestTargetKind.Metadata ||
                description.TargetKind == RequestTargetKind.ServiceDirectory)
            {
                return(XmlConstants.HttpMethodGet);
            }

            if (description.TargetKind == RequestTargetKind.Batch)
            {
                return(XmlConstants.HttpMethodPost);
            }

            int index = description.GetIndexOfTargetEntityResource();

            Debug.Assert(index >= 0 && index < description.SegmentInfos.Count, "index >=0 && index <description.SegmentInfos.Count");
            ResourceSetWrapper container = description.SegmentInfos[index].TargetResourceSet;

            return(GetAllowedMethods(configuration, container, description));
        }