/// <summary> /// Write out the target link information /// </summary> /// <param name="target">The target for which to write link information</param> /// <param name="options">The link display options</param> /// <param name="writer">The write to which the information is written</param> public void WriteTarget(Target target, DisplayOptions options, XmlWriter writer) { if(target == null) throw new ArgumentNullException("target"); if(writer == null) throw new ArgumentNullException("writer"); NamespaceTarget space = target as NamespaceTarget; if(space != null) { WriteNamespaceTarget(space, writer); return; } TypeTarget type = target as TypeTarget; if(type != null) { WriteTypeTarget(type, options, writer); return; } MemberTarget member = target as MemberTarget; if(member != null) { WriteMemberTarget(member, options, writer); return; } if(target.Id.StartsWith("R:", StringComparison.OrdinalIgnoreCase)) { WriteInvalid(new InvalidReference(target.Id), writer); return; } throw new InvalidOperationException("Unknown target type"); }
/// <inheritdoc /> public override bool TryGetValue(string key, out Target value) { return index.TryGetValue(key, out value); }
//===================================================================== /// <inheritdoc /> /// <remarks>If the key already exists, the existing value is replaced</remarks> public override void Add(string key, Target value) { index[key] = value; }
// Target factory methods /// <summary> /// Create a target /// </summary> /// <param name="topic">The topic from which to get the target information</param> /// <returns>The target</returns> public static Target CreateTarget(XPathNavigator topic) { if(topic == null) throw new ArgumentNullException("topic"); bool isApiTarget = (bool)topic.Evaluate("boolean(apidata)"); Target target; if(isApiTarget) target = CreateApiTarget(topic); else target = new Target(); if(target == null) throw new XmlSchemaValidationException(String.Format(CultureInfo.InvariantCulture, "The target file '{0}' is not valid.", topic.BaseURI)); target.Id = (string)topic.Evaluate(topicIdExpression); if(String.IsNullOrEmpty(target.Id)) throw new XmlSchemaValidationException(String.Format(CultureInfo.InvariantCulture, "The target file '{0}' is not valid.", topic.BaseURI)); target.Container = (string)topic.Evaluate(topicContainerExpression); target.File = (string)topic.Evaluate(topicFileExpression); if(String.IsNullOrEmpty(target.File)) throw new XmlSchemaValidationException(String.Format(CultureInfo.InvariantCulture, "The target file '{0}' is not valid.", topic.BaseURI)); return target; }