Hi all, Welcome back to Knowledge Base.
Everyone of us will be working on Portable Class Libraries and we will be creating lot of entities in that library. As in web technologies like ASP.NET MVC when we are working with entities we have got an option to specify the descriptive name for the property in our entity.
But where as in PCL libraries we don't have System.ComponentModel.DescriptionAttribute
We don't have any straight forward way to get this in to PCL. So we are using .NET Reflection.
We have created a simple EnumsHelper class which can be even altered for handling class also.
We are creating a class which is inheriting from Attribute where we are creating a property DisplayName.
We will be using the EnumDescription attribute like in above code snippet. We will be using the below snippet to populate the description.
Now with this process we can even deal with description in PCL Libraries.
Hope you liked it... Happy Coding....