is there a way to convert an existing workflow that is code based to a xoml based definition
Thanks
--
Nuno
Windows Workflow Foundation
Yes, it is fairly easy to accomplish. Try the following changing Workflow1 to the workflow type that you want to serialize to XOML:
using System;
using System.Workflow.Activities;
using System.Workflow.ComponentModel.Serialization;
using System.ComponentModel.Design.Serialization;
using System.Xml;
namespace WorkflowConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
Workflow1 workflow1 = Activator.CreateInstance<Workflow1>();
WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();
DesignerSerializationManager serializationManager = new DesignerSerializationManager();
using (XmlWriter xmlWriter = XmlWriter.Create(@"c:\SerializedWorkflow.xoml"))
{
using (serializationManager.CreateSession())
{
serializer.Serialize(serializationManager, xmlWriter, workflow1);
if (serializationManager.Errors.Count > 0)
{
throw new Exception("Serialization errors");
}
}
}
}
}
}
HI,
Are you still stuck because of this Following forum post might be useful to you:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=221919&SiteID=1
Do let us know if this solves your problem or not
Thanks
Saurabh
Add the following code to the bottom of the InitializeComponent method in the designer.cs file:
using (XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.Unicode))
{
WorkflowMarkupSerializer xomlSerializer = new WorkflowMarkupSerializer();
xomlSerializer.Serialize(xmlWriter, this);
}