Skip to content

Commit 982b6f1

Browse files
#130 - Deserialize attachments as is
1 parent bd5c978 commit 982b6f1

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

Diff for: src/CouchDB.Driver/Types/CouchDocument.cs

+5-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public abstract class CouchDocument
1313
protected CouchDocument()
1414
{
1515
_conflicts = new List<string>();
16-
_attachments = new Dictionary<string, CouchAttachment>();
16+
AttachmentsParsed = new Dictionary<string, CouchAttachment>();
1717
Attachments = new CouchAttachmentsCollection();
1818
}
1919

@@ -44,15 +44,10 @@ protected CouchDocument()
4444
[JsonIgnore]
4545
public IReadOnlyCollection<string> Conflicts => _conflicts.AsReadOnly();
4646

47-
// This must be Deserilizable-only field
48-
[JsonIgnore]
49-
private Dictionary<string, CouchAttachment> _attachments;
47+
// This must be for serialization only field
5048
[DataMember]
5149
[JsonProperty("_attachments")]
52-
private Dictionary<string, CouchAttachment> AttachmentsSetter
53-
{
54-
set { _attachments = value; }
55-
}
50+
private Dictionary<string, CouchAttachment> AttachmentsParsed { get; set; }
5651

5752
[JsonIgnore]
5853
public CouchAttachmentsCollection Attachments { get; internal set; }
@@ -64,9 +59,9 @@ private Dictionary<string, CouchAttachment> AttachmentsSetter
6459
[OnDeserialized]
6560
internal void OnDeserializedMethod(StreamingContext context)
6661
{
67-
if (_attachments != null && _attachments.Count > 0)
62+
if (AttachmentsParsed is { Count: > 0 })
6863
{
69-
Attachments = new CouchAttachmentsCollection(_attachments);
64+
Attachments = new CouchAttachmentsCollection(AttachmentsParsed);
7065
}
7166
}
7267
}

0 commit comments

Comments
 (0)