How to extend default enum class of nopCommerce

4 years ago
I have developed one custom plugin, in which i want to extend enum class (ProductSortingEnum) of default nopCommerce.

I'm doing like following, but it's not a solution

public enum MyCustomSortingEnum : ProductSortingEnum
{
        RatingAsc = 18,

        RatingDesc = 19,

        Popular = 20,  

}

  
Is it possible to extend enum class ? if yes then please advice me, How can i do that ?

Thanks.
4 years ago
So far I know you can not extend enum. May be http://stackoverflow.com/questions/757684/enum-inheritance can help you.
4 years ago
sina.islam wrote:
So far I know you can not extend enum. May be http://stackoverflow.com/questions/757684/enum-inheritance can help you.


Hi,

Is there any other way to do that ?
4 years ago
divyang16 wrote:
So far I know you can not extend enum. May be http://stackoverflow.com/questions/757684/enum-inheritance can help you.

Hi,

Is there any other way to do that ?


Sorry divyang16 I do not know other way. I did change to the default enum and change the Stored Procedure "ProductLoadAllPaged" accordingly.
4 years ago
As far as I know, ENUM is not inheritable. That is C#'s limitation, not nopCommerce's. :)
4 years ago
wooncherk wrote:
As far as I know, ENUM is not inheritable. That is C#'s limitation, not nopCommerce's. :)


Hi wooncherk,

Yes, That's true. But i want to know if there any alternate solution !
4 years ago
Not that I know of, except changing the code. :)
4 years ago
As far as I know you cannot extend enum being a part of c#.net. You can create your own enum and use that if that fits in your scenario.
2 years ago
That means, if I need any extra enum value, I must change in the core code. :(
2 years ago
Yes Ratul, you’ve to change in code