c# - Creating a class from nested unstructured data -


is there way create class kind of data?

<condition>     <action/>     <action/>     <condition>         <action/>         <action/>         <condition>             <condition>                 <action/>             </condition>         </condition>     </condition> </condition> 

the data above intrepreted <condition> condition object , <action> action object.

the scenario hierarchy till 1 .. n depth, , n number of nested condition n number of actions inside.

this not xml way wanted show how data nested

then define 2 properties:

class condition {     public condition condition {get; set;} // different name?     public list<action> actions {get; set;}  } 

how know action under condition

you can enumerate nested structure find or add parent information each action:

class action {     public condition parent { get; }     public action(condition parent)     {         parent = parent;         parent.actions.add(this); // not sure if idea     } } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

python - TypeError('Unrecognized keyword arguments: ' + str(kwargs)) # Validate user data -