public object Read(Object target, BlobReader reader) { if(target != null) reader = reader.ReadFieldBlob(); object result = Activator.CreateInstance(targetType); read_field: while (reader.CanTakeBytes(BlobReader.FieldHeaderLength)) { reader.ReadFieldHeader(); for(int i = 0; i < fields.Length; i++) { var field = fields[i]; if ((field.PeekIntKey != -1 && field.PeekIntKey == reader.PeekIntKey) || (field.ByteKey.Length == reader.FieldKeyBytes && BlobUtil.UnsafeCompare(field.ByteKey, reader.ByteKey))) { field.Serializer.Read(result, reader); goto read_field; } } reader.SkipField(); } reader.SkipSpare(); if (target != null) reader.Dispose(); return result; }
public object Read(Object target, BlobReader reader) { if (target != null) { reader = reader.ReadFieldBlob(); } object result = Activator.CreateInstance(targetType); read_field: while (reader.CanTakeBytes(BlobReader.FieldHeaderLength)) { reader.ReadFieldHeader(); for (int i = 0; i < fields.Length; i++) { var field = fields[i]; if ((field.PeekIntKey != -1 && field.PeekIntKey == reader.PeekIntKey) || (field.ByteKey.Length == reader.FieldKeyBytes && BlobUtil.UnsafeCompare(field.ByteKey, reader.ByteKey))) { field.Serializer.Read(result, reader); goto read_field; } } reader.SkipField(); } reader.SkipSpare(); if (target != null) { reader.Dispose(); } return(result); }