[C#] - Find the mandatory property of a structure element

Hi everyone,

I'm trying to find the mandatory property of attributes in a structure (using C#) but I can't find it.

Did anyone succeed on this?

I'm using reflection.


Cheers.

Hi Helder,

Could you please elaborate more in some details,what exactly you want to acheive?

Salman Ansari wrote:

Hi Helder,

Could you please elaborate more in some details,what exactly you want to acheive?

Using Reflection, I want to try to create a generic action that can validate structure mandatory elements. In my case, this would be really a huge benefit for REST/Service Actions.

To do the same we have now to create specific actions for every interface, which is a lot of work/maintenance.


Hélder Anselmo wrote:

Salman Ansari wrote:

Hi Helder,

Could you please elaborate more in some details,what exactly you want to acheive?

Using Reflection, I want to try to create a generic action that can validate structure mandatory elements. In my case, this would be really a huge benefit for REST/Service Actions.

To do the same we have now to create specific actions for every interface, which is a lot of work/maintenance.


you mean you will pass structure for some action and that action will validate and loop all the attribute of structure and check the mandatory attribute???something like that? 


Salman Ansari wrote:

Hélder Anselmo wrote:

Salman Ansari wrote:

Hi Helder,

Could you please elaborate more in some details,what exactly you want to acheive?

Using Reflection, I want to try to create a generic action that can validate structure mandatory elements. In my case, this would be really a huge benefit for REST/Service Actions.

To do the same we have now to create specific actions for every interface, which is a lot of work/maintenance.


you mean you will pass structure for some action and that action will validate and loop all the attribute of structure and check the mandatory attribute???something like that? 


Exactly. Structure is sent to an extension as an Object and there I'm parsing it and then iterating the properties.

I can get the type, name, etc. but not the mandatory property...


Hélder Anselmo wrote:

Salman Ansari wrote:

Hélder Anselmo wrote:

Salman Ansari wrote:

Hi Helder,

Could you please elaborate more in some details,what exactly you want to acheive?

Using Reflection, I want to try to create a generic action that can validate structure mandatory elements. In my case, this would be really a huge benefit for REST/Service Actions.

To do the same we have now to create specific actions for every interface, which is a lot of work/maintenance.


you mean you will pass structure for some action and that action will validate and loop all the attribute of structure and check the mandatory attribute???something like that? 


Exactly. Structure is sent to an extension as an Object and there I'm parsing it and then iterating the properties.

I can get the type, name, etc. but not the mandatory property...


Can you share C# code