public static ISerializable ReadSerializable(this BinaryReader reader) { long identifier = reader.ReadInt64(); if (!factory.ContainsKey(identifier)) { throw new FieldAccessException("Identifier not found: " + identifier + "!"); } ISerializable serializable = (ISerializable)Activator.CreateInstance(factory[identifier]); serializable.FromByteArray(reader); return(serializable); }