using (dsm.CreateSession()){
StringBuilder stringBuilder = new StringBuilder();
using (XmlTextWriter writer = new XmlTextWriter(new System.IO.StringWriter(stringBuilder))) {
WorkflowMarkupSerializer markupSerializer = new WorkflowMarkupSerializer();
markupSerializer.Serialize(dsm, writer, ruleDeinitions);
string rulesAsString = stringBuilder.ToString();
}
}
Deserialize Method
DesignerSerializationManager dsm = new DesignerSerializationManager();
using (dsm.CreateSession()){
StringBuilder stringBuilder = new StringBuilder();
using (XmlTextReader writer = new XmlTextReader(new System.IO.StringReader(xml)) ) {
reader.Read();
WorkflowMarkupSerializer markupSerializer = new WorkflowMarkupSerializer();
RuleDefinitions ruleDefinitions = markupSerializer.Deserialize(dsm, reader) as RuleDefinitions;
if (dsm.Errors.Count > 0){
WorkflowMarkupSerializationException error = dsm.Errors[0] as WorkflowMarkupSerializationException;
}
}
}