Serialization/Deserilazation by the mobileFormatter is automatic for managed backing fields in a subclass of BusinessBase or ReadOnlyBase. It is also automatic for BusinessListBase, ReadOnlyListBase, etc. It is not automatic for custom criteria classes, but is automatic for SingleCriteria. So the private Criteria classes generated by CodeComplete needs to be modified to get serialization of private backing fields. This can be done by inheriting from CriteriaBase and overiding the following methods: protected override void OnGetState(Csla.Serialization.Mobile.SerializationInfo info, StateMode mode) { info.AddValue("_username", _username); info.AddValue("_password", _password); base.OnGetState(info, mode); } protected override void OnSetState(Csla.Serialization.Mobile.SerializationInfo info, StateMode mode) { _username = (string)info.Values["_username"].Value; _password = (string)info.Values["_password"].Value; base.OnSetState(info, mode); } Another approach is to inherit from BusinessBase and use managed backing fields: private class Criteria : BusinessBase { public Criteria() { } private static PropertyInfo<System.String> _username = RegisterProperty<System.String>(typeof(Criteria), new PropertyInfo<System.String>("Username")); private static PropertyInfo<System.String> _password = RegisterProperty<System.String>(typeof(Criteria), new PropertyInfo<System.String>("Password")); public System.String Username { get { return GetProperty<System.String>(_username); } set { SetProperty<System.String>(_username, value); } } public System.String Password { get { return GetProperty<System.String>(_password); } set { SetProperty<System.String>(_password, value); } } public Criteria(string username, string password) { Username = username; Password = password; } } Then on to CodeComplete.Services. I converted the SourceCode for CodeComplete.Services from VB to C# This was just done because I find it easier to understand C# code. (I did not convert the ExportManager Class). Made a Silverlight Class Library with the same Namespace and AssemblyName as CodeComplete.Services Linked Classes from CodeComplete.Services to CodeComplete.Services.Silverlight: ValidationManager is the only one added so far in the Silverlight library. Built the CodeComplete.Services.Silverlight Project. Added a Reference from Trackit.BusinessLayer.Silverlight project to the dll from the CodeComplete.Services.Silverlight project. This is where the Silverlight Project Compiles with no Errors for the first time! End of Part 5. Paul Solheim www.faktnet.com |