Пример #1
0
 public void Reload()
 {
     if (m_OverriddenMethods == null)
     {
         m_OverriddenMethods = new OverriddenMethods(this);
     }
     m_TreeView.ReloadData();
 }
Пример #2
0
 public Method(Method method)
     : base(method)
 {
     Access               = method.Access;
     IsVirtual            = method.IsVirtual;
     IsConst              = method.IsConst;
     IsFinal              = method.IsFinal;
     IsProxy              = method.IsProxy;
     IsStatic             = method.IsStatic;
     Kind                 = method.Kind;
     IsDefaultConstructor = method.IsDefaultConstructor;
     IsCopyConstructor    = method.IsCopyConstructor;
     IsMoveConstructor    = method.IsMoveConstructor;
     Conversion           = method.Conversion;
     SynthKind            = method.SynthKind;
     AdjustedOffset       = method.AdjustedOffset;
     OverriddenMethods.AddRange(method.OverriddenMethods);
 }
Пример #3
0
        /// <summary>
        /// Adds a new method to the class, with the given name and method signature.
        /// </summary>
        /// <param name="name">The name of the method. name cannot contain embedded nulls. </param>
        /// <param name="methodInfoDeclaration">The method whose declaration is to be used.</param>
        /// <param name="attributes">The attributes of the method. </param>
        /// <returns>The defined method.</returns>
        public MethodBuilder DefineMethod(
            string name,
            MethodInfo methodInfoDeclaration,
            MethodAttributes attributes)
        {
            if (methodInfoDeclaration == null)
            {
                throw new ArgumentNullException("methodInfoDeclaration");
            }

            MethodBuilder method;

            ParameterInfo[] pi         = methodInfoDeclaration.GetParameters();
            Type[]          parameters = new Type[pi.Length];

            for (int i = 0; i < pi.Length; i++)
            {
                parameters[i] = pi[i].ParameterType;
            }

            if (methodInfoDeclaration.ContainsGenericParameters)
            {
                method = DefineGenericMethod(
                    name,
                    attributes,
                    methodInfoDeclaration.CallingConvention,
                    methodInfoDeclaration.GetGenericArguments(),
                    methodInfoDeclaration.ReturnType,
                    parameters);
            }
            else
            {
                method = DefineMethod(
                    name,
                    attributes,
                    methodInfoDeclaration.CallingConvention,
                    methodInfoDeclaration.ReturnType,
                    parameters);
            }

            // Compiler overrides methods only for interfaces. We do the same.
            // If we wanted to override virtual methods, then methods should've had
            // MethodAttributes.VtableLayoutMask attribute
            // and the following condition should've been used below:
            // if ((methodInfoDeclaration is FakeMethodInfo) == false)
            //
            if (methodInfoDeclaration.DeclaringType.IsInterface)
            {
                OverriddenMethods.Add(methodInfoDeclaration, new MethodBuilder(this, method.Builder));
                _typeBuilder.DefineMethodOverride(method.Builder, methodInfoDeclaration);
            }

            method.OverriddenMethod = methodInfoDeclaration;

            for (int i = 0; i < pi.Length; i++)
            {
                method.Builder.DefineParameter(i + 1, pi[i].Attributes, pi[i].Name);
            }

            return(method);
        }