Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Reading array of Rectangles from XML

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 MrZeo   Members   

116
Like
0Likes
Like

Posted 16 April 2013 - 10:41 AM

I'm bit confused why do I have to format array of Rectangles like this:

        <SourceRect>
          0 0 48 36
          48 0 48 36
        </SourceRect>

...instead of using <item></item> or <Rectangle></Rectangle> tags for each component in array?

 

I've been using the default method described here to load XML content in to the XNA project:

http://msdn.microsoft.com/en-us/library/ff604979.aspx



#2 Dave Hunt   Members   

4872
Like
1Likes
Like

Posted 17 April 2013 - 07:10 PM

See http://blogs.msdn.com/b/shawnhar/archive/2008/08/12/everything-you-ever-wanted-to-know-about-intermediateserializer.aspx - Everything you ever wanted to know about IntermediateSerializer.

That's an optimization applied to certain types of arrays.

#3 MrZeo   Members   

116
Like
0Likes
Like

Posted 19 April 2013 - 01:57 PM

See http://blogs.msdn.com/b/shawnhar/archive/2008/08/12/everything-you-ever-wanted-to-know-about-intermediateserializer.aspx - Everything you ever wanted to know about IntermediateSerializer.

That's an optimization applied to certain types of arrays.

 

Thank you, excactly the information I needed, the built in serializer isn't very well documented.

 

Now for example I'm deserializing class something like this:

public class SomeDataList
{
    [ContentSerializer]
    private SomeData[] data;

    // public properties and other stuff.

    public SomeDataList()
    {}

    public SomeData GetSomeData(int index)
    {
        // return stuff.
    }
}

 

If I understood correctly the serializer requires parameterless constructor. Can I just mark this constructor private to only ever create instances of the class during content loading?

 

Also just to clarify I am correct on this right?

// Both reference the same object.
SomeDataList listFirst = Content.Load<SomeDataList>("ListOne");
SomeDataList listSecond = Content.Load<SomeDataList>("ListOne");

// Two different objects.
SomeDataList listFirst = Content.Load<SomeDataList>("ListOne");
SomeDataList listSecond = Content.Load<SomeDataList>("ListTwo");

 

Thanks for the help again. :>



#4 Dave Hunt   Members   

4872
Like
0Likes
Like

Posted 21 April 2013 - 05:58 PM

A private constructor should work, since IntermediateSerializer user generated IL, rather than C# to do its work.

Yes, your first two statements will reference the same object and the second two will reference different objects.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.