2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 13:33:13 +00:00

Static Calling

This commit is contained in:
2022-08-07 23:09:31 +03:00
parent 0dc457bf7e
commit af94ce318a
18 changed files with 784 additions and 259 deletions

View File

@ -482,6 +482,36 @@ public static Hashtable Cached
else
return Expression;
}
public static Regex GetRouteRegex(string url)
{
var sc = Regex.Match(url, @"([^\{]*)\{([^\}]*)\}([^\{]*)");
List<VarInfo> vars = new List<VarInfo>();
while (sc.Success)
{
vars.Add(new VarInfo()
{
Pre = sc.Groups[1].Value,
VarName = sc.Groups[2].Value,
Post = sc.Groups[3].Value
});
sc = sc.NextMatch();
}
if (vars.Count > 0)
{
return new Regex("^" + String.Join("", vars.Select(x => x.Build()).ToArray()) + "$");
}
else
{
return new Regex("^" + Regex.Escape(url) + "$");
}
}
//public void Replace(string Expression, string Find, string Replacement, int Start, int Count)
//{
// Expression.IndexOf(