1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
3
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
// software and associated documentation files (the "Software"), to deal in the Software
5
// without restriction, including without limitation the rights to use, copy, modify, merge,
6
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7
// to whom the Software is furnished to do so, subject to the following conditions:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
12
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
// DEALINGS IN THE SOFTWARE.
20
using ICSharpCode.NRefactory.Editor;
21
using ICSharpCode.NRefactory.TypeSystem;
23
namespace ICSharpCode.NRefactory.Documentation
26
/// Represents a documentation comment.
28
public class DocumentationComment
31
protected readonly ITypeResolveContext context;
34
/// Gets the XML code for this documentation comment.
36
public ITextSource Xml {
41
/// Creates a new DocumentationComment.
43
/// <param name="xml">The XML text.</param>
44
/// <param name="context">Context for resolving cref attributes.</param>
45
public DocumentationComment(ITextSource xml, ITypeResolveContext context)
48
throw new ArgumentNullException("xml");
50
throw new ArgumentNullException("context");
52
this.context = context;
56
/// Creates a new DocumentationComment.
58
/// <param name="xml">The XML text.</param>
59
/// <param name="context">Context for resolving cref attributes.</param>
60
public DocumentationComment(string xml, ITypeResolveContext context)
63
throw new ArgumentNullException("xml");
65
throw new ArgumentNullException("context");
66
this.xml = new StringTextSource(xml);
67
this.context = context;
71
/// Resolves the given cref value to an entity.
72
/// Returns null if the entity is not found, or if the cref attribute is syntactically invalid.
74
public virtual IEntity ResolveCref(string cref)
77
return IdStringProvider.FindEntity(cref, context);
78
} catch (ReflectionNameParseException) {
83
public override string ToString ()
88
public static implicit operator string (DocumentationComment documentationComment)
90
if (documentationComment != null)
91
return documentationComment.ToString ();