public void ActivitySerializeTest() { IWfProcessDescriptor processDesc = WfProcessTestCommon.CreateSimpleProcessDescriptor(); WfProcessStartupParams startupParams = new WfProcessStartupParams(); startupParams.ProcessDescriptor = processDesc; IWfProcess process = WfRuntime.StartWorkflow(startupParams); Sky sky = new Sky(); sky.air = "清新"; sky.Cloud = 1; Sky space = new Sky(); space.air = "干净"; space.Cloud = 1; process.InitialActivity.Context.Add("DDO", sky); process.InitialActivity.Context.Add("DFO", space); XElementFormatter formatter = new XElementFormatter(); XElement root = formatter.Serialize(process); Console.WriteLine(root.ToString()); IWfProcess clonedProcess = (IWfProcess)formatter.Deserialize(root); Assert.IsNotNull(clonedProcess.InitialActivity.Context["DDO"]); Assert.AreEqual(process.InitialActivity.Context.Count, clonedProcess.InitialActivity.Context.Count); Assert.AreEqual(((Sky)process.InitialActivity.Context["DDO"]).air, ((Sky)clonedProcess.InitialActivity.Context["DDO"]).air); Assert.AreEqual(((Sky)process.InitialActivity.Context["DDO"]).Cloud, ((Sky)clonedProcess.InitialActivity.Context["DDO"]).Cloud); Assert.AreEqual(((Sky)process.InitialActivity.Context["DFO"]).air, ((Sky)clonedProcess.InitialActivity.Context["DFO"]).air); Assert.AreEqual(((Sky)process.InitialActivity.Context["DFO"]).Cloud, ((Sky)clonedProcess.InitialActivity.Context["DFO"]).Cloud); }