コード例 #1
0
        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());
        }
コード例 #2
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());
        }
コード例 #3
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());
        }
コード例 #4
0
        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());
        }