Esempio n. 1
0
        // Define a method override declaration for this class.
        public void DefineMethodOverride
            (MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration)
        {
            try
            {
                StartSync();

                // Validate the parameters.
                if (methodInfoBody == null)
                {
                    throw new ArgumentNullException("methodInfoBody");
                }
                if (methodInfoDeclaration == null)
                {
                    throw new ArgumentNullException
                              ("methodInfoDeclaration");
                }
                if (methodInfoBody.DeclaringType != this)
                {
                    throw new ArgumentException
                              (_("Emit_OverrideBodyNotInType"));
                }
                MethodToken bodyToken = module.GetMethodToken
                                            (methodInfoBody);
                MethodToken declToken = module.GetMethodToken
                                            (methodInfoDeclaration);
                lock (typeof(AssemblyBuilder))
                {
                    ClrTypeAddOverride
                        (module.privateData,
                        bodyToken.Token, declToken.Token);
                }
            }
            finally
            {
                EndSync();
            }
        }