示例#1
0
        public void Visit(ClassDiagramVisitorContext context)
        {
            this.MetaModel = context.GetTypeMetaModel(this.ReflectedType);

            LoadMembers(context);

            bool showInheritance = this.RenderInheritance && this.ReflectedType.BaseType != null;

            if (showInheritance)
            {
                var baseTypeMetaModel = context.GetTypeMetaModel(this.ReflectedType.BaseType);

                showInheritance = !baseTypeMetaModel.HideAsBaseClass && !baseTypeMetaModel.Hidden;
            }

            if (!this.MetaModel.Hidden)
            {
                foreach (ClassMemberDescriptor member in this.Members.InnerList)
                {
                    if (this.MetaModel.TreatAllMembersAsPrimitives)
                        member.TreatAsPrimitive = true;

                    TypeMetaModel metaModel = member.MetaModel;

                    if (!metaModel.Hidden && !member.TreatAsPrimitive)
                    {
                        // if not showing inheritance then show all members
                        // otherwise, only show member that aren't inherited
                        if (!showInheritance || !member.IsInherited)
                        {
                            if (metaModel.IsComplexType && this.GetMemberVisibility(member.Key))
                            {
                                var nextLevel = this.Level + 1;

                                if (member.MemberType.IsEnumerable())
                                {
                                    var enumeratorType = member.MemberType.GetEnumeratorType();
                                    var enumeratorTypeMetaModel = context.GetTypeMetaModel(enumeratorType);

                                    if (enumeratorTypeMetaModel.IsComplexType)
                                    {
                                        context.AddRelated(this, enumeratorType.GetReflected(), ClassDiagramRelationshipTypes.HasMany, nextLevel, member.Name);
                                    }
                                }
                                else
                                {
                                    context.AddRelated(this, member.MemberType.GetReflected(), ClassDiagramRelationshipTypes.HasA, nextLevel, member.Name);
                                }
                            }
                        }
                    }
                }
            }

            if (showInheritance)
            {
                context.AddRelated(this, this.ReflectedType.BaseType.GetReflected(), ClassDiagramRelationshipTypes.Base, this.Level - 1);
            }
        }
示例#2
0
 protected virtual void LoadMembers(ClassDiagramVisitorContext context)
 {
     switch (context.ScanMode)
     {
         case ClassDiagramScanModes.SystemServiceModelMember:
             _members.AddRange(this.ReflectedType.GetFields()
                                                 .Where(x => x.HasAttribute<DataMemberAttribute>() || x.HasAttribute<MessageBodyMemberAttribute>())
                                                 .Select(field => new ClassMemberDescriptor(this.ReflectedType, field, context.GetTypeMetaModel(field.FieldType)))
                              );
             _members.AddRange(this.ReflectedType.GetProperties()
                                                 .Where(x => x.HasAttribute<DataMemberAttribute>() || x.HasAttribute<MessageBodyMemberAttribute>())
                                                 .Select(property => new ClassMemberDescriptor(this.ReflectedType, property, context.GetTypeMetaModel(property.PropertyType)))
                              );
             break;
         default:
             _members.AddRange(this.ReflectedType.GetFields()
                                                 .Select(field => new ClassMemberDescriptor(this.ReflectedType, field, context.GetTypeMetaModel(field.FieldType)))
                              );
             _members.AddRange(this.ReflectedType.GetProperties()
                                                 .Select(property => new ClassMemberDescriptor(this.ReflectedType, property, context.GetTypeMetaModel(property.PropertyType)))
                              );
             break;
     }
 }
示例#3
0
        private bool ShouldShowInheritanceInterface(ClassDiagramVisitorContext context, Type type)
        {
            bool showInheritance = this.RenderInheritance && this.ReflectedType.BaseType != null;

            if (showInheritance)
            {
                var interfaceModel = context.GetTypeMetaModel(type);
                showInheritance |= !interfaceModel.HideAsBaseClass && !interfaceModel.Hidden;
            }
            return showInheritance;
        }