예제 #1
0
        public IDataHolder Read(BinaryReader reader)
        {
            object      firstValue = this.m_persistors[0].Read(reader);
            IDataHolder holder     = (IDataHolder)this.m_Def.CreateHolder(firstValue);

            this.m_fields[0].Accessor.Set((object)holder, firstValue);
            for (int index = 1; index < this.m_persistors.Length; ++index)
            {
                IBinaryPersistor persistor = this.m_persistors[index];
                try
                {
                    object obj = persistor.Read(reader);
                    this.m_fields[index].Accessor.Set((object)holder, obj);
                }
                catch (Exception ex)
                {
                    throw new DataHolderException(ex,
                                                  "Failed to read DataHolder \"{0}\" (Persistor #{1} {2} for: {3}).", new object[4]
                    {
                        (object)holder,
                        (object)index,
                        (object)persistor,
                        (object)this.m_fields[index]
                    });
                }
            }

            return(holder);
        }
예제 #2
0
        public object Read(BinaryReader reader)
        {
            var arr = (Array)m_DataField.ArrayProducer.Produce();

            for (var i = 0; i < m_DataField.Length; i++)
            {
                object obj;
                if (m_UnderlyingPersistor is NestedPersistor)
                {
                    obj = arr.GetValue(i);
                    ((NestedPersistor)m_UnderlyingPersistor).Read(reader, ref obj);
                }
                else
                {
                    obj = m_UnderlyingPersistor.Read(reader);
                }
                ArrayUtil.SetValue(arr, i, obj);
            }
            return(arr);
        }