Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ApproveRegex.cs
1using System;
2using System.Reflection;
3using System.Text.RegularExpressions;
4
6{
11 {
12 private readonly Regex regex;
13
17 public ApproveRegex(Regex Regex)
18 {
19 this.regex = Regex;
20 }
21
31 public override bool? Check(FrameInformation Frame)
32 {
33 if (IsMatch(this.regex, Frame.TypeName + "." + Frame.Method.Name) ||
34 IsMatch(this.regex, Frame.TypeName) ||
35 IsMatch(this.regex, Frame.AssemblyName))
36 {
37 return true;
38 }
39
40 Type T = Frame.Type;
41 while (!(T is null) && T.Attributes.HasFlag(TypeAttributes.NestedPrivate))
42 {
43 T = T.DeclaringType;
44
45 if (IsMatch(this.regex, T.FullName + "." + Frame.Method.Name) ||
46 IsMatch(this.regex, T.FullName))
47 {
48 return true;
49 }
50 }
51
52 return null;
53 }
54
55 internal static bool IsMatch(Regex Regex, string s)
56 {
57 Match M = Regex.Match(s);
58 return M.Success && M.Index == 0 && M.Length == s.Length;
59 }
60 }
61}
Checks for approved sources in the call stack using a regular expression.
Definition: ApproveRegex.cs:11
override? bool Check(FrameInformation Frame)
Performs a check of a stack frame.
Definition: ApproveRegex.cs:31
ApproveRegex(Regex Regex)
Checks for approved sources in the call stack using a regular expression.
Definition: ApproveRegex.cs:17
Abstract base class for call stack checks.
Contains information about a specific frame in a call stack.
MethodBase Method
Method represented by the frame.
Type Type
Call made from this type.