CommonMarkSharp.CharSet.Create C# (CSharp) Method

Create() private static method

private static Create ( string chars ) : ContainsDeletage
chars string
return ContainsDeletage
        private static ContainsDeletage Create(string chars)
        {
            var dynam = new DynamicMethod(
                "Contains",
                typeof(bool),
                new[] { typeof(char) },
                typeof(CharSet)
            );

            var il = dynam.GetILGenerator();
            var foundLabel = il.DefineLabel();
            var notFoundLabel = il.DefineLabel();

            foreach (var range in GetRanges(chars))
            {
                il.Emit(OpCodes.Ldarg_0);
                il.Emit(OpCodes.Ldc_I4, range.Start);
                il.Emit(OpCodes.Blt, notFoundLabel);
                if (range.Length == 1)
                {
                    il.Emit(OpCodes.Ldarg_0);
                    il.Emit(OpCodes.Ldc_I4, range.Start);
                    il.Emit(OpCodes.Beq, foundLabel);
                }
                else
                {
                    il.Emit(OpCodes.Ldarg_0);
                    il.Emit(OpCodes.Ldc_I4, range.End);
                    il.Emit(OpCodes.Ble, foundLabel);
                }
            }

            il.MarkLabel(notFoundLabel);
            il.Emit(OpCodes.Ldc_I4_0);
            il.Emit(OpCodes.Ret);

            il.MarkLabel(foundLabel);
            il.Emit(OpCodes.Ldc_I4_1);
            il.Emit(OpCodes.Ret);

            return (ContainsDeletage)dynam.CreateDelegate(typeof(ContainsDeletage));
        }