Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2928 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
11 changed files with 121 additions and 12 deletions
@ -0,0 +1,50 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright license="BSD-new" see="prj:///COPYING"/>
|
||||||
|
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Drawing; |
||||||
|
|
||||||
|
using Debugger.Expressions; |
||||||
|
using Debugger.MetaData; |
||||||
|
|
||||||
|
namespace Debugger.AddIn.TreeModel |
||||||
|
{ |
||||||
|
public class IListNode: AbstractNode |
||||||
|
{ |
||||||
|
Expression targetObject; |
||||||
|
DebugType iListType; |
||||||
|
|
||||||
|
public IListNode(Expression targetObject, DebugType iListType) |
||||||
|
{ |
||||||
|
this.targetObject = targetObject; |
||||||
|
this.iListType = iListType; |
||||||
|
|
||||||
|
this.Name = "IList"; |
||||||
|
this.ChildNodes = GetChildNodes(); |
||||||
|
} |
||||||
|
|
||||||
|
IEnumerable<AbstractNode> GetChildNodes() |
||||||
|
{ |
||||||
|
PropertyInfo countProperty = iListType.GetInterface(typeof(ICollection).FullName).GetProperty("Count"); |
||||||
|
Expression countExpr = targetObject.AppendPropertyReference(countProperty); |
||||||
|
AbstractNode countNode = ValueNode.Create(countExpr); |
||||||
|
int count = 0; |
||||||
|
if (countNode is ValueNode) { |
||||||
|
count = int.Parse(countNode.Text); |
||||||
|
} else { |
||||||
|
yield return countNode; |
||||||
|
} |
||||||
|
|
||||||
|
for(int i = 0; i < count; i++) { |
||||||
|
PropertyInfo itemProperty = iListType.GetProperty("Item"); |
||||||
|
Expression itemExpr = targetObject.AppendMemberReference(itemProperty, new PrimitiveExpression(i)); |
||||||
|
yield return ValueNode.Create(itemExpr); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue