Пример #1
0
        void IMobileObject.GetChildren(SerializationInfo info, MobileFormatter formatter)
        {
            int count = 0;

            foreach (var key in this.Keys)
            {
                if (_keyIsMobile)
                {
                    SerializationInfo si = formatter.SerializeObject(key);
                    info.AddChild(_keyPrefix + count, si.ReferenceId);
                }
                else
                {
                    info.AddValue(_keyPrefix + count, key);
                }

                if (_valueIsMobile)
                {
                    SerializationInfo si = formatter.SerializeObject(this[key]);
                    info.AddChild(_valuePrefix + count, si.ReferenceId);
                }
                else
                {
                    V value = this[key];
                    info.AddValue(_valuePrefix + count, value);
                }
                count++;
            }
        }
        protected override void OnGetChildren(SerializationInfo info, MobileFormatter formatter)
        {
            base.OnGetChildren(info, formatter);


            var boInfo = formatter.SerializeObject(this.BusinessObject);

            info.AddChild(nameof(BusinessObject), boInfo.ReferenceId);

            var mdInfo = formatter.SerializeObject(this.MobileDependencies);

            info.AddChild(nameof(MobileDependencies), mdInfo.ReferenceId);
        }
        // TODO : Make these generic
        // Probably take some changes to MobileFormatter but that's ok in the future

        protected override void OnGetChildren(SerializationInfo info, MobileFormatter formatter)
        {
            base.OnGetChildren(info, formatter);

            var mdInfo = formatter.SerializeObject(_newChild);

            info.AddChild(nameof(_newChild), mdInfo.ReferenceId);
        }
Пример #4
0
        /// <summary>
        /// Override this method to insert your child object
        /// references into 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 OnGetChildren(SerializationInfo info, MobileFormatter formatter)
        {
            if (_brokenRules != null && _brokenRules.Count > 0)
            {
                SerializationInfo brInfo = formatter.SerializeObject(_brokenRules);
                info.AddChild("_brokenRules", brInfo.ReferenceId);
            }

            base.OnGetChildren(info, formatter);
        }
Пример #5
0
        /// <summary>
        /// Override this method to manually retrieve child
        /// object data from the serializations stream.
        /// </summary>
        /// <param name="info">Serialization info.</param>
        /// <param name="formatter">Reference to the SerializationFormatterFactory.GetFormatter().</param>
        protected override void OnGetChildren(SerializationInfo info, MobileFormatter formatter)
        {
            if (_fieldManager != null)
            {
                SerializationInfo child = formatter.SerializeObject(_fieldManager);
                info.AddChild("_fieldManager", child.ReferenceId);
            }

            base.OnGetChildren(info, formatter);
        }
Пример #6
0
 void IMobileObject.GetChildren(SerializationInfo info, MobileFormatter formatter)
 {
   foreach (string key in this.Keys)
   {
     object value = this[key];
     IMobileObject mobile = value as IMobileObject;
     if (mobile != null)
     {
       SerializationInfo si = formatter.SerializeObject(mobile);
       info.AddChild(key, si.ReferenceId);
     }
   }
 }
Пример #7
0
 void IMobileObject.GetChildren(SerializationInfo info, MobileFormatter formatter)
 {
     foreach (string key in this.Keys)
     {
         object        value  = this[key];
         IMobileObject mobile = value as IMobileObject;
         if (mobile != null)
         {
             SerializationInfo si = formatter.SerializeObject(mobile);
             info.AddChild(key, si.ReferenceId);
         }
     }
 }
Пример #8
0
 /// <summary>
 /// Serializes child objects.
 /// </summary>
 /// <param name="info">Serialization state</param>
 /// <param name="formatter">Serializer instance</param>
 protected override void OnGetChildren(SerializationInfo info, MobileFormatter formatter)
 {
     foreach (IFieldData data in _fieldData)
     {
         if (data != null)
         {
             if (data.Value is IMobileObject mobile)
             {
                 SerializationInfo childInfo = formatter.SerializeObject(mobile);
                 info.AddChild(data.Name, childInfo.ReferenceId, data.IsDirty);
             }
         }
     }
     base.OnGetChildren(info, formatter);
 }
