Fauna v10 .NET/C# Driver 0.2.0-beta
 
Loading...
Searching...
No Matches
QueryArr.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.ObjectModel;
3using Fauna.Mapping;
5
6namespace Fauna;
7
8internal sealed class QueryArr<T> : Query, IQueryFragment, IEnumerable<T>
9{
10 public QueryArr(IEnumerable<T> v)
11 {
12 if (v == null)
13 {
14 throw new ArgumentNullException(nameof(v), "Value cannot be null.");
15 }
16
17 Unwrap = new ReadOnlyCollection<T>(v.ToList());
18 }
19
20 public ReadOnlyCollection<T> Unwrap { get; }
21
22 public int Count => Unwrap.Count;
23
24 public T this[int index] => Unwrap[index];
25
26 public override void Serialize(MappingContext ctx, Utf8FaunaWriter writer)
27 {
28 throw new NotImplementedException();
29 }
30
31 public override bool Equals(Query? o)
32 {
33 return o is QueryArr<T> other && Unwrap.SequenceEqual(other.Unwrap);
34 }
35
36 public override bool Equals(object? otherObject)
37 {
38 return Equals(otherObject as Query);
39 }
40
41 public override int GetHashCode()
42 {
43 unchecked
44 {
45 int hash = 17;
46 for (int i = 0; i < Unwrap.Count; i++)
47 {
48 T item = Unwrap[i];
49 hash = hash * 31 + (item?.GetHashCode() ?? 0);
50 }
51 return hash;
52 }
53 }
54
55 public override string ToString()
56 {
57 return $"QueryArr({string.Join(", ", Unwrap)})";
58 }
59
60 public IEnumerator<T> GetEnumerator()
61 {
62 return Unwrap.GetEnumerator();
63 }
64
65 IEnumerator IEnumerable.GetEnumerator()
66 {
67 return GetEnumerator();
68 }
69}
A class representing the mapping context to be used during serialization and deserialization.
Represents the abstract base class for constructing FQL queries.
Definition Query.cs:11
Provides functionality for writing data in a streaming manner to a buffer or a stream.
Represents the base interface for a query fragment used for FQL query construction.
Definition Client.cs:8