예제 #1
0
        public virtual void Write(BinaryWriter bw)
        {
            bw.Write(variableName);
            bw.Write((byte)attributes);
            bw.Write((byte)dataType);

            bw.Write(metaData != null);
            if (metaData != null)
            {
                metaData.Write(bw, dataType, attributes);
            }
        }
예제 #2
0
        public void Write(BinaryWriter bw)
        {
            bw.Write(variableName);
            bw.Write((byte)attributes);
            bw.Write((byte)dataType);

            if (this.attributes.HasFlagByte(VariableAttributes.IsArray) ||
                this.attributes.HasFlagByte(VariableAttributes.IsList))
            {
                if (value is IList)
                {
                    IList list  = (IList)value;
                    int   count = list.Count;
                    bw.Write(count);
                    for (int i = 0; i < count; i++)
                    {
                        DataTypeHelper.WriteToBinary(dataType, list[i], bw);
                    }
                }
                //else if(value is Array)
                //{
                //    Debug.Log(variableName + " is Array");
                //}
                else
                {
                    throw new NotImplementedException("Array serialisation has not been implemented for this array type: " + value.GetType());
                }
            }
            else
            {
                DataTypeHelper.WriteToBinary(dataType, value, bw);
            }

            bw.Write(metaData != null);
            if (metaData != null)
            {
                metaData.Write(bw, dataType, attributes);
            }
        }