// Start is called before the first frame update void Start() { //1.序列化 StoreRequest storeRequest = new StoreRequest(); storeRequest.Name = "goods"; storeRequest.Num = -50; storeRequest.Result = -1; for (int i = 0; i < 50; i++) { string str = $"str{i + 1}"; storeRequest.MyList.Add(str); } byte[] bytes = ProtobufTool.Serialize(storeRequest); //2.反序列化 StoreRequest storeRequestUnSer = ProtobufTool.Deserialize <StoreRequest>(bytes); byte[] maBytes = DeSerialize.Serialize(storeRequest); //2.反序列化 StoreRequest maStoreRequestUnSer = DeSerialize.Serialization <StoreRequest>(maBytes); }
public async void ReadGetIngridients(int runTime, List <Container> containerList) { byte[] mmBuffer = new byte[1024]; int numBytes; // bytes returned from read() Stopwatch timer = new Stopwatch(); timer.Start(); while (true) { try { System.Console.WriteLine("reciving..."); if (timer.ElapsedMilliseconds >= runTime || containerList.Count > 5) { break; } numBytes = await mInStream.ReadAsync(mmBuffer, 0, mmBuffer.Length); // Send the obtained bytes to the UI activity. if (numBytes > 0) { string recivedMessage = ASCIIEncoding.ASCII.GetString(mmBuffer); System.Console.WriteLine(recivedMessage); DeSerialize.DeSerializeArray(recivedMessage, containerList, this); } } catch (System.IO.IOException e) { System.Console.WriteLine("InputStream failure ERROR:4084"); System.Console.WriteLine(e.Message); throw; } } }
public void DeSerializeInvoker() => DeSerialize?.Invoke();
public override void OnDeSerialize(IFile source, REDEventArgs e) { DeSerialize?.Invoke(source, e); }