Arg() public method

ThisOffset is applied inside
public Arg ( int parameterIndex ) : ContextualOperand
parameterIndex int
return ContextualOperand
Exemplo n.º 1
0
        public EventGen WithStandardImplementation()
        {
            if ((object)handler == null)
            {
                if (IsStatic)
                {
                    handler = owner.Private.Static.Field(type, name);
                }
                else
                {
                    handler = owner.Private.Field(type, name);
                }

                CodeGen g = AddMethod();
                g.AssignAdd(handler, g.Arg("handler"));
                adder.GetMethodBuilder().SetImplementationFlags(MethodImplAttributes.IL | MethodImplAttributes.Managed | MethodImplAttributes.Synchronized);

                g = RemoveMethod();
                g.AssignSubtract(handler, g.Arg("handler"));
                remover.GetMethodBuilder().SetImplementationFlags(MethodImplAttributes.IL | MethodImplAttributes.Managed | MethodImplAttributes.Synchronized);
            }
            ;

            return(this);
        }
Exemplo n.º 2
0
        static void DynamicMethodExamples()
        {
            DynamicMethodGen dmg = DynamicMethodGen.Static <Program>().Void().Parameter <string>("name");
            CodeGen          g   = dmg.GetCode();

            g.Try();
            {
                Operand name = g.Local <string>(g.Arg("name"));
                g.WriteLine("Hello {0}!", name);
            }
            g.CatchAll();
            {
                g.WriteLine("Error");
            }
            g.End();

            DynamicMethod dm = dmg.GetCompletedDynamicMethod(true);

            // reflection-style invocation
            dm.Invoke(null, new object[] { "Dynamic Method" });

            // delegate invocation
            var hello = dm.CreateDelegate <Action <string> >();

            hello("Delegate");
        }
Exemplo n.º 3
0
        static void DynamicMethodExamples()
        {
            DynamicMethodGen dmg = DynamicMethodGen.Static(typeof(Program)).Method(typeof(void)).Parameter(typeof(string), "name");
            CodeGen          g   = dmg.GetCode();

            g.Try();
            {
                Operand name = g.Local(typeof(string), g.Arg("name"));
                g.WriteLine("Hello {0}!", name);
            }
            g.CatchAll();
            {
                g.WriteLine("Error");
            }
            g.End();

            DynamicMethod dm = dmg.GetCompletedDynamicMethod(true);

            // reflection-style invocation
            dm.Invoke(null, new object[] { "Dynamic Method" });

            // delegate invocation
            Action <string> hello = (Action <string>)dm.CreateDelegate(typeof(Action <string>));

            hello("Delegate");
        }