Esempio n. 1
0
        public TargetClassDefinition Build(ClassContext classContext)
        {
            ArgumentUtility.CheckNotNull("classContext", classContext);

            if (classContext.Type.ContainsGenericParameters)
            {
                string message = string.Format("The base class {0} contains generic parameters. This is not supported.", classContext.Type.FullName);
                throw new ConfigurationException(message);
            }

            var classDefinition = new TargetClassDefinition(classContext);

            var membersBuilder = new MemberDefinitionBuilder(classDefinition, ReflectionUtility.IsPublicOrProtectedOrExplicit);

            membersBuilder.Apply(classDefinition.Type);

            var attributesBuilder = new AttributeDefinitionBuilder(classDefinition);

            attributesBuilder.Apply(classDefinition.Type);

            ApplyComposedInterfaces(classDefinition, classContext);
            ApplyMixins(classDefinition, classContext);
            ApplyMethodRequirements(classDefinition);

            AnalyzeOverrides(classDefinition);
            AnalyzeAttributeIntroductions(classDefinition);
            AnalyzeMemberAttributeIntroductions(classDefinition);
            return(classDefinition);
        }
 private void AnalyzeMethods(IEnumerable <MethodInfo> methods)
 {
     foreach (MethodInfo method in methods)
     {
         if (!_specialMethods.Contains(method) && _methodFilter(method))
         {
             var definition       = new MethodDefinition(method, _classDefinition);
             var attributeBuilder = new AttributeDefinitionBuilder(definition);
             attributeBuilder.Apply(method);
             _classDefinition.Methods.Add(definition);
         }
     }
 }
 private MethodDefinition CreateSpecialMethodDefinition(MethodInfo methodInfo)
 {
     if (methodInfo != null && _methodFilter(methodInfo))
     {
         var methodDefinition = new MethodDefinition(methodInfo, _classDefinition);
         var attributeBuilder = new AttributeDefinitionBuilder(methodDefinition);
         attributeBuilder.Apply(methodInfo);
         _specialMethods.Add(methodInfo);
         return(methodDefinition);
     }
     else
     {
         return(null);
     }
 }
        private void AnalyzeEvents(IEnumerable <EventInfo> events)
        {
            foreach (EventInfo eventInfo in events)
            {
                MethodInfo addMethod    = eventInfo.GetAddMethod(true);
                MethodInfo removeMethod = eventInfo.GetRemoveMethod(true);

                MethodDefinition addMethodDefinition    = CreateSpecialMethodDefinition(addMethod);
                MethodDefinition removeMethodDefinition = CreateSpecialMethodDefinition(removeMethod);

                if (addMethodDefinition != null || removeMethodDefinition != null)
                {
                    var definition       = new EventDefinition(eventInfo, _classDefinition, addMethodDefinition, removeMethodDefinition);
                    var attributeBuilder = new AttributeDefinitionBuilder(definition);
                    attributeBuilder.Apply(eventInfo);
                    _classDefinition.Events.Add(definition);
                }
            }
        }
        private void AnalyzeProperties(IEnumerable <PropertyInfo> properties)
        {
            foreach (PropertyInfo property in properties)
            {
                MethodInfo getMethod = property.GetGetMethod(true);
                MethodInfo setMethod = property.GetSetMethod(true);

                MethodDefinition getMethodDefinition = CreateSpecialMethodDefinition(getMethod);
                MethodDefinition setMethodDefinition = CreateSpecialMethodDefinition(setMethod);

                if (getMethodDefinition != null || setMethodDefinition != null)
                {
                    var definition       = new PropertyDefinition(property, _classDefinition, getMethodDefinition, setMethodDefinition);
                    var attributeBuilder = new AttributeDefinitionBuilder(definition);
                    attributeBuilder.Apply(property);
                    _classDefinition.Properties.Add(definition);
                }
            }
        }
Esempio n. 6
0
        private void AnalyzeAttributes(MixinDefinition mixin)
        {
            var attributesBuilder = new AttributeDefinitionBuilder(mixin);

            attributesBuilder.Apply(mixin.Type);
        }