/
IArray.cs
146 lines (127 loc) · 5.55 KB
/
IArray.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//
// IArray.cs
//
// Copyright (c) 2017 Couchbase, Inc All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
using System;
using System.Collections.Generic;
using JetBrains.Annotations;
namespace Couchbase.Lite
{
/// <summary>
/// An interface representing a read-only linear collection of objects
/// </summary>
//[JsonConverter(typeof(IArrayConverter))]
public interface IArray : IArrayFragment, IEnumerable<object>
{
#region Properties
/// <summary>
/// Gets the number of elements in this array
/// </summary>
int Count { get; }
#endregion
#region Public Methods
/// <summary>
/// Gets the value at the given index as a read only array
/// </summary>
/// <param name="index">The index to lookup</param>
/// <returns>The value at the index, or <c>null</c></returns>
[CanBeNull]
ArrayObject GetArray(int index);
/// <summary>
/// Gets the value at the given index as a <see cref="Blob"/>
/// </summary>
/// <param name="index">The index to lookup</param>
/// <returns>The value at the index, or <c>null</c></returns>
[CanBeNull]
Blob GetBlob(int index);
/// <summary>
/// Gets the value at the given index as a <see cref="bool"/>
/// </summary>
/// <param name="index">The index to lookup</param>
/// <returns>The value at the index, or its converted equivalent</returns>
/// <remarks>Any non-zero object will be treated as true, so don't rely on
/// any sort of parsing</remarks>
bool GetBoolean(int index);
/// <summary>
/// Gets the value at the given index as a <see cref="DateTimeOffset"/>
/// </summary>
/// <param name="index">The index to lookup</param>
/// <returns>The value at the index, or a default</returns>
DateTimeOffset GetDate(int index);
/// <summary>
/// Gets the value at the given index as a <see cref="DictionaryObject"/>
/// </summary>
/// <param name="index">The index to lookup</param>
/// <returns>The value at the index, or <c>null</c></returns>
[CanBeNull]
DictionaryObject GetDictionary(int index);
/// <summary>
/// Gets the value at the given index as a <see cref="Double"/>
/// </summary>
/// <param name="index">The index to lookup</param>
/// <returns>The value at the index, or its converted equivalent</returns>
/// <remarks><c>true</c> will be converted to 1.0, and everything else that
/// is non-numeric will be 0.0</remarks>
double GetDouble(int index);
/// <summary>
/// Gets the value at the given index as a <see cref="Single"/>
/// </summary>
/// <param name="index">The index to lookup</param>
/// <returns>The value at the index, or its converted equivalent</returns>
/// <remarks><c>true</c> will be converted to 1.0f, and everything else that
/// is non-numeric will be 0.0f</remarks>
float GetFloat(int index);
/// <summary>
/// Gets the value at the given index as an <see cref="Int32"/>
/// </summary>
/// <param name="index">The index to lookup</param>
/// <returns>The value at the index, or its converted equivalent</returns>
/// <remarks><c>true</c> will be converted to 1, a <see cref="Double"/> value
/// will be rounded, and everything else non-numeric will be 0</remarks>
int GetInt(int index);
/// <summary>
/// Gets the value at the given index as an <see cref="Int64"/>
/// </summary>
/// <param name="index">The index to lookup</param>
/// <returns>The value at the index, or its converted equivalent</returns>
/// <remarks><c>true</c> will be converted to 1, a <see cref="Double"/> value
/// will be rounded, and everything else non-numeric will be 0</remarks>
long GetLong(int index);
/// <summary>
/// Gets the value at the given index as a <see cref="String"/>
/// </summary>
/// <param name="index">The index to lookup</param>
/// <returns>The value at the index, or <c>null</c></returns>
[CanBeNull]
string GetString(int index);
/// <summary>
/// Gets the value at the given index as an untyped object
/// </summary>
/// <param name="index">The index to lookup</param>
/// <returns>The value at the index, or <c>null</c></returns>
/// <remarks>This method should be avoided for numeric types, whose
/// underlying representation is subject to change and thus
/// <see cref="InvalidCastException"/>s </remarks>
[CanBeNull]
object GetValue(int index);
/// <summary>
/// Converts the contents of the array to a .NET list type
/// </summary>
/// <returns>The contents of the array as a .NET list</returns>
List<object> ToList();
#endregion
}
}