Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ public string CategoryValue

#endregion

#region TypeId

public override object TypeId
=> CategoryValue;

#endregion TypeId

#endregion

#region constructor
Expand All @@ -73,4 +80,3 @@ public CategoryOrderAttribute( string categoryName, int order )
#endregion
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -133,36 +133,20 @@ private PropertyItem CreatePropertyItem( PropertyDescriptor property, PropertyDe
return propertyItem;
}

private int GetCategoryOrder( object categoryValue )
private int GetCategoryOrder(object categoryValue)
{
Debug.Assert( SelectedObject != null );
Debug.Assert(SelectedObject != null);

if( categoryValue == null )
if (categoryValue == null)
return int.MaxValue;

int order = int.MaxValue;
object selectedObject = SelectedObject;
CategoryOrderAttribute[] orderAttributes = ( selectedObject != null )
? ( CategoryOrderAttribute[] )selectedObject.GetType().GetCustomAttributes( typeof( CategoryOrderAttribute ), true )
: new CategoryOrderAttribute[ 0 ];
object selectedObject = SelectedObject;

var orderAttribute = orderAttributes
.FirstOrDefault( ( a ) => object.Equals( a.CategoryValue, categoryValue ) );
var orderAttribute = TypeDescriptor.GetAttributes(selectedObject)
.OfType<CategoryOrderAttribute>()
.FirstOrDefault(a => Equals(a.CategoryValue, categoryValue));

if( orderAttribute != null )
{
order = orderAttribute.Order;
}

return order;
return orderAttribute?.Order ?? int.MaxValue;
}








}
}