Beispiel #1
0
        // Token: 0x06006287 RID: 25223 RVA: 0x0014E308 File Offset: 0x0014C508
        public Type Perform()
        {
            TypeBuilder typeBuilder = this.m_OutputModule.DefineType(this.m_strDestTypeName, TypeAttributes.Sealed, typeof(object), new Type[]
            {
                this.m_EventItfType,
                typeof(IDisposable)
            });
            FieldBuilder  fbCPC        = typeBuilder.DefineField("m_ConnectionPointContainer", typeof(IConnectionPointContainer), FieldAttributes.Private);
            FieldBuilder  fieldBuilder = typeBuilder.DefineField("m_aEventSinkHelpers", typeof(ArrayList), FieldAttributes.Private);
            FieldBuilder  fbEventCP    = typeBuilder.DefineField("m_ConnectionPoint", typeof(IConnectionPoint), FieldAttributes.Private);
            MethodBuilder mbInitSrcItf = this.DefineInitSrcItfMethod(typeBuilder, this.m_SrcItfType, fieldBuilder, fbEventCP, fbCPC);

            MethodInfo[] nonPropertyMethods = TCEAdapterGenerator.GetNonPropertyMethods(this.m_SrcItfType);
            for (int i = 0; i < nonPropertyMethods.Length; i++)
            {
                if (this.m_SrcItfType == nonPropertyMethods[i].DeclaringType)
                {
                    MethodBuilder methodBuilder  = this.DefineAddEventMethod(typeBuilder, nonPropertyMethods[i], this.m_SinkHelperType, fieldBuilder, fbEventCP, mbInitSrcItf);
                    MethodBuilder methodBuilder2 = this.DefineRemoveEventMethod(typeBuilder, nonPropertyMethods[i], this.m_SinkHelperType, fieldBuilder, fbEventCP);
                }
            }
            this.DefineConstructor(typeBuilder, fbCPC);
            MethodBuilder finalizeMethod = this.DefineFinalizeMethod(typeBuilder, this.m_SinkHelperType, fieldBuilder, fbEventCP);

            this.DefineDisposeMethod(typeBuilder, finalizeMethod);
            return(typeBuilder.CreateType());
        }
        public Type Perform()
        {
            Type[] aInterfaceTypes = new Type[] { this.m_InputType };
            string str             = null;
            string str2            = NameSpaceExtractor.ExtractNameSpace(this.m_EventItfType.FullName);

            if (str2 != "")
            {
                str = str2 + ".";
            }
            TypeBuilder tb = TCEAdapterGenerator.DefineUniqueType(str + this.m_InputType.Name + GeneratedTypeNamePostfix, TypeAttributes.Sealed | TypeAttributes.Public, null, aInterfaceTypes, this.m_OutputModule);

            TCEAdapterGenerator.SetHiddenAttribute(tb);
            TCEAdapterGenerator.SetClassInterfaceTypeToNone(tb);
            foreach (MethodInfo info in TCEAdapterGenerator.GetPropertyMethods(this.m_InputType))
            {
                this.DefineBlankMethod(tb, info);
            }
            MethodInfo[]   nonPropertyMethods = TCEAdapterGenerator.GetNonPropertyMethods(this.m_InputType);
            FieldBuilder[] afbDelegates       = new FieldBuilder[nonPropertyMethods.Length];
            for (int i = 0; i < nonPropertyMethods.Length; i++)
            {
                if (this.m_InputType == nonPropertyMethods[i].DeclaringType)
                {
                    Type parameterType = this.m_EventItfType.GetMethod("add_" + nonPropertyMethods[i].Name).GetParameters()[0].ParameterType;
                    afbDelegates[i] = tb.DefineField("m_" + nonPropertyMethods[i].Name + "Delegate", parameterType, FieldAttributes.Public);
                    this.DefineEventMethod(tb, nonPropertyMethods[i], parameterType, afbDelegates[i]);
                }
            }
            FieldBuilder fbCookie = tb.DefineField("m_dwCookie", typeof(int), FieldAttributes.Public);

            this.DefineConstructor(tb, fbCookie, afbDelegates);
            return(tb.CreateType());
        }
