Fauna v10 .NET/C# Driver 1.0.1
 
Loading...
Searching...
No Matches
Attributes.cs
Go to the documentation of this file.
1namespace Fauna.Mapping;
2
3
7[AttributeUsage(AttributeTargets.Class)]
8[Obsolete("Object attribute is no longer used and will not influence serialization.")]
9public class ObjectAttribute : Attribute
10{
11}
12
16[AttributeUsage(AttributeTargets.Property)]
17public class IgnoreAttribute : Attribute
18{
22 public IgnoreAttribute() { }
23
24}
25
29public abstract class BaseFieldAttribute : Attribute
30{
34 public readonly string? Name;
38 public readonly FieldType Type;
39
40 internal BaseFieldAttribute(string? name, FieldType type)
41 {
42 Name = name;
43 Type = type;
44 }
45}
46
50[AttributeUsage(AttributeTargets.Property)]
52{
56 public FieldAttribute() : base(null, FieldType.Field) { }
57
62 public FieldAttribute(string name) : base(name, FieldType.Field) { }
63}
64
69[AttributeUsage(AttributeTargets.Property)]
71{
72 private const string FieldName = "id";
73
77 public IdAttribute() : base(FieldName, FieldType.ServerGeneratedId) { }
78
79
84 public IdAttribute(bool isClientGenerated)
85 : base(FieldName, isClientGenerated ? FieldType.ClientGeneratedId : FieldType.ServerGeneratedId) { }
86}
87
92[AttributeUsage(AttributeTargets.Property)]
94{
95 private const string FieldName = "coll";
96
100 public CollectionAttribute() : base(FieldName, FieldType.Coll) { }
101
102}
103
108[AttributeUsage(AttributeTargets.Property)]
110{
111 private const string FieldName = "ts";
112
116 public TsAttribute() : base(FieldName, FieldType.Ts) { }
117}
An abstract type for attributing user-defined document classes.
Definition Attributes.cs:30
readonly? string Name
The name of the field.
Definition Attributes.cs:34
readonly FieldType Type
The type of the field.
Definition Attributes.cs:38
Attribute used to specify the coll (Collection) field on a Fauna document. The associated field will ...
Definition Attributes.cs:94
CollectionAttribute()
Initializes a CollectionAttribute. The Fauna field name will always be coll for this attribute.
Attribute used to specify fields on a Fauna document or struct.
Definition Attributes.cs:52
FieldAttribute()
Initializes a FieldAttribute of type Field with no name override. The name is inferred.
Definition Attributes.cs:56
FieldAttribute(string name)
Initializes a FieldAttribute of type Field with a name.
Definition Attributes.cs:62
Attribute used to specify the id field on a Fauna document. The associated field will be ignored duri...
Definition Attributes.cs:71
IdAttribute()
Initializes a IdAttribute, indicating Fauna will generate the ID.
Definition Attributes.cs:77
IdAttribute(bool isClientGenerated)
Initializes a IdAttribute.
Definition Attributes.cs:84
Attribute used to indicate that a field should be ignored during serialization and deserialization.
Definition Attributes.cs:18
IgnoreAttribute()
Initializes an instance of an IgnoreAttribute.
Definition Attributes.cs:22
Attribute used to indicate that a class represents a Fauna document or struct.
Definition Attributes.cs:10
Attribute used to specify the ts field on a Fauna document. The associated field will be ignored duri...
TsAttribute()
Initializes a TsAttribute. The Fauna field name will always be ts for this attribute.
FieldType
An enum for the field type, used with concrete implementations of BaseFieldAttribute.
Definition FieldType.cs:7
@ ClientGeneratedId
Indicates the document ID is client-generated.
@ Ts
Indicates the field is the ts field of the document.
@ Field
Indicates the field contains user-defined data for the document.
@ Coll
Indicates the field is the coll (collection) field of the document.
@ ServerGeneratedId
Indicates the document ID is Fauna-generated.