-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathRouteAttribute.cs
More file actions
33 lines (30 loc) · 862 Bytes
/
Copy pathRouteAttribute.cs
File metadata and controls
33 lines (30 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace BeetleX.Http.Clients
{
[AttributeUsage(AttributeTargets.Method)]
class RouteTemplateAttribute : Attribute
{
public RouteTemplateAttribute(string template)
{
Templete = template;
}
public string Templete { get; set; }
public string Analysis(string parent)
{
if (string.IsNullOrEmpty(Templete))
return null;
if (string.IsNullOrEmpty(parent))
parent = "/";
if (parent[parent.Length - 1] != '/')
parent += "/";
if (!Regex.IsMatch(Templete, @"(\{[A-Za-z0-9]+\})"))
{
return null;
}
return parent + Templete;
}
}
}