CompiledRegexRunnerFactory.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Regex / System / Text / RegularExpressions / CompiledRegexRunnerFactory.cs / 1 / CompiledRegexRunnerFactory.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

using System.Reflection.Emit; 
using System.Diagnostics; 
using System.Security.Permissions;
 
namespace System.Text.RegularExpressions {


    internal sealed class CompiledRegexRunnerFactory : RegexRunnerFactory { 
        DynamicMethod goMethod;
        DynamicMethod findFirstCharMethod; 
        DynamicMethod initTrackCountMethod; 

        internal CompiledRegexRunnerFactory (DynamicMethod go, DynamicMethod firstChar, DynamicMethod trackCount) { 
            this.goMethod = go;
            this.findFirstCharMethod = firstChar;
            this.initTrackCountMethod = trackCount;
            //Debug.Assert(goMethod != null && findFirstCharMethod != null && initTrackCountMethod != null, "can't be null"); 
        }
 
        protected internal override RegexRunner CreateInstance() { 
            CompiledRegexRunner runner = new CompiledRegexRunner();
 
            new ReflectionPermission(PermissionState.Unrestricted).Assert();
            runner.SetDelegates((NoParamDelegate)       goMethod.CreateDelegate(typeof(NoParamDelegate)),
                                (FindFirstCharDelegate) findFirstCharMethod.CreateDelegate(typeof(FindFirstCharDelegate)),
                                (NoParamDelegate)       initTrackCountMethod.CreateDelegate(typeof(NoParamDelegate))); 

            return runner; 
        } 
    }
 
    internal delegate RegexRunner CreateInstanceDelegate();
}


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK