Beispiel #1
0
            public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
            {
                TypeData typeData = null;

                switch (typeDeclaration.ClassType)
                {
                case ClassType.Enum:
                    typeData = new TypeData {
                        IsEnum       = true,
                        DeclaredType = new TypePair(
                            AstType.Create(typeDeclaration.Name),
                            typeDeclaration.BaseTypes.FirstOrDefault()
                            as PrimitiveType ?? new PrimitiveType("int")
                            )
                    };
                    break;

                case ClassType.Interface:
                    typeData = new TypeData {
                        DeclaredType = new TypePair(
                            AstType.Create(typeDeclaration.Name),
                            typeDeclaration.BaseTypes.FirstOrDefault()
                            )
                    };

                    foreach (var attr in GetTypeAttributes(typeDeclaration.Attributes))
                    {
                        typeData.AddBackingType(
                            attr.Backend,
                            new TypePair(attr.TypeName, attr.BaseTypeName)
                            );
                    }

                    typeData.IsReadOnlyList = typeDeclaration
                                              .Attributes
                                              .SelectMany(section => section.Attributes)
                                              .FirstOrDefault(attr =>
                                                              attr.Type.ToString() == "IReadOnlyList") != null;
                    break;
                }

                if (typeData != null)
                {
                    typeData.DomBinder = domBinder;
                    declaredTypes.Add(typeDeclaration.Name, typeData);
                }

                base.VisitTypeDeclaration(typeDeclaration);
            }