/// <summary> /// Method called by MobileFormatter when an object /// should serialize its child references. The data should be /// serialized into the SerializationInfo parameter. /// </summary> /// <param name="info"> /// Object to contain the serialized data. /// </param> /// <param name="formatter"> /// Reference to the formatter performing the serialization. /// </param> public void GetChildren(SerializationInfo info, MobileFormatter formatter) { foreach (string key in _children.Keys) { ChildData value = _children[key]; SerializationInfo si = formatter.SerializeObject(value); info.AddChild(key, si.ReferenceId); } foreach (string key in _values.Keys) { FieldData value = _values[key]; SerializationInfo si = formatter.SerializeObject(value); info.AddChild(key, si.ReferenceId); } }
/// <summary> /// Method called by MobileFormatter when an object /// should serialize its child references. The data should be /// serialized into the SerializationInfo parameter. /// </summary> /// <param name="info"> /// Object to contain the serialized data. /// </param> /// <param name="formatter"> /// Reference to the formatter performing the serialization. /// </param> protected override void OnGetChildren(Csla.Serialization.Mobile.SerializationInfo info, Csla.Serialization.Mobile.MobileFormatter formatter) { base.OnGetChildren(info, formatter); if (_deletedList != null) { var fieldManagerInfo = formatter.SerializeObject(_deletedList); info.AddChild("_deletedList", fieldManagerInfo.ReferenceId); } }
/// <summary> /// Read a data from a stream, typically <see cref="MemoryStream"/>, and convert it into /// a list of <see cref="SerializationInfo"/> objects /// </summary> /// <param name="serializationStream">Stream to read the data from</param> /// <returns>List of <see cref="SerializationInfo"/> objects</returns> public List <SerializationInfo> Read(Stream serializationStream) { var returnValue = new List <SerializationInfo>(); int childCount, valueCount, referenceId; string systemName, enumTypeName; bool isDirty; object value; this.keywordsDictionary.Clear(); using (var reader = new BinaryReader(serializationStream)) { var totalCount = reader.ReadInt32(); for (var counter = 0; counter < totalCount; counter++) { var info = new SerializationInfo() { ReferenceId = reader.ReadInt32(), TypeName = ReadString(reader) }; childCount = reader.ReadInt32(); for (var childCounter = 0; childCounter < childCount; childCounter++) { systemName = ReadString(reader); isDirty = reader.ReadBoolean(); referenceId = reader.ReadInt32(); info.AddChild(systemName, referenceId, isDirty); } valueCount = reader.ReadInt32(); for (var valueCounter = 0; valueCounter < valueCount; valueCounter++) { systemName = ReadString(reader); enumTypeName = ReadString(reader); isDirty = reader.ReadBoolean(); value = ReadObject(reader); info.AddValue(systemName, value, isDirty, string.IsNullOrEmpty(enumTypeName) ? null : enumTypeName); } returnValue.Add(info); } } return(returnValue); }