Beispiel #1
0
        public override IMember Clone()
        {
            DefaultField field = new DefaultField(ReturnType, Name, Modifiers, Region, DeclaringType);

            field.CopyDocumentationFrom(this);
            return(field);
        }
Beispiel #2
0
            IField ReadField()
            {
                DefaultField p = new DefaultField(currentClass, ReadString());

                ReadMember(p);
                return(p);
            }
Beispiel #3
0
            void InitMembers(TypeDefinition type)
            {
                string defaultMemberName = null;

                foreach (CustomAttribute att in type.CustomAttributes)
                {
                    if (att.Constructor.DeclaringType.FullName == "System.Reflection.DefaultMemberAttribute" &&
                        att.ConstructorArguments.Count == 1)
                    {
                        defaultMemberName = att.ConstructorArguments[0].Value as string;
                    }
                }

                foreach (TypeDefinition nestedType in type.NestedTypes)
                {
                    TypeAttributes visibility = nestedType.Attributes & TypeAttributes.VisibilityMask;
                    if (visibility == TypeAttributes.NestedPublic || visibility == TypeAttributes.NestedFamily ||
                        visibility == TypeAttributes.NestedFamORAssem)
                    {
                        string name = nestedType.Name;
                        int    pos  = name.LastIndexOf('/');
                        if (pos > 0)
                        {
                            name = name.Substring(pos + 1);
                        }
                        if (name.Length == 0 || name[0] == '<')
                        {
                            continue;
                        }
                        name = ReflectionClass.SplitTypeParameterCountFromReflectionName(name);
                        name = this.FullyQualifiedName + "." + name;
                        InnerClasses.Add(new CecilClass(this.CompilationUnit, this, nestedType, name));
                    }
                }

                foreach (FieldDefinition field in type.Fields)
                {
                    if (IsVisible(field.Attributes) && !field.IsSpecialName)
                    {
                        DefaultField f = new DefaultField(this, field.Name);
                        f.Modifiers  = TranslateModifiers(field);
                        f.ReturnType = CreateType(this.ProjectContent, this, field.FieldType, field);
                        AddAttributes(CompilationUnit.ProjectContent, f, f.Attributes, field);
                        Fields.Add(f);
                    }
                }

                foreach (PropertyDefinition property in type.Properties)
                {
                    AddProperty(defaultMemberName, property);
                }

                foreach (EventDefinition eventDef in type.Events)
                {
                    if (eventDef.AddMethod != null && IsVisible(eventDef.AddMethod.Attributes))
                    {
                        DefaultEvent e = new DefaultEvent(this, eventDef.Name);
                        if (this.ClassType == ClassType.Interface)
                        {
                            e.Modifiers = ModifierEnum.Public | ModifierEnum.Abstract;
                        }
                        else
                        {
                            e.Modifiers = TranslateModifiers(eventDef);
                        }
                        e.ReturnType = CreateType(this.ProjectContent, this, eventDef.EventType, eventDef);
                        AddAttributes(CompilationUnit.ProjectContent, e, e.Attributes, eventDef);
                        Events.Add(e);
                    }
                }

                this.AddDefaultConstructorIfRequired = (this.ClassType == ClassType.Struct || this.ClassType == ClassType.Enum);
                foreach (MethodDefinition method in type.Methods)
                {
                    if (method.IsConstructor || !method.IsSpecialName)
                    {
                        AddMethod(method);
                    }
                }
            }