private string SelectHelpNamesapce( string managedName ) { string helpNamespace = String.Empty; ManagedName name = new ManagedName( managedName ); // since in most cases all managed names in a namespace will be in the // same help collection, let's fisrt try to short circuit the search by seeing // if there is a single managedNamespace entry that starts with the root of the name we are looking for string xpath = string.Format( "//map:managedNamespace[ starts-with( @ns,'{0}' ) ]", name.RootNamespace ); XmlNodeList firstTry = map.SelectNodes( xpath, nsmgr ); // if only one managedNamespace start with the root we can just return its help namespace if ( firstTry.Count == 1 ) { helpNamespace = GetNSFromManagedNameNode( firstTry.Item( 0 ) ); } else { // Since there is more than one managed name that starts with the root // being searched, we have to search for a more specific match. // We do this by starting with the most specified name and working backwards to the root // e.g. if we are looking for NS1.NS2.N3.NS4 we would start // with NS1.NS2.N3.NS4, then NS1.NS2.N3, then NS1.NS2 // // In this way managed namespace documentation can be spread across help namesapces string[] s = name.Parts; for ( int i = s.Length - 1; i >= 0; i-- ) { string ns = FindMatch( s[i] ); if ( ns.Length > 0 ) { helpNamespace = ns; break; } } } return helpNamespace; }
/// <summary> /// Determines the associative index for a cref /// </summary> /// <param name="cref">The cref to link to</param> /// <returns>The associative index</returns> public string GetAIndex(string cref) { // if it's not a type string return nothing if ((cref.Length <= 2) || (cref[1] != ':')) { Trace.WriteLine("[WARNING] MsdnXsltUtilities.GetAIndex : Malformed cref found(" + cref + ")"); return String.Empty; } string aindex = (string)aIndexCache[cref]; if (aindex != null && aindex.Length > 0) return aindex; ManagedName name = new ManagedName(cref); // if the cref is from the system or microsoft namespace generate a MS AIndex if (name.RootNamespace == "System" || name.RootNamespace == "Microsoft") aindex = GetSystemAIndex(cref); // otherwise we're going to assume that the foreign type was documented with NDoc // and generate an NDoc AIndex else aindex = GetNDocAIndex(cref); aIndexCache[cref] = aindex; return aindex; }