Beispiel #3
0
        // Token: 0x0600628F RID: 25231 RVA: 0x0014F4C8 File Offset: 0x0014D6C8
        public Type Perform()
        {
            Type[] aInterfaceTypes = new Type[]
            {
                this.m_InputType
            };
            string text  = null;
            string text2 = NameSpaceExtractor.ExtractNameSpace(this.m_EventItfType.FullName);

            if (text2 != "")
            {
                text = text2 + ".";
            }
            text = text + this.m_InputType.Name + EventSinkHelperWriter.GeneratedTypeNamePostfix;
            TypeBuilder typeBuilder = TCEAdapterGenerator.DefineUniqueType(text, TypeAttributes.Public | TypeAttributes.Sealed, null, aInterfaceTypes, this.m_OutputModule);

            TCEAdapterGenerator.SetHiddenAttribute(typeBuilder);
            TCEAdapterGenerator.SetClassInterfaceTypeToNone(typeBuilder);
            MethodInfo[] propertyMethods = TCEAdapterGenerator.GetPropertyMethods(this.m_InputType);
            foreach (MethodInfo method in propertyMethods)
            {
                this.DefineBlankMethod(typeBuilder, method);
            }
            MethodInfo[]   nonPropertyMethods = TCEAdapterGenerator.GetNonPropertyMethods(this.m_InputType);
            FieldBuilder[] array2             = new FieldBuilder[nonPropertyMethods.Length];
            for (int j = 0; j < nonPropertyMethods.Length; j++)
            {
                if (this.m_InputType == nonPropertyMethods[j].DeclaringType)
                {
                    MethodInfo      method2       = this.m_EventItfType.GetMethod("add_" + nonPropertyMethods[j].Name);
                    ParameterInfo[] parameters    = method2.GetParameters();
                    Type            parameterType = parameters[0].ParameterType;
                    array2[j] = typeBuilder.DefineField("m_" + nonPropertyMethods[j].Name + "Delegate", parameterType, FieldAttributes.Public);
                    this.DefineEventMethod(typeBuilder, nonPropertyMethods[j], parameterType, array2[j]);
                }
            }
            FieldBuilder fbCookie = typeBuilder.DefineField("m_dwCookie", typeof(int), FieldAttributes.Public);

            this.DefineConstructor(typeBuilder, fbCookie, array2);
            return(typeBuilder.CreateType());
        }
Beispiel #4
0
        public Type Perform()
        {
            Type[] aInterfaceTypes = new Type[1] {
                this.m_InputType
            };
            string str       = (string)null;
            string nameSpace = NameSpaceExtractor.ExtractNameSpace(this.m_EventItfType.FullName);

            if (nameSpace != "")
            {
                str = nameSpace + ".";
            }
            TypeBuilder typeBuilder = TCEAdapterGenerator.DefineUniqueType(str + this.m_InputType.Name + EventSinkHelperWriter.GeneratedTypeNamePostfix, TypeAttributes.Public | TypeAttributes.Sealed, (Type)null, aInterfaceTypes, this.m_OutputModule);

            TCEAdapterGenerator.SetHiddenAttribute(typeBuilder);
            TCEAdapterGenerator.SetClassInterfaceTypeToNone(typeBuilder);
            foreach (MethodInfo propertyMethod in TCEAdapterGenerator.GetPropertyMethods(this.m_InputType))
            {
                this.DefineBlankMethod(typeBuilder, propertyMethod);
            }
            MethodInfo[]   nonPropertyMethods = TCEAdapterGenerator.GetNonPropertyMethods(this.m_InputType);
            FieldBuilder[] afbDelegates       = new FieldBuilder[nonPropertyMethods.Length];
            for (int index = 0; index < nonPropertyMethods.Length; ++index)
            {
                if (this.m_InputType == nonPropertyMethods[index].DeclaringType)
                {
                    Type parameterType = this.m_EventItfType.GetMethod("add_" + nonPropertyMethods[index].Name).GetParameters()[0].ParameterType;
                    afbDelegates[index] = typeBuilder.DefineField("m_" + nonPropertyMethods[index].Name + "Delegate", parameterType, FieldAttributes.Public);
                    this.DefineEventMethod(typeBuilder, nonPropertyMethods[index], parameterType, afbDelegates[index]);
                }
            }
            FieldBuilder fbCookie = typeBuilder.DefineField("m_dwCookie", typeof(int), FieldAttributes.Public);

            this.DefineConstructor(typeBuilder, fbCookie, afbDelegates);
            return(typeBuilder.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());
        }
        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();
                    Contract.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());
        }