예제 #1
0
        private void ProcessCodeClass(CodeClass codeClass, IdeBindingSourceProcessor bindingSourceProcessor)
        {
            var filteredAttributes = codeClass.Attributes.Cast <CodeAttribute2>().Where(attr => bindingSourceProcessor.CanProcessTypeAttribute(attr.FullName)).ToArray();

            if (!bindingSourceProcessor.PreFilterType(filteredAttributes.Select(attr => attr.FullName)))
            {
                return;
            }

            var bindingSourceType = bindingReflectionFactory.CreateBindingSourceType(codeClass, filteredAttributes);

            if (!bindingSourceProcessor.ProcessType(bindingSourceType))
            {
                return;
            }

            foreach (var codeFunction in codeClass.Children.OfType <CodeFunction>())
            {
                var bindingSourceMethod = CreateBindingSourceMethod(codeFunction, bindingSourceType, bindingSourceProcessor);
                if (bindingSourceMethod != null)
                {
                    bindingSourceProcessor.ProcessMethod(bindingSourceMethod);
                }
            }

            bindingSourceProcessor.ProcessTypeDone();
        }
        private void ProcessCodeClass(CodeClass codeClass, IdeBindingSourceProcessor bindingSourceProcessor, params CodeClass[] classParts)
        {
            var filteredAttributes = classParts
                                     .SelectMany(cc => cc.Attributes.Cast <CodeAttribute2>().Where(attr => CanProcessTypeAttribute(bindingSourceProcessor, attr))).ToArray();

            if (!bindingSourceProcessor.PreFilterType(filteredAttributes.Select(attr => attr.FullName)))
            {
                return;
            }


            var bindingSourceType = bindingReflectionFactory.CreateBindingSourceType(classParts, filteredAttributes); //TODO: merge info from parts

            if (!bindingSourceProcessor.ProcessType(bindingSourceType))
            {
                return;
            }

            ProcessCodeFunctions(codeClass, bindingSourceType, bindingSourceProcessor);

            bindingSourceProcessor.ProcessTypeDone();
            // process base classes
            foreach (var part in classParts.Where(cp => cp != codeClass))
            {
                var bindingSourceType2 = bindingReflectionFactory.CreateBindingSourceType(new[] { part }, filteredAttributes);

                if (!bindingSourceProcessor.ProcessType(bindingSourceType2))
                {
                    return;
                }

                ProcessCodeFunctions(part, bindingSourceType2, bindingSourceProcessor);

                bindingSourceProcessor.ProcessTypeDone();
            }
        }