Exemple #1
0
 private static void PopulateSectorWithObjects(XmlReader reader, Sector sector)
 {
     while (reader.Read() && !(!reader.IsStartElement() && reader.LocalName.Equals("OBJECTS")))
     {
         if (reader.IsStartElement())
         {
             Debug.Log(reader.LocalName);
             try{
                 DType deserializer = deserializers [reader.LocalName];
                 if (deserializer != null)
                 {
                     IUnityXmlSerializable deserializedThing = deserializer.Invoke(reader);
                     if (deserializedThing)
                     {
                         sector.AddToSector(deserializedThing.gameObject);
                     }
                 }
                 else
                 {
                     Debug.LogError("Cannot find deserialization method for: " + reader.LocalName);
                 }
             } catch (KeyNotFoundException k) {
                 Debug.LogError("Cannot find Type Mapping for: " + reader.LocalName + " " + k.Message);
             }
         }
     }
 }
Exemple #2
0
    public static IUnityXmlSerializable MyMonoDeserialize(XmlReader reader)
    {
//		switch (reader.LocalName) {
//		case typeof(Module).Name:
//			return DeserializeModule (reader);
//		case typeof(Ship).Name:
//			return DeserializeShip (reader);
//		default:
//			return null;
//		}

        DType func = deserializers[typeLookup[reader.LocalName]];

        if (func != null)
        {
            return(func.Invoke(reader));
        }
        else
        {
            throw new Exception("NO DESERIALIZER FOR: " + reader.LocalName);
        }
    }