public Type Perform()
        {
            // Create the output Type.
            Type[] aInterfaces = new Type[1];
            aInterfaces[0] = m_InputType;
            String strFullName  = null;
            String strNameSpace = NameSpaceExtractor.ExtractNameSpace(m_EventItfType.FullName);

            if (strNameSpace != "")
            {
                strFullName = strNameSpace + ".";
            }

            strFullName += m_InputType.Name + GeneratedTypeNamePostfix;
            TypeBuilder OutputTypeBuilder = TCEAdapterGenerator.DefineUniqueType(
                strFullName,
                TypeAttributes.Sealed | TypeAttributes.Public,
                null,
                aInterfaces,
                m_OutputModule
                );

            // Hide the _SinkProvider interface
            TCEAdapterGenerator.SetHiddenAttribute(OutputTypeBuilder);

            // Set the class interface to none.
            TCEAdapterGenerator.SetClassInterfaceTypeToNone(OutputTypeBuilder);

            // Retrieve the property methods on the input interface and give them a dummy implementation.
            MethodInfo[] pMethods = TCEAdapterGenerator.GetPropertyMethods(m_InputType);
            foreach (MethodInfo method in pMethods)
            {
                DefineBlankMethod(OutputTypeBuilder, method);
            }

            // Retrieve the non-property methods on the input interface.
            MethodInfo[] aMethods = TCEAdapterGenerator.GetNonPropertyMethods(m_InputType);

            // Allocate an array to contain the delegate fields.
            FieldBuilder[] afbDelegates = new FieldBuilder[aMethods.Length];
            // Process all the methods on the input interface.
            for (int cMethods = 0; cMethods < aMethods.Length; cMethods++)
            {
                if (m_InputType == aMethods[cMethods].DeclaringType)
                {
                    // Retrieve the delegate type from the add_XXX method.
                    MethodInfo      AddMeth = m_EventItfType.GetMethod("add_" + aMethods[cMethods].Name);
                    ParameterInfo[] aParams = AddMeth.GetParameters();
                    Debug.Assert(aParams.Length == 1, "All event interface methods must take a single delegate derived type and have a void return type");
                    Type DelegateCls = aParams[0].ParameterType;

                    // Define the delegate instance field.
                    afbDelegates[cMethods] = OutputTypeBuilder.DefineField(
                        "m_" + aMethods[cMethods].Name + "Delegate",
                        DelegateCls,
                        FieldAttributes.Public
                        );

                    // Define the event method itself.
                    DefineEventMethod(OutputTypeBuilder, aMethods[cMethods], DelegateCls, afbDelegates[cMethods]);
                }
            }

            // Create the cookie field.
            FieldBuilder fbCookie = OutputTypeBuilder.DefineField(
                "m_dwCookie",
                typeof(Int32),
                FieldAttributes.Public
                );

            // Define the constructor.
            DefineConstructor(OutputTypeBuilder, fbCookie, afbDelegates);

            return(OutputTypeBuilder.CreateType());
        }
        public Type Perform()
        {
            // Create the event provider class.
            TypeBuilder OutputTypeBuilder = m_OutputModule.DefineType(
                m_strDestTypeName,
                TypeAttributes.Sealed | TypeAttributes.NotPublic,
                typeof(Object),
                new Type[] { m_EventItfType, typeof(IDisposable) }
                );

            // Create the event source field.
            FieldBuilder fbCPC = OutputTypeBuilder.DefineField(
                "m_ConnectionPointContainer",
                typeof(IConnectionPointContainer),
                FieldAttributes.Private
                );

            // Create array of event sink helpers.
            FieldBuilder fbSinkHelper = OutputTypeBuilder.DefineField(
                "m_aEventSinkHelpers",
                typeof(ArrayList),
                FieldAttributes.Private
                );

            // Define the connection point field.
            FieldBuilder fbEventCP = OutputTypeBuilder.DefineField(
                "m_ConnectionPoint",
                typeof(IConnectionPoint),
                FieldAttributes.Private
                );

            // Define the InitXXX method.
            MethodBuilder InitSrcItfMethodBuilder =
                DefineInitSrcItfMethod(OutputTypeBuilder, m_SrcItfType, fbSinkHelper, fbEventCP, fbCPC);

            // Process all the methods in the event interface.
            MethodInfo[] aMethods = TCEAdapterGenerator.GetNonPropertyMethods(m_SrcItfType);
            for (int cMethods = 0; cMethods < aMethods.Length; cMethods++)
            {
                if (m_SrcItfType == aMethods[cMethods].DeclaringType)
                {
                    // Define the add_XXX method.
                    MethodBuilder AddEventMethodBuilder = DefineAddEventMethod(
                        OutputTypeBuilder, aMethods[cMethods], m_SinkHelperType, fbSinkHelper, fbEventCP, InitSrcItfMethodBuilder);

                    // Define the remove_XXX method.
                    MethodBuilder RemoveEventMethodBuilder = DefineRemoveEventMethod(
                        OutputTypeBuilder, aMethods[cMethods], m_SinkHelperType, fbSinkHelper, fbEventCP);
                }
            }

            // Define the constructor.
            DefineConstructor(OutputTypeBuilder, fbCPC);

            // Define the finalize method.
            MethodBuilder FinalizeMethod = DefineFinalizeMethod(OutputTypeBuilder, m_SinkHelperType, fbSinkHelper, fbEventCP);

            // Define the Dispose method.
            DefineDisposeMethod(OutputTypeBuilder, FinalizeMethod);

            return(OutputTypeBuilder.CreateType());
        }