Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Runtime / InteropServices / TCEAdapterGen / TCEAdapterGenerator.cs / 1 / TCEAdapterGenerator.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== namespace System.Runtime.InteropServices.TCEAdapterGen { using System.Runtime.InteropServices; using System; using System.Reflection; using System.Reflection.Emit; using System.Collections; using System.Threading; internal class TCEAdapterGenerator { public void Process(ModuleBuilder ModBldr, ArrayList EventItfList) { // Store the input/output module. m_Module = ModBldr; // Generate the TCE adapters for all the event sources. int NumEvItfs = EventItfList.Count; for ( int cEventItfs = 0; cEventItfs < NumEvItfs; cEventItfs++ ) { // Retrieve the event interface info. EventItfInfo CurrEventItf = (EventItfInfo)EventItfList[cEventItfs]; // Retrieve the information from the event interface info. Type EventItfType = CurrEventItf.GetEventItfType(); Type SrcItfType = CurrEventItf.GetSrcItfType(); String EventProviderName = CurrEventItf.GetEventProviderName(); // Generate the sink interface helper. Type SinkHelperType = new EventSinkHelperWriter( m_Module, SrcItfType, EventItfType ).Perform(); // Generate the event provider. new EventProviderWriter( m_Module, EventProviderName, EventItfType, SrcItfType, SinkHelperType ).Perform(); } } internal static void SetClassInterfaceTypeToNone(TypeBuilder tb) { // Create the ClassInterface(ClassInterfaceType.None) CA builder if we haven't created it yet. if (s_NoClassItfCABuilder == null) { Type []aConsParams = new Type[1]; aConsParams[0] = typeof(ClassInterfaceType); ConstructorInfo Cons = typeof(ClassInterfaceAttribute).GetConstructor(aConsParams); Object[] aArgs = new Object[1]; aArgs[0] = ClassInterfaceType.None; s_NoClassItfCABuilder = new CustomAttributeBuilder(Cons, aArgs); } // Set the class interface type to none. tb.SetCustomAttribute(s_NoClassItfCABuilder); } internal static TypeBuilder DefineUniqueType(String strInitFullName, TypeAttributes attrs, Type BaseType, Type[] aInterfaceTypes, ModuleBuilder mb) { String strFullName = strInitFullName; int PostFix = 2; // Find the first unique name for the type. for (; mb.GetType(strFullName) != null; strFullName = strInitFullName + "_" + PostFix, PostFix++); // Define a type with the determined unique name. return mb.DefineType(strFullName, attrs, BaseType, aInterfaceTypes); } internal static void SetHiddenAttribute(TypeBuilder tb) { if (s_HiddenCABuilder == null) { // Hide the type from Object Browsers Type []aConsParams = new Type[1]; aConsParams[0] = typeof(TypeLibTypeFlags); ConstructorInfo Cons = typeof(TypeLibTypeAttribute).GetConstructor(aConsParams); Object []aArgs = new Object[1]; aArgs[0] = TypeLibTypeFlags.FHidden; s_HiddenCABuilder = new CustomAttributeBuilder(Cons, aArgs); } tb.SetCustomAttribute(s_HiddenCABuilder); } internal static MethodInfo[] GetNonPropertyMethods(Type type) { MethodInfo[] aMethods = type.GetMethods(); ArrayList methods = new ArrayList(aMethods); PropertyInfo[] props = type.GetProperties(); foreach(PropertyInfo prop in props) { MethodInfo[] accessors = prop.GetAccessors(); foreach (MethodInfo accessor in accessors) { for (int i=0; i < methods.Count; i++) { if ((MethodInfo)methods[i] == accessor) methods.RemoveAt(i); } } } MethodInfo[] retMethods = new MethodInfo[methods.Count]; methods.CopyTo(retMethods); return retMethods; } internal static MethodInfo[] GetPropertyMethods(Type type) { MethodInfo[] aMethods = type.GetMethods(); ArrayList methods = new ArrayList(); PropertyInfo[] props = type.GetProperties(); foreach(PropertyInfo prop in props) { MethodInfo[] accessors = prop.GetAccessors(); foreach (MethodInfo accessor in accessors) { methods.Add(accessor); } } MethodInfo[] retMethods = new MethodInfo[methods.Count]; methods.CopyTo(retMethods); return retMethods; } private ModuleBuilder m_Module = null; private Hashtable m_SrcItfToSrcItfInfoMap = new Hashtable(); private static CustomAttributeBuilder s_NoClassItfCABuilder = null; private static CustomAttributeBuilder s_HiddenCABuilder = null; } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PointConverter.cs
- ReceiveMessageAndVerifySecurityAsyncResultBase.cs
- Table.cs
- MgmtConfigurationRecord.cs
- AnnotationDocumentPaginator.cs
- ConnectionStringsExpressionBuilder.cs
- ConfigurationSchemaErrors.cs
- ExtensibleClassFactory.cs
- Rotation3DAnimation.cs
- XmlSerializableReader.cs
- ObjectHelper.cs
- CustomValidator.cs
- ImageBrush.cs
- AnnotationComponentManager.cs
- SynchronizedDispatch.cs
- ProxyElement.cs
- DBNull.cs
- RegexReplacement.cs
- GroupBox.cs
- HttpModuleAction.cs
- BidOverLoads.cs
- NavigationProperty.cs
- ReadOnlyDataSource.cs
- loginstatus.cs
- FormClosingEvent.cs
- ResourceCodeDomSerializer.cs
- Literal.cs
- EpmContentDeSerializerBase.cs
- MultipleViewProviderWrapper.cs
- SystemIcmpV6Statistics.cs
- AsymmetricSecurityProtocolFactory.cs
- PageRouteHandler.cs
- TextPenaltyModule.cs
- ImportContext.cs
- WindowsAltTab.cs
- CardSpaceException.cs
- AssociationSetEnd.cs
- MetadataPropertyvalue.cs
- CodeDomLocalizationProvider.cs
- SafeProcessHandle.cs
- ValuePatternIdentifiers.cs
- GenericAuthenticationEventArgs.cs
- FieldTemplateUserControl.cs
- CqlIdentifiers.cs
- DataGridCommandEventArgs.cs
- BasicHttpBindingCollectionElement.cs
- ProcessModuleCollection.cs
- SqlUnionizer.cs
- StreamUpdate.cs
- NoResizeHandleGlyph.cs
- CryptoStream.cs
- AuthorizationBehavior.cs
- OracleRowUpdatedEventArgs.cs
- FormViewPagerRow.cs
- InputLangChangeRequestEvent.cs
- CultureInfoConverter.cs
- ListenerAdapterBase.cs
- ResourceIDHelper.cs
- SmiRequestExecutor.cs
- XmlSchemaNotation.cs
- ProcessInfo.cs
- StatusStrip.cs
- PackageRelationshipCollection.cs
- ComboBoxAutomationPeer.cs
- ApplyTemplatesAction.cs
- RotateTransform.cs
- EntityDataSourceWrapperCollection.cs
- ProfilePropertySettingsCollection.cs
- QilGeneratorEnv.cs
- SemaphoreFullException.cs
- DelegateBodyWriter.cs
- Unit.cs
- PeerConnector.cs
- SmtpNegotiateAuthenticationModule.cs
- AutomationElementCollection.cs
- MessageQueue.cs
- TimeStampChecker.cs
- DocumentSequenceHighlightLayer.cs
- RayMeshGeometry3DHitTestResult.cs
- DesignerCapabilities.cs
- _ProxyChain.cs
- CodePageEncoding.cs
- ContextBase.cs
- DataListItemCollection.cs
- CodeTypeReferenceSerializer.cs
- SymmetricKey.cs
- WebBrowserDocumentCompletedEventHandler.cs
- Table.cs
- AutomationEvent.cs
- Size.cs
- XmlBaseReader.cs
- DATA_BLOB.cs
- IndentedTextWriter.cs
- PropertyPushdownHelper.cs
- EventItfInfo.cs
- OledbConnectionStringbuilder.cs
- XmlAutoDetectWriter.cs
- BindingMemberInfo.cs
- KeyValueSerializer.cs
- TransformedBitmap.cs