Exemplo n.º 1
0
            private IProperty ReadProperty()
            {
                DefaultProperty p = new DefaultProperty(_currentClass, ReadString());

                ReadMember(p);
                p.accessFlags = _reader.ReadByte();
                ReadParameters(p);
                return(p);
            }
Exemplo n.º 2
0
        public override IMember Clone()
        {
            DefaultProperty p = new DefaultProperty(Name, ReturnType, Modifiers, Region, BodyRegion, DeclaringType);

            p._parameters = DefaultParameter.Clone(this.Parameters);
            p.accessFlags = this.accessFlags;
            foreach (ExplicitInterfaceImplementation eii in InterfaceImplementations)
            {
                p.InterfaceImplementations.Add(eii.Clone());
            }
            return(p);
        }
Exemplo n.º 3
0
            private void ReadParameters(DefaultProperty m)
            {
                int count = _reader.ReadUInt16();

                if (count > 0)
                {
                    ReadParameters(m.Parameters, count);
                }
                else
                {
                    m.Parameters = DefaultParameter.EmptyParameterList;
                }
            }
Exemplo n.º 4
0
            private void WriteProperty(IProperty p)
            {
                WriteMember(p);
                DefaultProperty dp = p as DefaultProperty;

                if (dp != null)
                {
                    _writer.Write(dp.accessFlags);
                }
                else
                {
                    _writer.Write((byte)0);
                }
                WriteParameters(p.Parameters);
            }
Exemplo n.º 5
0
            void InitMembers(TypeDefinition type)
            {
                string defaultMemberName = null;

                foreach (CustomAttribute att in type.CustomAttributes)
                {
                    if (att.Constructor.DeclaringType.FullName == "System.Reflection.DefaultMemberAttribute" &&
                        att.ConstructorParameters.Count == 1)
                    {
                        defaultMemberName = att.ConstructorParameters[0] 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;
                        }
                        if (name.Length > 2 && name[name.Length - 2] == '`')
                        {
                            name = name.Substring(0, name.Length - 2);
                        }
                        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);
                        AddAttributes(CompilationUnit.ProjectContent, f.Attributes, field.CustomAttributes);
                        Fields.Add(f);
                    }
                }

                foreach (PropertyDefinition property in type.Properties)
                {
                    if ((property.GetMethod != null && IsVisible(property.GetMethod.Attributes)) ||
                        (property.SetMethod != null && IsVisible(property.SetMethod.Attributes)))
                    {
                        DefaultProperty p = new DefaultProperty(this, property.Name);
                        if (this.ClassType == ClassType.Interface)
                        {
                            p.Modifiers = ModifierEnum.Public | ModifierEnum.Abstract;
                        }
                        else
                        {
                            p.Modifiers = TranslateModifiers(property);
                        }
                        p.ReturnType = CreateType(this.ProjectContent, this, property.PropertyType);
                        p.CanGet     = property.GetMethod != null;
                        p.CanSet     = property.SetMethod != null;
                        if (p.Name == defaultMemberName)
                        {
                            p.IsIndexer = true;
                        }
                        AddParameters(p, property.Parameters);
                        AddAttributes(CompilationUnit.ProjectContent, p.Attributes, property.CustomAttributes);
                        Properties.Add(p);
                    }
                }

                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);
                        AddAttributes(CompilationUnit.ProjectContent, e.Attributes, eventDef.CustomAttributes);
                        Events.Add(e);
                    }
                }

                foreach (MethodDefinition method in type.Constructors)
                {
                    AddMethod(method);
                }
                foreach (MethodDefinition method in type.Methods)
                {
                    if (!method.IsSpecialName)
                    {
                        AddMethod(method);
                    }
                }
            }