public IDataHolder Read(BinaryReader reader) { var firstVal = m_persistors[0].Read(reader); var holder = (IDataHolder)m_Def.CreateHolder(firstVal); m_fields[0].Accessor.Set(holder, firstVal); for (var i = 1; i < m_persistors.Length; i++) { var persistor = m_persistors[i]; try { var val = persistor.Read(reader); m_fields[i].Accessor.Set(holder, val); } catch (Exception e) { throw new DataHolderException(e, "Failed to read DataHolder \"{0}\" (Persistor #{1} {2} for: {3}).", holder, i, persistor, m_fields[i]); } } return(holder); }
public IDataHolder Read(BinaryReader reader) { object firstValue = m_persistors[0].Read(reader); IDataHolder holder = (IDataHolder)m_Def.CreateHolder(firstValue); m_fields[0].Accessor.Set(holder, firstValue); for (int index = 1; index < m_persistors.Length; ++index) { IBinaryPersistor persistor = m_persistors[index]; try { object obj = persistor.Read(reader); m_fields[index].Accessor.Set(holder, obj); } catch (Exception ex) { throw new DataHolderException(ex, "Failed to read DataHolder \"{0}\" (Persistor #{1} {2} for: {3}).", (object)holder, (object)index, (object)persistor, (object)m_fields[index]); } } return(holder); }