public TypeViewModel(TypeDeclaration type, AD.ProjectType projectType, ViewModel parent)
            : base(parent)
        {
            _type        = type;
            _projectType = projectType;
            _typeKind    = ProjectUtils.GetTypeKind(type);

            Caption = NodePrinter.Print(type, true, true);
            Image   = ProjectUtils.GetTypeImage(type, _typeKind);
        }
示例#2
0
        internal static FieldNodeKind GetFieldKind(FieldDeclaration field, TypeDeclaration type, TypeNodeKind typeKind)
        {
            switch (typeKind)
            {
            case TypeNodeKind.Enum:
            {
                if (SignatureComparer.IgnoreTypeOwner_IgnoreAssemblyStrongName.Equals(field.FieldType, type))
                {
                    return(FieldNodeKind.EnumItem);
                }
                else
                {
                    return(FieldNodeKind.Field);
                }
            }

            default:
            {
                return(FieldNodeKind.Field);
            }
            }
        }
示例#3
0
        internal static ImageType GetTypeImage(TypeDeclaration type, TypeNodeKind typeKind)
        {
            switch (typeKind)
            {
            case TypeNodeKind.Class:
                switch (type.Visibility)
                {
                case TypeVisibilityFlags.Private:
                case TypeVisibilityFlags.NestedAssembly:
                    return(ImageType.Node_Class_Sealed);

                case TypeVisibilityFlags.NestedPrivate:
                    return(ImageType.Node_Class_Private);

                case TypeVisibilityFlags.NestedFamily:
                case TypeVisibilityFlags.NestedFamOrAssem:
                case TypeVisibilityFlags.NestedFamAndAssem:
                    return(ImageType.Node_Class_Protected);

                default:
                    return(ImageType.Node_Class);
                }

            case TypeNodeKind.Delegate:
                switch (type.Visibility)
                {
                case TypeVisibilityFlags.Private:
                case TypeVisibilityFlags.NestedAssembly:
                    return(ImageType.Node_Delegate_Sealed);

                case TypeVisibilityFlags.NestedPrivate:
                    return(ImageType.Node_Delegate_Private);

                case TypeVisibilityFlags.NestedFamily:
                case TypeVisibilityFlags.NestedFamOrAssem:
                case TypeVisibilityFlags.NestedFamAndAssem:
                    return(ImageType.Node_Delegate_Protected);

                default:
                    return(ImageType.Node_Delegate);
                }

            case TypeNodeKind.Enum:
                switch (type.Visibility)
                {
                case TypeVisibilityFlags.Private:
                case TypeVisibilityFlags.NestedAssembly:
                    return(ImageType.Node_Enum_Sealed);

                case TypeVisibilityFlags.NestedPrivate:
                    return(ImageType.Node_Enum_Private);

                case TypeVisibilityFlags.NestedFamily:
                case TypeVisibilityFlags.NestedFamOrAssem:
                case TypeVisibilityFlags.NestedFamAndAssem:
                    return(ImageType.Node_Enum_Protected);

                default:
                    return(ImageType.Node_Enum);
                }

            case TypeNodeKind.Interface:
                switch (type.Visibility)
                {
                case TypeVisibilityFlags.Private:
                case TypeVisibilityFlags.NestedAssembly:
                    return(ImageType.Node_Interface_Sealed);

                case TypeVisibilityFlags.NestedPrivate:
                    return(ImageType.Node_Interface_Private);

                case TypeVisibilityFlags.NestedFamily:
                case TypeVisibilityFlags.NestedFamOrAssem:
                case TypeVisibilityFlags.NestedFamAndAssem:
                    return(ImageType.Node_Interface_Protected);

                default:
                    return(ImageType.Node_Interface);
                }

            case TypeNodeKind.ValueType:
                switch (type.Visibility)
                {
                case TypeVisibilityFlags.Private:
                case TypeVisibilityFlags.NestedAssembly:
                    return(ImageType.Node_ValueType_Sealed);

                case TypeVisibilityFlags.NestedPrivate:
                    return(ImageType.Node_ValueType_Private);

                case TypeVisibilityFlags.NestedFamily:
                case TypeVisibilityFlags.NestedFamOrAssem:
                case TypeVisibilityFlags.NestedFamAndAssem:
                    return(ImageType.Node_ValueType_Protected);

                default:
                    return(ImageType.Node_ValueType);
                }

            default:
                throw new NotImplementedException();
            }
        }