Example #1
0
        /// <summary>
        /// Deserializes the given object.
        /// </summary>
        /// <param name="stream">Stream containing data.</param>
        /// <param name="type">The type of the object to create.</param>
        /// <returns>The deserialized object.</returns>
        public object Deserialize(Type type, SerializeStream stream)
        {
            Type elementType = stream.ReadType("elementType");
            int  length      = stream.ReadInt("length");

            System.Array array = System.Array.CreateInstance(elementType, length);
            for (int i = 0; i < array.Length; i++)
            {
                array.SetValue(stream.ReadObject(null), i);
            }
            return(array);
        }
Example #2
0
        /// <summary>
        /// Deserializes the given object.
        /// </summary>
        /// <param name="stream">Stream containing data.</param>
        /// <param name="type">The type of the object to create.</param>
        /// <returns>The deserialized object.</returns>
        public object Deserialize(Type type, SerializeStream stream)
        {
            int length = stream.ReadInt("registered");

            for (int i = 0; i < length; i++)
            {
                stream.EnterObject(null);
                Register(stream.ReadString("Name"), stream.ReadString("DllPath"), stream.ReadString("ClassName"));
                stream.LeaveObject();
            }
            return(this);
        }
Example #3
0
 /// <summary>
 /// Deserializes the given object.
 /// </summary>
 /// <param name="stream">Stream containing data.</param>
 /// <param name="type">The type of the object to create.</param>
 /// <returns>The deserialized object.</returns>
 public object Deserialize(Type type, SerializeStream stream)
 {
     if (type == typeof(int))
     {
         return(stream.ReadInt("value"));
     }
     else if (type == typeof(float))
     {
         return(stream.ReadFloat("value"));
     }
     else if (type == typeof(bool))
     {
         return(stream.ReadBool("value"));
     }
     else
     {
         throw new NotSupportedException("Type: " + type.Name + " not supported at the moment");
     }
 }
Example #4
0
        /// <summary>
        /// Deserializes the given object.
        /// </summary>
        /// <param name="stream">Stream containing data.</param>
        /// <param name="type">The type of the object to create.</param>
        /// <returns>The deserialized object.</returns>
        public object Deserialize(Type type, SerializeStream stream)
        {
            int id = stream.ReadInt("id");

            return(stream.ReferenceManager.GetReference(id));
        }