Windows WorkFlow Foundation入門(六)- 編譯工作流
編譯工作流
工作流可以通過以下三種方式被創(chuàng)建:
通過工作流markup文件,使用工作流markup,該文件的后綴為.xoml。通過宿主程序,把該文件傳入給工作流運行時引擎,這種方式被稱為“無代碼工作流創(chuàng)建”,這種方式下,工作流不需要編譯。被創(chuàng)建的文件名WorkflowSample.xoml(舉例)
另一種方式是,markup文件用來聲明工作流,然后與包含邏輯實現的代碼一起被編譯。這種方式被稱為“代碼分離工作流創(chuàng)建”。被創(chuàng)建的文件名為:WorkflowSample.xoml 和WorkflowSample.xoml.cs
在代碼文件中使用WF對象模型。這種方式稱為“僅代碼工作流創(chuàng)建”。被創(chuàng)建的文件名為:WorkflowSample.cs 和 WorkflowSample.Designer.cs,這些文件會被編譯。
當工作流被編譯時,會執(zhí)行以下過程:
- 驗證工作流活動是否符合為該活動設置的規(guī)則,如果驗證產生錯誤,編譯器會返回一個錯誤列表;
- 據傳入到編譯器中的標記(markup)定義,創(chuàng)建一個partial類;
- 從標記文件產生的partial類和人代碼文件產生的partial類,被送入到.net編譯器,這個過程的輸出結果就是一個.net 程序集。文件名如:WorkflowSample.dll,可以被部署運行工作流了。
在命令行中使用wfc.exe
WF提供了命令行方式的工作流編譯器,即wfc.exe。WF同樣提供一系列的支持工作流編譯公共類型,可以用來開發(fā)自定義的工作流編譯器。這些公共類型也是wfc.exe所用來的類型。你可以通過WorkflowCompiler類來創(chuàng)建一個自定義的編譯器。
你還可以使用WorkflowCompiler類來編譯工作流,例如:
WorkflowCompilerParameters param = new WorkflowCompilerParameters();
compiler.Compile(param, new string[] { "MainWorkflow.xoml" });
wfc.exe編譯選項
wfc命令行的選項如下
Microsoft (R) Windows Workflow Compiler version 3.0.0.0
Copyright (C) Microsoft Corporation 2005. All rights reserved.
Windows Workflow Compiler Options
wfc.exe <XAML file> /target:codegen [/language:...]
wfc.exe <XAML file list> /target:assembly [<vb/cs file list>] [/language:...]
[/out:...] [/reference:...] [/library:...] [/debug:...] [/nocode:...] [/checktypes:...]
- OUTPUT FILE -
/out:<file> Output file name
/target:assembly Build a Windows Workflow assembly (default).
Short form: /t:assembly
/target:exe Build a Windows Workflow application.
Short form: /t:exe
/target:codegen Generate partial class definition.
Short form: /t:codegen
/delaysign[+|-] Delay-sign the assembly using only the public portion
of the strong name key.
/keyfile:<file> Specifies a strong name key file.
/keycontainer:<string> Specifies a strong name key container.
- INPUT FILES -
<XAML file list> XAML source file name(s).
<vb/cs file list> Code file name(s).
/reference:<file list> Reference metadata from the specified assembly file(s).
Short form is '/r:'.
/library:<path list> Set of directories where to lookup for the references.
Short form is '/lib:'.
- CODE GENERATION -
/debug[+|-] Emit full debugging information. The default is '+'.
Short form is '/d:'.
/nocode[+|-] Disallow code-separation and code-within models.
The default is '-'. Short form is '/nc:'.
/checktypes[+|-] Check for permitted types in wfc.exe.config file.
The default is '-'. Short form is '/ct:'.
- LANGUAGE -
/language:[cs|vb] The language to use for the generated class.
The default is 'CS' (C#). Short form is '/l:'.
/rootnamespace:<string> Specifies the root Namespace for all type declarations.
Valid only for 'VB' (Visual Basic) language.
Short form is '/rns:'.
- MISCELLANEOUS -
/help Display this usage message. Short form is '/?'.
/nologo Suppress compiler copyright message. Short form is '/n'.
/nowarn Ignore compiler warnings. Short form is '/w'.
浙公網安備 33010602011771號