Welcome
Guest
, you are in:
<root>
EnterpriseLibrary
FDOT Security STS
FDOT_Application_Model
GisFramework
•
Login
FDOT Wiki
GisFramework
¶
Gis Framework
Fdot Wiki
Random Page
All Pages
Categories
Search the wiki
»
Back
Caliburn Micro
Modified on Friday, 27 May 2011 01:31 PM
by
Administrator
Categorized as
Uncategorized
==Caliburn Micro == The framework makes extensive use of MVVM patterns ([^http://en.wikipedia.org/wiki/Model_View_ViewModel|Model View ViewModel]). To facilitate the user of MVVM the framework uses an open source framework Caliburn Micro. There are three main parts of the caliburn framework that are used: MVVM support, Coroutines, and Conductors. {TOC} ===Coroutines === Caliburn Micro [^http://en.wikipedia.org/wiki/Coroutine|Coroutines] help solve the problem of asynchronous calls needing to happen in synchronous workflow. Coroutines are implemented through an interface Caliburn.Micro.IResult. The Gis Framework has created two implementation of IResult to simplify it's use for framework developers. =====ResultBase===== {| class="tablesorter" ! Name !! Abstract !! Description |- | Execute(ActionExecutionContext) || True || This is where the code needs to be written to be run when the coroutine executes in the workflow. |- | Success() || False || Once the asynchronous call has been successful completed this method should be called for the next coroutine to be begin executing in the workflow. |- | Failure(Exception) || False || This should be called once an exception that is handled occurs in the coroutine. |} ResultBase Implementation Example: (((@@ csharp public class IdentifyWorkflow : ResultBase { public IEnumerable<FindOperationResult> Result { get; internal set; } public IdentifyWorkflow(IdentifyOptions options, string url) { _options = options; _url = url; } private readonly string _url; private readonly IdentifyOptions _options; public override void Execute(ActionExecutionContext context) { try { var svs = ServiceClients.GetQueryServiceClient(); svs.IdentifyCompressedCompleted += svs_IdentifyCompleted; svs.IdentifyCompressedAsync(_options, _url); } catch (Exception ex) { Failure(ex); } } private void svs_IdentifyCompleted(object sender, IdentifyCompressedCompletedEventArgs e) { e.Result.Decompress<FindOperationResults>(result => { result.Results.ToList().ForEach(x => x.Url = _url); Result = result.Results; Success(); }); } }@@))) =====Creating a Workflow===== Coroutines are executed in the context of a workflow. Workflows methods return an IEnumerble<IResult> that enumerates through the coroutines in the workflow. In the workflow method instances of the coroutines are created then the yield return keyword is called on the couroutine. Example of workflow being created and executed: (((@@ csharp public void RunWorkflow() { var executionContext = new ActionExecutionContext(); Coroutine.BeginExecute(GetSampleWorkflow().GetEnumerator(), executionContext, Complete); } private static void Complete(object sender, ResultCompletionEventArgs e) { if (e.Error != null) throw new Exception("Error on SampleWorkflow",e.Error); } private IEnumerable<IResult> GetSampleWorkflow() { var coroutine1 = new SampleCoroutines(); yield return coroutine1; //Do something with the result var coroutine2 = new SampleCoroutines2(); yield return coroutine2; yield break; }@@))) See Also *[^http://caliburnmicro.codeplex.com/wikipage?title=IResult and Coroutines&referringTitle=Documentation|In Depth Look at Coroutines] ==MVVM Support== Caliburn Micro framework allows developers to easily implement a MVVM pattern in there application. When Caliburn Micro is used to set the binding between the view and view model conventions and actions can be used. Example of Binding View and ViewModel: @@ csharp var view = new ReportView(); var viewModel = new ReportViewModel(); Caliburn.Micro.View.SetModel(view, viewModel);@@ =====Conventions===== Caliburn Micro supports convention based bindings. Examples of this include are creating a button in the xaml view name SaveButton. When a method is also named SaveButton in the viewModel the onclick event is automatically wired up to the viewModel's method. View's XAML: (((@@ xml <Button x:Name="SaveButton" Content="Save"/>@@))) ViewModel cs: (((@@ csharp public void SaveButton() { //Do Something }@@))) There are many more options for the convention based binding can be found in the following article In Depth Look at Conventions. =====Actions===== Caliburn Micro allow developers to wire up events from the view to methods in the view models. See more about actions in the following article In Depth Look at Actions. ==Screens and Conductors == [^http://caliburnmicro.codeplex.com/wikipage?title=Screens, Conductors and Composition&referringTitle=Documentation|In Depth Look at Screens and Conductors] ==See Also== {INCOMING}
Meta Keywords:
Meta Description:
Change Comment:
Any Questions or Comments? Email
GIS Framework Development Team
Some of the icons created by
FamFamFam
.