예제 #1
0
        /// <summary>
        /// Concatenates the given sequence of segment sets into a comma and slash delimited string
        /// </summary>
        /// <param name="converter">The uri to string converter to extend</param>
        /// <param name="segmentSets">the segment sets to concatenate</param>
        /// <returns>the concatenated segment string</returns>
        public static string ConcatenateSegments(this IODataUriToStringConverter converter, ODataUriSegmentPathCollection segmentSets)
        {
            var builder = new StringBuilder();

            converter.ConcatenateSegments(builder, segmentSets);
            return(builder.ToString());
        }
예제 #2
0
        /// <summary>
        /// Concatenates the given sequence of segments into a slash-delimited string
        /// </summary>
        /// <param name="converter">The uri to string converter to extend</param>
        /// <param name="segments">the segments to concatenate</param>
        /// <returns>the concatenated segment string</returns>
        public static string ConcatenateSegments(this IODataUriToStringConverter converter, IEnumerable <ODataUriSegment> segments)
        {
            var builder = new StringBuilder();

            converter.ConcatenateSegments(builder, segments);
            return(builder.ToString());
        }
예제 #3
0
        /// <summary>
        /// Concatenates the given sequence of segment sets onto the given string builder
        /// </summary>
        /// <param name="converter">The uri to string converter to extend</param>
        /// <param name="builder">The string builder to append onto</param>
        /// <param name="segmentSets">The segment sets to append</param>
        public static void ConcatenateSegments(this IODataUriToStringConverter converter, StringBuilder builder, ODataUriSegmentPathCollection segmentSets)
        {
            ExceptionUtilities.CheckArgumentNotNull(converter, "converter");
            ExceptionUtilities.CheckArgumentNotNull(builder, "builder");
            ExceptionUtilities.CheckCollectionNotEmpty(segmentSets, "segmentSets");

            bool isFirstSegmentSet = true;

            foreach (var segments in segmentSets)
            {
                if (!isFirstSegmentSet)
                {
                    builder.Append(',');
                }

                isFirstSegmentSet = false;
                converter.ConcatenateSegments(builder, segments);
            }
        }
예제 #4
0
        /// <summary>
        /// Concatenates the given sequence of segments onto the given string builder
        /// </summary>
        /// <param name="converter">The uri to string converter to extend</param>
        /// <param name="builder">The string builder to append onto</param>
        /// <param name="segments">The segments to append</param>
        public static void ConcatenateSegments(this IODataUriToStringConverter converter, StringBuilder builder, IEnumerable <ODataUriSegment> segments)
        {
            ExceptionUtilities.CheckArgumentNotNull(converter, "converter");
            ExceptionUtilities.CheckArgumentNotNull(builder, "builder");
            ExceptionUtilities.CheckCollectionNotEmpty(segments, "segments");

            bool isFirstSegment = true;

            foreach (var segment in segments)
            {
                if (!isFirstSegment && segment.HasPrecedingSlash)
                {
                    if (builder[builder.Length - 1] != '/')
                    {
                        builder.Append('/');
                    }
                }

                isFirstSegment = false;
                builder.Append(converter.ConvertToString(segment));
            }
        }
예제 #5
0
 /// <summary>
 /// Extracts the names of properties specified in the $select option, if any.
 /// </summary>
 /// <param name="uri">The URI to parse.</param>
 /// <param name="uriToStringConverter">The IODataUriToStringConverter implementation.</param>
 /// <returns>The list of property names.</returns>
 public static IEnumerable <string> GetSelectedPropertyNamesFromUri(ODataUri uri, IODataUriToStringConverter uriToStringConverter)
 {
     return(uri.SelectSegments.Select(s => uriToStringConverter.ConcatenateSegments(s.Where(s2 => !(s2 is EntityTypeSegment)))));
 }
예제 #6
0
 /// <summary>
 /// Helper method for converting an OData uri directly to a system Uri
 /// </summary>
 /// <param name="converter">The uri-to-string converter to extend</param>
 /// <param name="uri">The uri to convert</param>
 /// <returns>The system uri for the given OData uri</returns>
 public static Uri ConvertToUri(this IODataUriToStringConverter converter, ODataUri uri)
 {
     ExceptionUtilities.CheckArgumentNotNull(converter, "converter");
     ExceptionUtilities.CheckArgumentNotNull(uri, "uri");
     return(new Uri(converter.ConvertToString(uri), UriKind.RelativeOrAbsolute));
 }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the ODataRequest class
 /// </summary>
 /// <param name="uriToStringConverter">The OData uri to string converter to use when sending the request</param>
 /// <param name="requestManager">The IODataRequestManager used for building the ODataRequest (which is needed for cloning)</param>
 internal ODataRequest(IODataUriToStringConverter uriToStringConverter, IODataRequestManager requestManager = null)
 {
     ExceptionUtilities.CheckArgumentNotNull(uriToStringConverter, "uriToStringConverter");
     this.uriToStringConverter = uriToStringConverter;
     this.RequestManager       = requestManager;
 }
예제 #8
0
 /// <summary>
 /// Extracts the names of properties specified in the $select option, if any.
 /// </summary>
 /// <param name="uri">The URI to parse.</param>
 /// <param name="uriToStringConverter">The IODataUriToStringConverter implementation.</param>
 /// <returns>The list of property names.</returns>
 public static IEnumerable<string> GetSelectedPropertyNamesFromUri(ODataUri uri, IODataUriToStringConverter uriToStringConverter)
 {
     return uri.SelectSegments.Select(s => uriToStringConverter.ConcatenateSegments(s.Where(s2 => !(s2 is EntityTypeSegment))));
 }