Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/Demo/Sample Extensions/ItemCollectionWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Copyright SmartFormat Project maintainers and contributors.
// Licensed under the MIT license.
//

using System.Collections.Generic;
using System.ComponentModel;

namespace Demo.Sample_Extensions;

public class InventoryItem {
public string Name { get; set; } = string.Empty;
public decimal Price { get; set; }
public int Count { get; set; }
public List<InventoryItem> Components { get; set; } = [];
public override string ToString() => $"{Name} (Comp: {Components.Count})";
}

public class ItemCollectionWrapper
{
// Use the ExpandableObjectConverter so the PropertyGrid
// shows a '+' sign next to the property to expand it.
[TypeConverter(typeof(ExpandableObjectConverter))]
// Use the Category and Description attributes for better display in the grid
[Category("Products")]
[DisplayName("Items")]
[Browsable(true)]
public List<InventoryItem> Items { get; set; }

public ItemCollectionWrapper(List<InventoryItem> items)
{
Items = items;
}

public override string ToString() => $"{Items.Count} items";

}
Loading