public static byte[] Serialize(PsScriptMgr mgr) { MemoryStream sm = new MemoryStream(1024 * 10); using (BinaryWriter w = new BinaryWriter(sm)) { byte[] data = VariableMgr.Export(mgr.mVarMgr); w.Write(data.Length); w.Write(data); w.Write(mgr.mScriptList.Count); foreach (PsScript q in mgr.mScriptList) { w.Write(q.Id); q.Store(w); } SerializeList(mgr.mScriptLoadList, w); SerializeList(mgr.mScriptRemoveList, w); } return(sm.ToArray()); }
PsScript(PsScriptMgr mgr) { mMgr = mgr; mVarMgr = new VariableMgr(); Result = EResult.Max; }
public static VariableMgr Import(byte[] data) { System.IO.MemoryStream stream = new System.IO.MemoryStream(data, false); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); VariableMgr mgr = b.Deserialize(stream) as VariableMgr; return(mgr); }
public static byte[] Export(VariableMgr mgr) { System.IO.MemoryStream stream = new System.IO.MemoryStream(); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); b.Serialize(stream, mgr); return(stream.ToArray()); }
public void Store(System.IO.BinaryWriter w) { w.Write((sbyte)Result); byte[] data = VariableMgr.Export(mVarMgr);; w.Write(data.Length); w.Write(data); mTriggerGroup.Store(w); }
public void Store(System.IO.BinaryWriter w) { w.Write(Repeat.Value); w.Write((sbyte)mStep); byte[] data = VariableMgr.Export(mVarMgr); w.Write(data.Length); w.Write(data); mAction.Store(w); }
public void Restore(System.IO.BinaryReader r) { Repeat = new RepeatCount(r.ReadInt32()); mStep = (EStep)r.ReadSByte(); int length = r.ReadInt32(); byte[] data = r.ReadBytes(length); mVarMgr = VariableMgr.Import(data); mAction.Restore(r); }
public void Restore(System.IO.BinaryReader r) { Result = (EResult)r.ReadSByte(); int length = r.ReadInt32(); byte[] data = r.ReadBytes(length); mVarMgr = VariableMgr.Import(data); mTriggerGroup.Restore(r); }
public static PsScriptMgr Deserialize(Factory factory, byte[] data) { if (null == data) { return(null); } factory.Init(); PsScriptMgr scriptMgr = new PsScriptMgr(factory); MemoryStream sm = new MemoryStream(data, false); using (BinaryReader r = new BinaryReader(sm)) { int varDatalength = r.ReadInt32(); byte[] varData = r.ReadBytes(varDatalength); scriptMgr.mVarMgr = VariableMgr.Import(varData); int count = r.ReadInt32(); for (int i = 0; i < count; i++) { int id = r.ReadInt32(); PsScript script = PsScript.Load(scriptMgr, id); if (null == script) { continue; } if (!script.Init()) { continue; } scriptMgr.mScriptList.Add(script); script.Restore(r); } DeserializeList(scriptMgr.mScriptLoadList, r); DeserializeList(scriptMgr.mScriptRemoveList, r); } return(scriptMgr); }
public Trigger(PsScript script) { mScript = script; mStep = EStep.Max; mVarMgr = new VariableMgr(); }