Fauna v10 .NET/C# Driver 1.0.1
 
Loading...
Searching...
No Matches
BaseRefBuilder.cs
Go to the documentation of this file.
1namespace Fauna.Types;
2
3internal class BaseRefBuilder<T>
4{
5 public string? Id { get; set; }
6 public string? Name { get; set; }
7 public Module? Collection { get; set; }
8 public string? Cause { get; set; }
9 public bool? Exists { get; set; }
10 public T? Doc { get; set; }
11
12 public BaseRef<T> Build()
13 {
14 if (Collection is null) throw new ArgumentNullException(nameof(Collection));
15
16 if (Id is not null)
17 {
18 if (Exists != null && !Exists.Value) return new Ref<T>(Id, Collection, Cause ?? "");
19 if (Doc != null) return new Ref<T>(Id, Collection, Doc);
20 return new Ref<T>(Id, Collection);
21 }
22
23 if (Name is not null)
24 {
25 if (Exists != null && !Exists.Value) return new NamedRef<T>(Name, Collection, Cause ?? "");
26 if (Doc != null) return new NamedRef<T>(Name, Collection, Doc);
27 return new NamedRef<T>(Name, Collection);
28 }
29
30 throw new ArgumentException("Id and Name cannot both be null");
31 }
32}
System.ArgumentException ArgumentException
Fauna.Types.Module Module
Definition MappingInfo.cs:4