1 //------------------------------------------------------------------------------
2 // <copyright file="CompiledRegexRunnerFactory.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //------------------------------------------------------------------------------
7 using System.Reflection.Emit;
8 using System.Diagnostics;
9 using System.Security.Permissions;
13 namespace System.Text.RegularExpressions {
16 internal sealed class CompiledRegexRunnerFactory : RegexRunnerFactory {
17 DynamicMethod goMethod;
18 DynamicMethod findFirstCharMethod;
19 DynamicMethod initTrackCountMethod;
21 internal CompiledRegexRunnerFactory (DynamicMethod go, DynamicMethod firstChar, DynamicMethod trackCount) {
23 this.findFirstCharMethod = firstChar;
24 this.initTrackCountMethod = trackCount;
25 //Debug.Assert(goMethod != null && findFirstCharMethod != null && initTrackCountMethod != null, "can't be null");
28 protected internal override RegexRunner CreateInstance() {
29 CompiledRegexRunner runner = new CompiledRegexRunner();
31 new ReflectionPermission(PermissionState.Unrestricted).Assert();
32 runner.SetDelegates((NoParamDelegate) goMethod.CreateDelegate(typeof(NoParamDelegate)),
33 (FindFirstCharDelegate) findFirstCharMethod.CreateDelegate(typeof(FindFirstCharDelegate)),
34 (NoParamDelegate) initTrackCountMethod.CreateDelegate(typeof(NoParamDelegate)));
40 internal delegate RegexRunner CreateInstanceDelegate();