What is the use of XOML files? OR How can we serialize workflows?

 Posted by ArticlesMaint on 9/18/2009 | Category: WWF Interview questions | Views: 8519

Windows Workflow Foundation gives developers a declarative way to create workflows by using XAML. See WPF chapter for more details about XAML. These markup files are Stored with XOML (Extensible Object Markup Language) extension. In the below snapshot you can see Workflow1.xoml file created by designer. Markup file can also have code behind. The whole concept of having code behind for XOML file is to separate the presentation from logic files.
In the below code snapshot we have made a simple XOML sample. Below is the explanation number wise:

  1. In order to create a XOML file you need to add sequential workflow with separation. Which means that XOML file will be created with a behind code.

  2. Currently we have two activity code3 and code1. Below is the XOML file contents:
<?Mapping XmlNamespace="ComponentModel" 

Assembly="System.Workflow.ComponentModel" ?>
<?Mapping XmlNamespace="Compiler"
Assembly="System.Workflow.ComponentModel" ?>
<?Mapping XmlNamespace="Activities"
Assembly="System.Workflow.Activities" ?>
<?Mapping XmlNamespace="RuleConditions"
Assembly="System.Workflow.Activities" ?>
<SequentialWorkflow x:Class="WorkflowSeq.Workflow1"
x:CompileWith="Workflow1.xoml.cs" ID="Workflow1"
xmlns:x="Definition" xmlns="Activities">
<Code ExecuteCode="Mycode3" ID="code3" />
<Code ExecuteCode="Mycode1" ID="code1" />

See the above snippet of the XOML file. You can see how the behind code is linked using the Compile With attribute. Code forms the element of the Sequential Workflow tag. One of the best thing with Markup is we can change the sequence just by changing the XOML file we do not need to compile the whole application again.

Figure 7: - XOML in action

In the above snapshot, one of the things to now is 3, 4, and 5 numbered sections. These sections are not linked with the sample. But just to make you aware you can create serialize any workflow and deserialize them again using the text writer object.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response