Ejemplo n.º 1
0
        internal NetTypeBrowserInfo GetTypeInfo(Type type)
        {
            Debug.Assert(type != null, "type != null");

            NetTypeBrowserInfo typeInfo = (NetTypeBrowserInfo)m_cachedTypes[type];

            if (typeInfo == null)
            {
                NetAssemblyBrowserInfo assembly = GetAssemblyInfo(type.Assembly);
                Debug.Assert(assembly != null, "assembly != null");

                string nsName = (type.Namespace == null ? NetBrowserSettings.NullNamespaceName : type.Namespace);
                NetNamespaceBrowserInfo ns = assembly.GetNamespace(nsName);
                Debug.Assert(ns != null, "ns != null");

                // Retrieving the namespaces may add types to CachedTypes, so try to find this type again.

                typeInfo = (NetTypeBrowserInfo)m_cachedTypes[type];

                if (typeInfo == null)
                {
                    typeInfo = new NetTypeBrowserInfo(type, ns);
                    m_cachedTypes.Add(type, typeInfo);
                }
            }

            return(typeInfo);
        }
Ejemplo n.º 2
0
        internal NetTypeBrowserInfo(Type type, NetNamespaceBrowserInfo ns)
        {
            Debug.Assert(type != null && ns != null, "type != null && ns != null");

            m_type      = type;
            m_namespace = ns;
        }
Ejemplo n.º 3
0
        internal RemoteNamespaceBrowserInfo(NetNamespaceBrowserInfo wrapped, RemoteAssemblyBrowserInfo assembly, string name)
        {
            Debug.Assert(wrapped != null && assembly != null && name != null,
                         "wrapped != null && assembly != null && name != null");

            m_wrapped  = wrapped;
            m_assembly = assembly;
            m_name     = name;
        }
Ejemplo n.º 4
0
        internal DescriptionText GetDescription(NetNamespaceBrowserInfo ns, NetTypeBrowserInfo baseType)
        {
            if (m_description == null)
            {
                m_description = GetDescriptionInternal(ns, baseType);
                Debug.Assert(m_description != null, "m_description != null");
            }

            return(m_description);
        }
Ejemplo n.º 5
0
        private void GetNamespacesAndTypes()
        {
            SortedList namespaces = new SortedList();
            NetNamespaceBrowserInfo nullNamespace = null;

            foreach (Type type in m_assembly.GetTypes())
            {
                if (!Settings.TypeShouldBeVisible(type))
                {
                    continue;                     // The user has chosen not to see types with this visibility.
                }
                string nsName = type.Namespace;

                if (nsName == null)
                {
                    // Types with a null namespace appear directly under the repository, but to simplify
                    // implementation create a NetNamespaceBrowserInfo named NullNamespaceName for them.

                    if (type.FullName.StartsWith("<PrivateImplementationDetails>"))
                    {
                        continue;                         // Ignore <PrivateImplementationDetails>.
                    }
                    else
                    {
                        if (nullNamespace == null)
                        {
                            nullNamespace = new NetNamespaceBrowserInfo(this, NetBrowserSettings.NullNamespaceName);
                        }

                        nullNamespace.AddType(Manager.GetTypeInfo(type, nullNamespace));
                    }
                }
                else
                {
                    // A "normal" type - it has a namespace.

                    NetNamespaceBrowserInfo ns = (NetNamespaceBrowserInfo)namespaces[nsName];

                    if (ns == null)
                    {
                        ns = new NetNamespaceBrowserInfo(this, nsName);
                        namespaces.Add(nsName, ns);
                    }

                    ns.AddType(Manager.GetTypeInfo(type, ns));
                }
            }

            m_namespaces    = namespaces;
            m_nullNamespace = nullNamespace;
        }
Ejemplo n.º 6
0
        internal RemoteTypeBrowserInfo GetRemoteType(NetTypeBrowserInfo realType)
        {
            if (realType == null)
            {
                return(null);
            }

            NetNamespaceBrowserInfo realNs = realType.NamespaceInternal;

            RemoteAssemblyBrowserInfo  assembly = new RemoteAssemblyBrowserInfo(((NetAssemblyBrowserInfo)realNs.Repository).FilePath, this);
            RemoteNamespaceBrowserInfo ns       = new RemoteNamespaceBrowserInfo(realNs, assembly, realNs.DisplayName);

            return(new RemoteTypeBrowserInfo(realType, ns, realType.FullName));
        }
