GetSubstringAfterSegment() private static method

Gets a the substring after a segment.
private static GetSubstringAfterSegment ( string resourceId, string segmentName, bool selectLastSegment = true ) : string
resourceId string The resource Id.
segmentName string The segment name.
selectLastSegment bool When set to true, gets the last segment (default) otherwise gets the first one.
return string
        /// <summary>
        /// Gets either a resource type or resource Id based on the value of the <see cref="getResourceName"/> parameter.
        /// </summary>
        /// <param name="resourceId">The resource Id.</param>
        /// <param name="getResourceName">When set to true returns a resource name, otherwise a resource type.</param>
        /// <param name="includeProviderNamespace">Indicates if the provider namespace should be included in the resource name.</param>
        /// <param name="useLastSegment">Seek the last segment instead of the first match.</param>
        private static string GetResourceTypeOrName(string resourceId, bool getResourceName, bool includeProviderNamespace = true, bool useLastSegment = false)
        {
            var substring = ResourceIdUtility.GetSubstringAfterSegment(
                resourceId: resourceId,
                segmentName: Constants.Providers,
                selectLastSegment: useLastSegment);

            var segments = substring.CoalesceString().SplitRemoveEmpty('/');

            if (!segments.Any())
            {
                return(null);
            }

            var providerNamespace = segments.First();

            var segmentString = segments.Skip(1)
                                .TakeWhile(segment => !segment.EqualsInsensitively(Constants.Providers))
                                .Where((segment, index) => getResourceName ? index % 2 != 0 : index % 2 == 0)
                                .ConcatStrings("/");

            return(getResourceName
                ? segmentString
                : includeProviderNamespace
                    ? string.Format("{0}/{1}", providerNamespace, segmentString)
                    : segmentString);
        }
        /// <summary>
        /// Gets the next segment after the one specified in <paramref name="segmentName"/>.
        /// </summary>
        /// <param name="resourceId">The resource Id.</param>
        /// <param name="segmentName">The segment name.</param>
        /// <param name="selectLastSegment">When set to true, gets the last segment (default) otherwise gets the first one.</param>
        private static string GetNextSegmentAfter(string resourceId, string segmentName, bool selectLastSegment = false)
        {
            var segment = ResourceIdUtility
                          .GetSubstringAfterSegment(
                resourceId: resourceId,
                segmentName: segmentName,
                selectLastSegment: selectLastSegment)
                          .SplitRemoveEmpty('/')
                          .FirstOrDefault();

            return(string.IsNullOrWhiteSpace(segment)
                ? null
                : segment);
        }