开发者

Class Design related clarification c#

I have a design related question. So please guide me on how to do this?

Right now, I have a xml structure which will be in this format.

<Sheet id="abc"/>
     <Elements>
        <Element id="xyz">
           <value>23</value>
        </Element>
        <Element id="sdz">
           <value>46</value>
        </Element>
        ...
    </Elements>
</Sheet>

So, we have a class like this to store each & every element of the sheet.

Sheet
{
    Public string SheetId
    {
      get; set;
    }

    //all Elements will be stored in the below collection   
    Public IList<IDictionary<string, string>> Elements
    {
      get; set;
    }
}

But now for few sheets the format has been changed to the bel开发者_JS百科ow structure.

<abc> //SheetId
    <Elements>
       <Record>
            <Element1/>
            <Element2/>
            <Element3/>
            <Element4/>
       </Record>      
       <Record>
            <Element1/>
            <Element2/>
            <Element3/>
            <Element4/>
       </Record>
       ...   
</abc>

So, we need to create a Generic class to hold the above xml formats and we don't want to have different object to store these.

I mean in future if we have some other xml format also we need to accommodate the same without any change in the Sheet class.

So, can you please advise me on how to design the Sheet Class.?

Ok. let me explain how my app works.

Actually we have around 200 sheets(in other words measures).

1) User will upload the sheet data in xml format (all sheets in xml file) & edit the same if they want Or Enter the data in the screen (dynamic screen generated using the xml template) if they dont want to upload.

2) Then the data will be stored in the Sheet object and it will go through lot of Validation process and finally the data will be converted to xml again and stored in the db.

You can ask why you want to store this as XML? The reason is we dont want to create 200 aspx pages for this same kind of data and thats why we are generating the sheet pages dynamically using the xml templates. Also, we will be adding, updating or deleting sheets frequently.

Ok. I think now you will have some idea about this issue.

To be more clear, all the elements in my XML file will be displayed as a field in the aspx page. It maybe a Textbox, dropdown & etc....


I would recommend designing your class based on what the information actually represents and how your software plans to utilize the data, not the XML format being used.

You should always be able to do the transposition from the data format into the structure which best represents how your program will use this data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