Ejemplo n.º 7
0
        internal NetTypeBrowserInfo GetTypeInfo(Type type, NetNamespaceBrowserInfo ns)
        {
            Debug.Assert(type != null && ns != null, "type != null && ns != null");

            NetTypeBrowserInfo typeInfo = (NetTypeBrowserInfo)m_cachedTypes[type];

            if (typeInfo == null)
            {
                typeInfo = new NetTypeBrowserInfo(type, ns);
                m_cachedTypes.Add(type, typeInfo);
            }

            return(typeInfo);
        }
Ejemplo n.º 8
0
        private DescriptionText GetDescriptionInternal(NetNamespaceBrowserInfo ns, NetTypeBrowserInfo baseType)
        {
            try
            {
                DescriptionBuilder sb = new DescriptionBuilder(true);

                sb.Append(Settings.GetKeyword(GetTypeAccess(m_type)));
                sb.Append(" ");

                AppendTypeAttribute(sb, m_type, TypeAttributes.Abstract);
                AppendTypeAttribute(sb, m_type, TypeAttributes.Sealed);

                sb.Append(Settings.GetKeyword(GetObjectType(m_type)));
                sb.Append(" ");

                sb.AppendName(GetTypeDisplayName(m_type));

                if (baseType != null)
                {
                    sb.Append(" : ");
                    sb.AppendLink(baseType.DisplayName, baseType);
                }

                if (m_type.IsEnum)
                {
                    Type underlying = Enum.GetUnderlyingType(m_type);
                    sb.Append(" (");
                    sb.AppendName(Settings.GetKeyword(underlying.AssemblyQualifiedName));
                    sb.Append(")");
                }

                IElementBrowserInfo container = (ns.IsNullNamespace ? ns.Repository : (IElementBrowserInfo)ns);

                sb.EndFirstLine();
                sb.Append(@"     Member of ");
                sb.AppendLink(container.NodeText, container);
                sb.EndLine();

                return(sb.GetText());
            }
            catch (System.Exception ex)
            {
                throw new ApplicationException("Failed to write the type declaration for type '"
                                               + m_type.FullName + "'.", ex);
            }
        }
Ejemplo n.º 9
0
        internal override SortedList GetNamespaces()
        {
            SortedList namespaces = Wrapped.GetNamespaces();

            SortedList remoteNamespaces = new SortedList(namespaces.Count);

            IDictionaryEnumerator enumerator = namespaces.GetEnumerator();

            enumerator.Reset();

            while (enumerator.MoveNext())
            {
                NetNamespaceBrowserInfo value = (NetNamespaceBrowserInfo)enumerator.Value;
                remoteNamespaces.Add(enumerator.Key, new RemoteNamespaceBrowserInfo(value, this, value.DisplayName));
            }

            return(remoteNamespaces);
        }
Ejemplo n.º 10
0
        public override bool Equals(object obj)
        {
            NetNamespaceBrowserInfo other = obj as NetNamespaceBrowserInfo;

            if (other == null)
            {
                return(false);
            }

            // The other object may be a RemoteNamespaceBrowserInfo or just a NetNamespaceBrowserInfo.

            RemoteNamespaceBrowserInfo otherRemote = other as RemoteNamespaceBrowserInfo;

            if (otherRemote == null)
            {
                return(object.Equals(Wrapped, other));
            }
            else
            {
                return(object.Equals(Wrapped, otherRemote.Wrapped));
            }
        }
Ejemplo n.º 11
0
        internal override NetNamespaceBrowserInfo GetNullNamespace()
        {
            NetNamespaceBrowserInfo nullNs = Wrapped.GetNullNamespace();

            return(nullNs == null ? null : new RemoteNamespaceBrowserInfo(nullNs, this, nullNs.DisplayName));
        }
Ejemplo n.º 12
0
 private void CreateWrappedObject()
 {
     m_wrapped = m_assembly.GetNamespace(m_name);
     Debug.Assert(m_wrapped != null, "m_wrapped != null");
 }
Ejemplo n.º 13
0
 public void Dispose()
 {
     m_namespace = null;
 }