File tree Expand file tree Collapse file tree 4 files changed +277
-179
lines changed Expand file tree Collapse file tree 4 files changed +277
-179
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // Copyright SmartFormat Project maintainers and contributors.
3+ // Licensed under the MIT license.
4+ //
5+
6+ using System . Collections . Generic ;
7+ using System . ComponentModel ;
8+
9+ namespace Demo . Sample_Extensions ;
10+
11+ public class InventoryItem {
12+ public string Name { get ; set ; } = string . Empty ;
13+ public decimal Price { get ; set ; }
14+ public int Count { get ; set ; }
15+ public List < InventoryItem > Components { get ; set ; } = [ ] ;
16+ public override string ToString ( ) => $ "{ Name } (Comp: { Components . Count } )";
17+ }
18+
19+ public class ItemCollectionWrapper
20+ {
21+ // Use the ExpandableObjectConverter so the PropertyGrid
22+ // shows a '+' sign next to the property to expand it.
23+ [ TypeConverter ( typeof ( ExpandableObjectConverter ) ) ]
24+ // Use the Category and Description attributes for better display in the grid
25+ [ Category ( "Products" ) ]
26+ [ DisplayName ( "Items" ) ]
27+ [ Browsable ( true ) ]
28+ public List < InventoryItem > Items { get ; set ; }
29+
30+ public ItemCollectionWrapper ( List < InventoryItem > items )
31+ {
32+ Items = items ;
33+ }
34+
35+ public override string ToString ( ) => $ "{ Items . Count } items";
36+
37+ }
You can’t perform that action at this time.
0 commit comments