void ReadData() { EmbedHandDataV1 obj = dataReader.read(); Debug.Log("received" + obj.X); // try // { // map = MemoryMappedFile.Open(MapAccess.FileMapRead, "handCursorData"); // } // catch // { // map = MemoryMappedFile.Create(MapProtection.PageReadWrite, 8 * 1024, "handCursorData"); // } // reader= map.MapView(MapAccess.FileMapRead, 0, 8 * 1024); // int a; // List<char> d = new List<char> (); // try // { // mutex = Mutex.OpenExisting("MyMutex"); // } // catch // { // mutex = new Mutex(false, "MyMutex", out mutexCreated); // } // if (mutexCreated == false) // { // Console.WriteLine("Mutex error"); // //return; // } // // mutex.WaitOne(); // while(true) { // a = GetData (); // if (a <= 0) { // break; // } // d.Add ((char)a); // //Debug.Log ((char)a); // } // mutex.ReleaseMutex (); // string fdata = new string (d.ToArray ()); // Debug.Log (fdata); // EmbedHandDataV1 obj=null; // try{ // obj = DeserializeFromXML (fdata); // }catch(Exception e) // { // // } // //if (obj != null) { // //Debug.Log (obj.X); // //} }
public static EmbedHandDataV1 DeserializeFromXML(string xmlData) { EmbedHandDataV1 data = null; StringReader stringReader = null; XmlSerializer deserializer = new XmlSerializer(typeof(EmbedHandDataV1)); stringReader = new StringReader(xmlData); data = (EmbedHandDataV1)deserializer.Deserialize(stringReader); stringReader.Close(); return(data); }