Browse Source

Merge branch 'master' of git://github.com/icsharpcode/ILSpy into Debugger

newNRvisualizers
Eusebiu Marcu 15 years ago
parent
commit
044958af31
  1. 56
      ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs

56
ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs

@ -537,49 +537,23 @@ namespace ICSharpCode.NRefactory.CSharp
return null; return null;
} }
public IEnumerable<T> Annotations<T>() where T: class /// <summary>
{ /// Gets all annotations stored on this AstNode.
object annotations = this.annotations; /// </summary>
AnnotationList list = annotations as AnnotationList; public IEnumerable<object> Annotations {
if (list != null) { get {
List<T> result = new List<T>(); object annotations = this.annotations;
lock (list) { AnnotationList list = annotations as AnnotationList;
foreach (object obj in list) { if (list != null) {
T t = obj as T; lock (list) {
if (t != null) return list.ToArray();
result.Add(t);
}
}
return result;
} else {
T t = annotations as T;
if (t != null)
return new T[] { t };
else
return Enumerable.Empty<T>();
}
}
public IEnumerable<object> Annotations(Type type)
{
if (type == null)
throw new ArgumentNullException("type");
object annotations = this.annotations;
AnnotationList list = annotations as AnnotationList;
if (list != null) {
List<object> result = new List<object>();
lock (list) {
foreach (object obj in list) {
if (type.IsInstanceOfType(obj))
result.Add(obj);
} }
} else {
if (annotations != null)
return new object[] { annotations };
else
return Enumerable.Empty<object>();
} }
return result;
} else {
if (type.IsInstanceOfType(annotations))
return new object[] { annotations };
else
return Enumerable.Empty<object>();
} }
} }
#endregion #endregion

Loading…
Cancel
Save