t4csla code generation for MVVM SL4 project

Aug 26, 2011 at 8:04 PM
As my 1st MVVM exercise, I wanted to update Rocky's SilverLight "Simple App" code sample (csla 4.1) by using EF with the Bxf framework.
In the CustomerEdit.cs class, Rocky has a #IF Silverlight and these factory method get called from the view model (see below)
If I generate w/T4csla (separate client and server classes) and the solution is setup according to Lino's documentation,
the resulting class(es) are obviously not 100% what is needed, some hands-on is required.

Any suggestions/pointers when dealing with MVVM / SL4 would be much appreciated.
Thank you.


 Factory Methods #if SILVERLIGHT     public static void BeginNewCustomer(       DataPortal.ProxyModes proxyMode,       EventHandler<DataPortalResult<CustomerEdit>> callback)     {       var dp = new DataPortal<CustomerEdit>(DataPortal.ProxyModes.LocalOnly);       dp.CreateCompleted += callback;       dp.BeginCreate();     }     public static void BeginGetCustomer(       DataPortal.ProxyModes proxyMode,       EventHandler<DataPortalResult<CustomerEdit>> callback)     {       var dp = new DataPortal<CustomerEdit>();       dp.FetchCompleted += callback;       dp.BeginFetch();     }     [Obsolete("For use by MobileFormatter")]     public CustomerEdit()     { /* required by MobileFormatter */ }     [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]     public override void DataPortal_Create(Csla.DataPortalClient.LocalProxy<CustomerEdit>.CompletedHandler handler)     {       var bw = new System.ComponentModel.BackgroundWorker();       bw.DoWork += (s, e) =>         { e.Result = e.Argument; };       bw.RunWorkerCompleted += (s, e) =>         {           try           {             using (BypassPropertyChecks)               Status = "Created " + ApplicationContext.ExecutionLocation.ToString();             CreateComplete(handler);           }           catch (Exception ex)           {             handler(this, ex);           }         };       bw.RunWorkerAsync();     }     private void CreateComplete(Csla.DataPortalClient.LocalProxy<CustomerEdit>.CompletedHandler handler)     {       base.DataPortal_Create(handler);     } #else     public static CustomerEdit GetCustomer(int id)     {       return DataPortal.Fetch<CustomerEdit>(new SingleCriteria<CustomerEdit, int>(id));     }     private CustomerEdit()     { /* require use of factory methods */ } #endif