public GetType ( string name ) : |
||
name | string | |
Résultat |
public override TypeWrapper GetType(string name) { TypeWrapper wrapper; if (!this._typesByFullName.TryGetValue(name, out wrapper)) { if (_deferredTypesProvider != null) { return(_deferredTypesProvider.GetType(name)); } return(null); } return(wrapper); }
private static string DocBlobToHTML(XElement rootNode, AbstractTypeProvider typeProvider, FrameworkVersion version) { using (var textWriter = new StringWriter()) { var writerSettings = new XmlWriterSettings { OmitXmlDeclaration = true }; using (var writer = XmlWriter.Create(textWriter, writerSettings)) { var reader = rootNode.CreateReader(); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // handle self-closing element, like <a /> // this must be read before any other reading is done var selfClosingElement = reader.IsEmptyElement; // element name substitution, if necessary string elementName; if (!NdocToHtmlElementMapping.TryGetValue(reader.LocalName, out elementName)) { elementName = reader.LocalName; } // some elements can't be empty, use this variable for that string emptyElementContents = null; // start element writer.WriteStartElement(elementName); // copy over attributes if (reader.HasAttributes) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); var attributeName = reader.Name; var attributeValue = reader.Value; var isCref = string.Equals(attributeName, crefAttributeName, StringComparison.Ordinal); var isHref = string.Equals(attributeName, hrefAttributeName, StringComparison.Ordinal); var isName = string.Equals(attributeName, nameAttributeName, StringComparison.Ordinal); var writeAttribute = true; if (isCref) { // replace cref with href attributeName = hrefAttributeName; // extract type name from cref value for emptyElementContents var crefParts = attributeValue.Split(':'); if (crefParts.Length != 2) { throw new InvalidOperationException(); } var typeName = crefParts[1]; var targetType = typeProvider.GetType(typeName); if (targetType == null) { emptyElementContents = typeName; //If the type cannot be found do not render out the href attribute. //This will make it so things such as properties which we do not have //specific doc pages for do not render as a broken link but we can still //use the crefs in the code correctly. writeAttribute = false; } else { emptyElementContents = targetType.CreateReferenceHtml(fullTypeName: true); } } else if (isHref) { // extract href value for emptyElementContents emptyElementContents = attributeValue; } else if (isName) { emptyElementContents = attributeValue; } if (writeAttribute) { writer.WriteAttributeString(attributeName, attributeValue); } } } // if this is a self-closing element, close it if (selfClosingElement) { // write empty element contents, if any if (!string.IsNullOrEmpty(emptyElementContents)) { writer.WriteRaw(emptyElementContents); } // close element now writer.WriteEndElement(); } break; case XmlNodeType.EndElement: writer.WriteEndElement(); break; case XmlNodeType.Text: writer.WriteRaw(reader.Value); break; default: throw new InvalidOperationException(); } } } return(textWriter.ToString()); } }