Пример #9
0
        void IMobileObject.GetChildren(SerializationInfo info, MobileFormatter formatter)
        {
            foreach (IFieldData data in _fieldData)
            {
                if (data != null)
                {
                    IMobileObject mobile = data.Value as IMobileObject;
                    if (mobile != null)
                    {
                        SerializationInfo childInfo = formatter.SerializeObject(mobile);
                        info.AddChild(data.Name, childInfo.ReferenceId, data.IsDirty);
                    }
                }
            }

            OnGetChildren(info, formatter);
        }
Пример #10
0
        /// <summary>
        /// Override this method to manually serialize child objects
        /// contained within the current object.
        /// </summary>
        /// <param name="info">Object containing serialized values.</param>
        /// <param name="formatter">Reference to the current MobileFormatter.</param>
        protected virtual void OnGetChildren(SerializationInfo info, MobileFormatter formatter)
        {
            bool mobileChildren = typeof(IMobileObject).IsAssignableFrom(typeof(T));
            int  count          = 0;

            foreach (T child in this)
            {
                if (mobileChildren)
                {
                    SerializationInfo si = formatter.SerializeObject(child);
                    info.AddChild(_valuePrefix + count, si.ReferenceId);
                }
                else
                {
                    info.AddValue(_valuePrefix + count, child);
                }
                count++;
            }
            info.AddValue("count", count);
        }
Пример #11
0
		/// <summary>
		/// Read a data from a stream, typically MemoryStream, and convert it into 
		/// a list of SerializationInfo objects
		/// </summary>
		/// <param name="serializationStream">Stream to read the data from</param>
		/// <returns>List of 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;
			keywordsDictionary.Clear();
			using (var reader = new BinaryReader(serializationStream))
			{
				int totalCount = reader.ReadInt32();
				for (int counter = 0; counter < totalCount; counter++)
				{
					var info = new SerializationInfo();
					info.ReferenceId = reader.ReadInt32();
					info.TypeName = (string)ReadObject(reader);

					childCount = reader.ReadInt32();
					for (int childCounter = 0; childCounter < childCount; childCounter++)
					{
						systemName = (string)ReadObject(reader);
						isDirty = (bool)ReadObject(reader);
						referenceId = (int)ReadObject(reader);
						info.AddChild(systemName, referenceId, isDirty);
					}

					valueCount = reader.ReadInt32();
					for (int valueCounter = 0; valueCounter < valueCount; valueCounter++)
					{
						systemName = (string)ReadObject(reader);
						enumTypeName = (string)ReadObject(reader);
						isDirty = (bool)ReadObject(reader);
						value = ReadObject(reader);
						info.AddValue(systemName, value, isDirty, string.IsNullOrEmpty(enumTypeName) ? null : enumTypeName);
					}
					returnValue.Add(info);
				}
			}

			return returnValue;
		}
Пример #12
0
    /// <summary>
    /// Override this method to insert your child object
    /// references into 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 OnGetChildren(SerializationInfo info, MobileFormatter formatter)
    {
      if (_brokenRules != null && _brokenRules.Count > 0)
      {
        SerializationInfo brInfo = formatter.SerializeObject(_brokenRules);
        info.AddChild("_brokenRules", brInfo.ReferenceId);
      }

      base.OnGetChildren(info, formatter);
    }
Пример #13
0
 protected override void OnGetChildren(SerializationInfo info, MobileFormatter formatter)
 {
     info.AddChild("PrimaryContact", formatter.SerializeObject(PrimaryContact).ReferenceId);
     info.AddChild("AccountsPayableContact", formatter.SerializeObject(AccountsPayableContact).ReferenceId);
 }
Пример #14
0
        protected override void OnGetChildren(SerializationInfo info, MobileFormatter formatter)
        {
            var serializedCriteria = formatter.SerializeObject(Criteria);

            info.AddChild("Criteria", 2);
        }
Пример #15
0
        /// <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)
        {
            if (info == null)
                throw new ArgumentNullException("info");

            if (formatter == null)
                throw new ArgumentNullException("formatter");

            if (BuildFailure != null)
            {
                var childInfo = formatter.SerializeObject(BuildFailure);
                info.AddChild("BuildFailure", childInfo.ReferenceId);
            }
        }