|
8 | 8 |
|
9 | 9 | namespace NPlug;
|
10 | 10 |
|
| 11 | +/// <summary> |
| 12 | +/// A list of attribute used to communicate with the host (e.g via message). |
| 13 | +/// </summary> |
11 | 14 | public readonly ref struct AudioAttributeList
|
12 | 15 | {
|
13 | 16 | private readonly IAudioAttributeListBackend? _backend;
|
14 | 17 | internal readonly IntPtr NativeContext;
|
| 18 | + |
| 19 | + /// <summary> |
| 20 | + /// Creates a new instance. |
| 21 | + /// </summary> |
15 | 22 | public AudioAttributeList(IAudioAttributeListBackend? backend, IntPtr nativeContext)
|
16 | 23 | {
|
17 | 24 | _backend = backend;
|
18 | 25 | NativeContext = nativeContext;
|
19 | 26 | }
|
20 | 27 |
|
| 28 | + /// <summary> |
| 29 | + /// Tries to set a value for the specified attribute. |
| 30 | + /// </summary> |
| 31 | + /// <param name="attributeId">The name of the attribute.</param> |
| 32 | + /// <param name="value">The value to set.</param> |
| 33 | + /// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns> |
21 | 34 | public bool TrySetBool(string attributeId, bool value)
|
22 | 35 | {
|
23 | 36 | return TrySetInt64(attributeId, value ? 1 : 0);
|
24 | 37 | }
|
25 | 38 |
|
| 39 | + /// <summary> |
| 40 | + /// Tries to get a value for the specified attribute. |
| 41 | + /// </summary> |
| 42 | + /// <param name="attributeId">The name of the attribute.</param> |
| 43 | + /// <param name="value">The value to get.</param> |
| 44 | + /// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns> |
26 | 45 | public bool TryGetBool(string attributeId, out bool value)
|
27 | 46 | {
|
28 | 47 | var result = TryGetInt64(attributeId, out var intValue);
|
29 | 48 | value = intValue != 0;
|
30 | 49 | return result;
|
31 | 50 | }
|
32 | 51 |
|
| 52 | + /// <summary> |
| 53 | + /// Tries to set a value for the specified attribute. |
| 54 | + /// </summary> |
| 55 | + /// <param name="attributeId">The name of the attribute.</param> |
| 56 | + /// <param name="value">The value to set.</param> |
| 57 | + /// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns> |
33 | 58 | public bool TrySetByte(string attributeId, byte value)
|
34 | 59 | {
|
35 | 60 | return TrySetInt64(attributeId, value);
|
36 | 61 | }
|
37 | 62 |
|
| 63 | + /// <summary> |
| 64 | + /// Tries to get a value for the specified attribute. |
| 65 | + /// </summary> |
| 66 | + /// <param name="attributeId">The name of the attribute.</param> |
| 67 | + /// <param name="value">The value to get.</param> |
| 68 | + /// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns> |
38 | 69 | public bool TryGetByte(string attributeId, out byte value)
|
39 | 70 | {
|
40 | 71 | var result = TryGetInt64(attributeId, out var intValue);
|
41 | 72 | value = (byte)intValue;
|
42 | 73 | return result;
|
43 | 74 | }
|
44 | 75 |
|
| 76 | + /// <summary> |
| 77 | + /// Tries to set a value for the specified attribute. |
| 78 | + /// </summary> |
| 79 | + /// <param name="attributeId">The name of the attribute.</param> |
| 80 | + /// <param name="value">The value to set.</param> |
| 81 | + /// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns> |
45 | 82 | public bool TrySetInt16(string attributeId, short value)
|
46 | 83 | {
|
47 | 84 | return TrySetInt64(attributeId, value);
|
48 | 85 | }
|
49 | 86 |
|
| 87 | + /// <summary> |
| 88 | + /// Tries to get a value for the specified attribute. |
| 89 | + /// </summary> |
| 90 | + /// <param name="attributeId">The name of the attribute.</param> |
| 91 | + /// <param name="value">The value to get.</param> |
| 92 | + /// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns> |
50 | 93 | public bool TryGetInt16(string attributeId, out short value)
|
51 | 94 | {
|
52 | 95 | var result = TryGetInt64(attributeId, out var intValue);
|
53 | 96 | value = (short)intValue;
|
54 | 97 | return result;
|
55 | 98 | }
|
56 | 99 |
|
| 100 | + /// <summary> |
| 101 | + /// Tries to set a value for the specified attribute. |
| 102 | + /// </summary> |
| 103 | + /// <param name="attributeId">The name of the attribute.</param> |
| 104 | + /// <param name="value">The value to set.</param> |
| 105 | + /// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns> |
57 | 106 | public bool TrySetUInt16(string attributeId, ushort value)
|
58 | 107 | {
|
59 | 108 | return TrySetInt64(attributeId, value);
|
60 | 109 | }
|
61 | 110 |
|
| 111 | + /// <summary> |
| 112 | + /// Tries to get a value for the specified attribute. |
| 113 | + /// </summary> |
| 114 | + /// <param name="attributeId">The name of the attribute.</param> |
| 115 | + /// <param name="value">The value to get.</param> |
| 116 | + /// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns> |
62 | 117 | public bool TryGetUInt16(string attributeId, out ushort value)
|
63 | 118 | {
|
64 | 119 | var result = TryGetInt64(attributeId, out var intValue);
|
65 | 120 | value = (ushort)intValue;
|
66 | 121 | return result;
|
67 | 122 | }
|
68 | 123 |
|
| 124 | + /// <summary> |
| 125 | + /// Tries to set a value for the specified attribute. |
| 126 | + /// </summary> |
| 127 | + /// <param name="attributeId">The name of the attribute.</param> |
| 128 | + /// <param name="value">The value to set.</param> |
| 129 | + /// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns> |
69 | 130 | public bool TrySetUInt32(string attributeId, uint value)
|
70 | 131 | {
|
71 | 132 | return TrySetInt64(attributeId, value);
|
72 | 133 | }
|
73 | 134 |
|
| 135 | + /// <summary> |
| 136 | + /// Tries to get a value for the specified attribute. |
| 137 | + /// </summary> |
| 138 | + /// <param name="attributeId">The name of the attribute.</param> |
| 139 | + /// <param name="value">The value to get.</param> |
| 140 | + /// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns> |
74 | 141 | public bool TryGetUInt32(string attributeId, out uint value)
|
75 | 142 | {
|
76 | 143 | var result = TryGetInt64(attributeId, out var intValue);
|
77 | 144 | value = unchecked((uint)intValue);
|
78 | 145 | return result;
|
79 | 146 | }
|
80 | 147 |
|
| 148 | + /// <summary> |
| 149 | + /// Tries to set a value for the specified attribute. |
| 150 | + /// </summary> |
| 151 | + /// <param name="attributeId">The name of the attribute.</param> |
| 152 | + /// <param name="value">The value to set.</param> |
| 153 | + /// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns> |
81 | 154 | public bool TrySetInt32(string attributeId, int value)
|
82 | 155 | {
|
83 | 156 | return TrySetInt64(attributeId, value);
|
84 | 157 | }
|
85 | 158 |
|
| 159 | + /// <summary> |
| 160 | + /// Tries to get a value for the specified attribute. |
| 161 | + /// </summary> |
| 162 | + /// <param name="attributeId">The name of the attribute.</param> |
| 163 | + /// <param name="value">The value to get.</param> |
| 164 | + /// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns> |
86 | 165 | public bool TryGetInt32(string attributeId, out int value)
|
87 | 166 | {
|
88 | 167 | var result = TryGetInt64(attributeId, out var intValue);
|
89 | 168 | value = unchecked((int)intValue);
|
90 | 169 | return result;
|
91 | 170 | }
|
92 | 171 |
|
| 172 | + /// <summary> |
| 173 | + /// Tries to set a value for the specified attribute. |
| 174 | + /// </summary> |
| 175 | + /// <param name="attributeId">The name of the attribute.</param> |
| 176 | + /// <param name="value">The value to set.</param> |
| 177 | + /// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns> |
93 | 178 | public bool TrySetFloat32(string attributeId, float value)
|
94 | 179 | {
|
95 | 180 | return TrySetFloat64(attributeId, value);
|
96 | 181 | }
|
97 | 182 |
|
| 183 | + /// <summary> |
| 184 | + /// Tries to get a value for the specified attribute. |
| 185 | + /// </summary> |
| 186 | + /// <param name="attributeId">The name of the attribute.</param> |
| 187 | + /// <param name="value">The value to get.</param> |
| 188 | + /// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns> |
98 | 189 | public bool TryGetFloat32(string attributeId, out float value)
|
99 | 190 | {
|
100 | 191 | var result = TryGetFloat64(attributeId, out var doubleValue);
|
101 | 192 | value = (float)doubleValue;
|
102 | 193 | return result;
|
103 | 194 | }
|
104 | 195 |
|
| 196 | + /// <summary> |
| 197 | + /// Tries to set a value for the specified attribute. |
| 198 | + /// </summary> |
| 199 | + /// <param name="attributeId">The name of the attribute.</param> |
| 200 | + /// <param name="value">The value to set.</param> |
| 201 | + /// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns> |
105 | 202 | public bool TrySetInt64(string attributeId, long value)
|
106 | 203 | {
|
107 | 204 | return GetSafeBackend().TrySetInt64(this, attributeId, value);
|
108 | 205 | }
|
109 | 206 |
|
| 207 | + /// <summary> |
| 208 | + /// Tries to get a value for the specified attribute. |
| 209 | + /// </summary> |
| 210 | + /// <param name="attributeId">The name of the attribute.</param> |
| 211 | + /// <param name="value">The value to get.</param> |
| 212 | + /// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns> |
110 | 213 | public bool TryGetInt64(string attributeId, out long value)
|
111 | 214 | {
|
112 | 215 | return GetSafeBackend().TryGetInt64(this, attributeId, out value);
|
113 | 216 | }
|
114 | 217 |
|
| 218 | + /// <summary> |
| 219 | + /// Tries to set a value for the specified attribute. |
| 220 | + /// </summary> |
| 221 | + /// <param name="attributeId">The name of the attribute.</param> |
| 222 | + /// <param name="value">The value to set.</param> |
| 223 | + /// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns> |
115 | 224 | public bool TrySetFloat64(string attributeId, double value)
|
116 | 225 | {
|
117 | 226 | return GetSafeBackend().TrySetFloat64(this, attributeId, value);
|
118 | 227 | }
|
119 | 228 |
|
| 229 | + /// <summary> |
| 230 | + /// Tries to get a value for the specified attribute. |
| 231 | + /// </summary> |
| 232 | + /// <param name="attributeId">The name of the attribute.</param> |
| 233 | + /// <param name="value">The value to get.</param> |
| 234 | + /// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns> |
120 | 235 | public bool TryGetFloat64(string attributeId, out double value)
|
121 | 236 | {
|
122 | 237 | return GetSafeBackend().TryGetFloat64(this, attributeId, out value);
|
123 | 238 | }
|
124 | 239 |
|
| 240 | + /// <summary> |
| 241 | + /// Tries to set a value for the specified attribute. |
| 242 | + /// </summary> |
| 243 | + /// <param name="attributeId">The name of the attribute.</param> |
| 244 | + /// <param name="value">The value to set.</param> |
| 245 | + /// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns> |
125 | 246 | public bool TrySetString(string attributeId, string value)
|
126 | 247 | {
|
127 | 248 | return GetSafeBackend().TrySetString(this, attributeId, value);
|
128 | 249 | }
|
129 | 250 |
|
| 251 | + /// <summary> |
| 252 | + /// Tries to get a value for the specified attribute. |
| 253 | + /// </summary> |
| 254 | + /// <param name="attributeId">The name of the attribute.</param> |
| 255 | + /// <param name="value">The value to get.</param> |
| 256 | + /// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns> |
130 | 257 | public bool TryGetString(string attributeId, out string value)
|
131 | 258 | {
|
132 | 259 | return GetSafeBackend().TryGetString(this, attributeId, out value);
|
133 | 260 | }
|
134 | 261 |
|
| 262 | + /// <summary> |
| 263 | + /// Tries to set a value for the specified attribute. |
| 264 | + /// </summary> |
| 265 | + /// <param name="attributeId">The name of the attribute.</param> |
| 266 | + /// <param name="value">The value to set.</param> |
| 267 | + /// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns> |
135 | 268 | public bool TrySetBinary(string attributeId, ReadOnlySpan<byte> value)
|
136 | 269 | {
|
137 | 270 | return GetSafeBackend().TrySetBinary(this, attributeId, value);
|
138 | 271 | }
|
139 | 272 |
|
| 273 | + /// <summary> |
| 274 | + /// Tries to get a value for the specified attribute. |
| 275 | + /// </summary> |
| 276 | + /// <param name="attributeId">The name of the attribute.</param> |
| 277 | + /// <param name="value">The value to get.</param> |
| 278 | + /// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns> |
140 | 279 | [UnscopedRef]
|
141 | 280 | public bool TryGetBinary(string attributeId, out ReadOnlySpan<byte> value)
|
142 | 281 | {
|
|
0 commit comments