我已经写了返回查询IEnumerable<Item>,其中Item类有几种不同的成员:
public class Item
{
public string Name { get; private set; }
public string Type { get; private set; }
public IEnumerable<Property> Properties;
public IEnumerable<Item> Items;
public Item(XElement itemElement)
{
Name = itemElement.Attribute("name").Value;
Type = itemElement.Attribute("type").Value;
Properties = from property in itemElement.Elements("Property")
select new Property(property);
Items = from item in itemElement.Elements("Item")
select new Item(item);
}
}
Run Code Online (Sandbox Code Playgroud)
我不喜欢LINQPad选择将Item属性分配给结果表中的列的顺序.我想列出现的顺序Name,Type,Properties,Items,但LINQPad默认是显示Properties,Items,Name,Type.有没有办法提示LINQPad属性列应该是什么顺序?
我仍然想知道在我不控制声明顺序的情况下是否有办法覆盖LINQPad Dump()列顺序
IEnumerable<FooObject>.
如果您可以更改Item类,则可以通过实现ICustomMemberProvider来实现此目的(请参阅http://www.linqpad.net/FAQ.aspx#extensibility)
例如
public class Item : LINQPad.ICustomMemberProvider
{
...
IEnumerable<string> ICustomMemberProvider.GetNames()
{
return new [] { "Name", "Type", "Properties", "Items" };
}
IEnumerable<Type> ICustomMemberProvider.GetTypes ()
{
return new [] { typeof (string), typeof(string) , typeof(IEnumerable<Item>), typeof(IEnumerable<Property>) };
}
IEnumerable<object> ICustomMemberProvider.GetValues ()
{
return new object [] { this.Name, this.Type, this.Properties, this.Items };
}
}
Run Code Online (Sandbox Code Playgroud)