Example #1
0
        internal static MultiTenantRouteTemplate ParseTemplate(string template)
        {
            var originalTemplate = template;

            template = template.Trim('/');
            if (template == string.Empty)
            {
                // Special case "/";
                return(new MultiTenantRouteTemplate("/", Array.Empty <MultiTenantTemplateSegment>()));
            }

            var segments         = template.Split('/');
            var templateSegments = new MultiTenantTemplateSegment[segments.Length];

            for (int i = 0; i < segments.Length; i++)
            {
                var segment = segments[i];
                if (string.IsNullOrEmpty(segment))
                {
                    throw new InvalidOperationException(
                              $"Invalid template '{template}'. Empty segments are not allowed.");
                }

                if (segment[0] != '{')
                {
                    if (segment[segment.Length - 1] == '}')
                    {
                        throw new InvalidOperationException(
                                  $"Invalid template '{template}'. Missing '{{' in parameter segment '{segment}'.");
                    }
                    if (segment[^ 1] == '?')
Example #2
0
 private static int GetRank(MultiTenantTemplateSegment xSegment)
 {
     return(xSegment switch
     {
         // Literal
         { IsParameter : false } => 0,