コード例 #1
0
        /// <summary>
        /// Reads the object.
        /// </summary>
        /// <returns>The object.</returns>
        /// <param name="type">Type.</param>
        protected virtual void ReadObject(Type type, object result)
        {
            if (result != null)
            {
                if (result is ISavable)
                {
                    // Skip object start
                    m_Position++;

                    m_IsFirstProperty = true;
                    ISavable savable = result as ISavable;
                    savable.OnRead(this);

                    // Skip object end
                    m_Position++;
                }
                else
                {
                    ReadSavableMembers(result, type);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Reads into the object.
        /// </summary>
        /// <returns>The object.</returns>
        /// <param name="type">Type.</param>
        protected virtual void ReadIntoObject(Type type, object result)
        {
            if (result != null)
            {
                if (result is ISavable)
                {
                    ISavable savable = result as ISavable;
                    savable.OnRead(this);
                }
#if !UNITY_WSA || !UNITY_WINRT
                else if (result is ISerializable)
                {
                    int count = m_Reader.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        string    name  = m_Reader.ReadString();
                        FieldInfo field = type.GetSavableField(name);
                        if (field != null)
                        {
                            object fieldValue = field.GetValue(result);
                            ReadInto(fieldValue);
                            continue;
                        }
                        PropertyInfo property = type.GetSavableProperty(name);
                        if (property != null)
                        {
                            object propertyValue = property.GetValue(result, null);
                            ReadInto(propertyValue);
                            continue;
                        }
                    }
                }
#endif
                else
                {
                    ReadIntoSavableMembers(result, type);
                }
            }
        }