Exemple #1
0
        void CheckInitialization()
        {
            if (isInitialized)
            {
                return;
            }
            isInitialized = true;

            foreach (FieldDefinition fieldDefinition in typeDefinition.Fields)
            {
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(fieldDefinition)))
                {
                    continue;
                }
                base.Add(new DomCecilField(fieldDefinition));
            }
            foreach (MethodDefinition methodDefinition in typeDefinition.Methods)
            {
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(methodDefinition)))
                {
                    continue;
                }
                base.Add(new DomCecilMethod(methodDefinition));
            }

            bool internalOnly    = true;
            bool hasConstructors = false;

            foreach (MethodDefinition methodDefinition in typeDefinition.Constructors)
            {
                hasConstructors = true;
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(methodDefinition)))
                {
                    continue;
                }
                internalOnly = false;
                base.Add(new DomCecilMethod(methodDefinition));
            }
            if (hasConstructors && internalOnly)
            {
                base.TypeModifier |= TypeModifier.HasOnlyHiddenConstructors;
            }

            foreach (PropertyDefinition propertyDefinition in typeDefinition.Properties)
            {
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(propertyDefinition.Attributes)))
                {
                    continue;
                }
                base.Add(new DomCecilProperty(propertyDefinition));
            }
            foreach (EventDefinition eventDefinition in typeDefinition.Events)
            {
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(eventDefinition.Attributes)))
                {
                    continue;
                }
                base.Add(new DomCecilEvent(eventDefinition));
            }

            foreach (TypeDefinition nestedType in typeDefinition.NestedTypes)
            {
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(nestedType.Attributes)))
                {
                    continue;
                }
                DomCecilType innerType = new DomCecilType(nestedType, loadInternal);
                base.Add(innerType);
                if (typeParameters != null && innerType.typeParameters != null)
                {
                    innerType.typeParameters.RemoveAll(para => typeParameters.Any(myPara => myPara.Name == para.Name));
                }
            }
        }