SpriteLibrary
SpriteLibrary
SpriteLibrary
SpriteDatabase Class
SpriteDatabase Methods
CloneByXMLSerializing(T) Method
GetImageFromName Method
GetImageNames Method
LoadObjectFromXmlFile(T) Method
OpenEditWindow Method
ReadFromXmlFile(T) Method
ReadFromXmlString(T) Method
Save Method
SetIcon Method
SetSnapGridSize Method
SpriteFromName Method
SpriteNames Method
WriteToXmlFile(T) Method
WriteToXMLString(T) Method

# SpriteDatabase LoadObjectFromXmlFile T Method

Load in an XML serialized item from the specified ResourceManager. You will usually make an XML file by creating an object (as a variable) and using WriteToXmlFile
T
(String, T) to serialize it and save it to a file on your desktop. Then you can drag and drop that file into your project and then use this LoadObjectFromXmlFile function. You can google XML Serialization for more information.

Namespace: SpriteLibrary
Assembly: SpriteLibrary (in SpriteLibrary.dll) Version: 1.0.0.6 (1.0.0.6)
Syntax
C#
Copy

    public static T LoadObjectFromXmlFile<T>(
    	string XMLResourceToLoad,
    	ResourceManager MyManager
    )
    where T : new()

#### Parameters

XMLResourceToLoad
  Type: System
  String
  The resource item to load. If you would access it like: properties.resources.myFile, the correct value to put here would be "myFile"
MyManager
  Type: System.Resources
  ResourceManager
  The resource manager. Usually Properties.Resources.ResourceManager

#### Type Parameters

T
  The type of object to load. It could be something as simple as an int, a class, or a list of classes.

#### Return Value

Type: T
An object of the value you specified. Or null if it fails.
Examples
XML Serialization takes an object (a class, a variable, or whatever) and will store any public values in XML. You can choose to save the resulting XML as a string, or to save it to a file. This function Loads it from a resource file (one which has been added to Properties.Resources.) The corresponding write function: WriteToXmlFile
T
(String, T) writes to a file that is outside of Properties.Resources; the resources of a program are read-only. Once you write to a file, you can drag the resulting XML into your project and load it from there. If you want to load from an XML file that is not a resource, use ReadFromXmlFile
T
(String)

Here is code to create an item and save it to a file.
Copy

    MyClass MyVariable = new MyClass();
    MyVariable.Name = "StoreThis!";

    SpriteDatabase.WriteToXmlFile<MyClass>("c:\xml_file.xml", MyClass);

Now that we have an XML file, we drag that file into our project so that it shows up in our Properties.Resources and then we can use this code to load it.
Copy

    MyClass MyVariable = SpriteDatabase.LoadObjectFromXmlFile<MyClass>("xml_file",Properties.Resources.ResourceManager);
    Console.WriteLine(MyVariable.Name);

See Also

#### Reference

SpriteDatabase Class
SpriteLibrary Namespace