Пример #1
0
        private void FinishType(TypeBuilder typeBuilder, Cci.ITypeDefinition typeDef)
        {
            // implemented interfaces
            foreach (var iface in typeDef.Interfaces(_context))
            {
                // an implemented interface must be loaded before the type that implements it:
                typeBuilder.AddInterfaceImplementation(ResolveType(iface, dependentType: typeBuilder, valueTypeDependency: false));
            }

            // method implementations
            foreach (Cci.MethodImplementation impl in typeDef.GetExplicitImplementationOverrides(_context))
            {
                typeBuilder.DefineMethodOverride(ResolveMethod(impl.ImplementingMethod), ResolveMethod(impl.ImplementedMethod));
            }

            // properties (don't need to be defined prior custom attributes - we don't use CustomAttributeBuilders):
            foreach (Cci.IPropertyDefinition propertyDef in typeDef.GetProperties(_context))
            {
                EmitCustomAttributes(DefineProperty(typeBuilder, propertyDef), propertyDef.GetAttributes(_context));
            }

            // events
            foreach (Cci.IEventDefinition eventDef in typeDef.Events)
            {
                EmitCustomAttributes(DefineEvent(typeBuilder, eventDef), eventDef.GetAttributes(_context));
            }

            // custom attributes
            EmitCustomAttributes(typeBuilder, typeDef.GetAttributes(_context));

            // TODO:
            // decl security
        }