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); }
internal NetTypeBrowserInfo(Type type, NetNamespaceBrowserInfo ns) { Debug.Assert(type != null && ns != null, "type != null && ns != null"); m_type = type; m_namespace = ns; }
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; }
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); }
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; }
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)); }
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); }
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); } }
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); }
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)); } }
internal override NetNamespaceBrowserInfo GetNullNamespace() { NetNamespaceBrowserInfo nullNs = Wrapped.GetNullNamespace(); return(nullNs == null ? null : new RemoteNamespaceBrowserInfo(nullNs, this, nullNs.DisplayName)); }
private void CreateWrappedObject() { m_wrapped = m_assembly.GetNamespace(m_name); Debug.Assert(m_wrapped != null, "m_wrapped != null"); }
public void Dispose() { m_namespace = null; }