/// <summary> /// Override this method to retrieve your child object /// references from the MobileFormatter serialzation stream. /// </summary> /// <param name="info"> /// Object containing the data to serialize. /// </param> /// <param name="formatter"> /// Reference to MobileFormatter instance. Use this to /// convert child references to/from reference id values. /// </param> protected override void OnSetChildren(SerializationInfo info, MobileFormatter formatter) { if (info.Children.ContainsKey("_brokenRules")) { int referenceId = info.Children["_brokenRules"].ReferenceId; _brokenRules = (BrokenRulesCollection)formatter.GetObject(referenceId); } base.OnSetChildren(info, formatter); }
public void MergeBrokenRules() { UnitTestContext context = GetContext(); var root = new BrokenRulesMergeRoot(); root.Validate(); Csla.Rules.BrokenRulesCollection list = root.BrokenRulesCollection; context.Assert.AreEqual(2, list.Count, "Should have 2 broken rules"); context.Assert.AreEqual("rule://csla.test.validationrules.brokenrulesmergeroot-rulebroken/Test1", list[0].RuleName); context.Assert.Success(); context.Complete(); }
void IUndoableObject.UndoChanges(int parentEditLevel, bool parentBindingEdit) { if (((IUndoableObject)this).EditLevel > 0) { if (((IUndoableObject)this).EditLevel - 1 < parentEditLevel) { throw new UndoException(string.Format(Properties.Resources.EditLevelMismatchException, "UndoChanges"), this.GetType().Name, null, ((IUndoableObject)this).EditLevel, parentEditLevel + 1); } SerializationInfo state = _stateStack.Pop(); OnSetState(state, StateMode.Undo); lock (SyncRoot) _brokenRules = null; if (state.Values.ContainsKey("_rules")) { byte[] rules = Convert.FromBase64String(state.GetValue <string>("_rules")); lock (SyncRoot) _brokenRules = (BrokenRulesCollection)MobileFormatter.Deserialize(rules); } } }