1 /// Copyright 2016 by Samsung Electronics, Inc.,
4 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 using System.Collections;
22 using System.Collections.Generic;
23 using System.Runtime.InteropServices;
25 namespace Tizen.Network.IoTConnectivity
28 /// This class represents current attributes of a resource.
29 /// It provides API to manage attributes.
30 /// This class is accessed by using a constructor to create a new instance of this object.
32 public class Attributes : IDictionary<string, object>, IDisposable
34 internal IntPtr _resourceAttributesHandle = IntPtr.Zero;
35 private readonly IDictionary<string, object> _attributes = new Dictionary<string, object>();
36 private bool _disposed = false;
39 /// The Attributes constructor
42 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
46 int ret = Interop.IoTConnectivity.Common.Attributes.Create(out _resourceAttributesHandle);
47 if (ret != (int)IoTConnectivityError.None)
49 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create attributes handle");
50 throw IoTConnectivityErrorFactory.GetException(ret);
54 internal Attributes(IntPtr attributesHandleToClone)
56 int ret = Interop.IoTConnectivity.Common.Attributes.Clone(attributesHandleToClone, out _resourceAttributesHandle);
57 if (ret != (int)IoTConnectivityError.None)
59 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create attributes handle");
60 throw IoTConnectivityErrorFactory.GetException(ret);
63 SetAttributes(attributesHandleToClone);
67 /// Destructor of the Attributes class.
75 /// Gets the number of keys
78 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
79 /// attributes.Add("brightness", 50);
80 /// var count = attributes.Count;
81 /// Console.WriteLine("There are {0} keys in the attribute object", count);
87 return _attributes.Count;
92 /// Represents whether attribute is readonly
95 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
96 /// { "state", "ON" },
99 /// if (attributes.IsReadOnly)
100 /// Console.WriteLine("Read only attribute");
102 public bool IsReadOnly
106 return _attributes.IsReadOnly;
111 /// Contains all the attribute keys
114 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
115 /// { "state", "ON" },
118 /// var keys = attributes.Keys;
119 /// Console.WriteLine("Attribute contains keys {0} and {1}", keys.ElementAt(0), keys.ElementAt(1));
121 public ICollection<string> Keys
125 return _attributes.Keys;
130 /// Contains all the attribute values
133 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
134 /// { "state", "ON" },
137 /// var values = attributes.Values;
138 /// Console.WriteLine("Attribute contains values {0} and {1}", values.ElementAt(0), values.ElementAt(1));
140 public ICollection<object> Values
144 return _attributes.Values;
149 /// Gets or sets the attribute with the specified key.
151 /// <param name="key">The key of the attribute to get or set.</param>
152 /// <returns>The element with the specified key.</returns>
154 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
155 /// attributes["state"] = "ON";
156 /// Console.WriteLine("Attribute value for key 'state' : {0}", attributes["state"]);
158 public object this[string key]
162 if (_attributes.ContainsKey(key))
163 return _attributes[key];
175 /// Adds attribute key and value as a key value pair
177 /// <param name="item">The key value pair to add</param>
179 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
180 /// attributes.Add(new KeyValuePair<string, object> ("state", "ON"));
182 public void Add(KeyValuePair<string, object> item)
184 Add(item.Key, item.Value);
188 /// Adds an attribute
190 /// <param name="key">The key representing the attribute</param>
191 /// <param name="value">The value representing the attribute</param>
193 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
194 /// attributes.Add("brightness", 50);
196 public void Add(string key, object value)
201 ret = Interop.IoTConnectivity.Common.Attributes.AddInt(_resourceAttributesHandle, key, (int)value);
202 if (ret != (int)IoTConnectivityError.None)
204 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add int");
205 throw IoTConnectivityErrorFactory.GetException(ret);
208 else if (value is Attributes)
210 Attributes attribs = (Attributes)value;
211 ret = Interop.IoTConnectivity.Common.Attributes.AddAttributes(_resourceAttributesHandle, key, attribs._resourceAttributesHandle);
212 if (ret != (int)IoTConnectivityError.None)
214 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
215 throw IoTConnectivityErrorFactory.GetException(ret);
218 else if (value is string)
220 ret = Interop.IoTConnectivity.Common.Attributes.AddStr(_resourceAttributesHandle, key, (string)value);
221 if (ret != (int)IoTConnectivityError.None)
223 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add string");
224 throw IoTConnectivityErrorFactory.GetException(ret);
227 else if (value is double)
229 ret = Interop.IoTConnectivity.Common.Attributes.AddDouble(_resourceAttributesHandle, key, (double)value);
230 if (ret != (int)IoTConnectivityError.None)
232 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add double");
233 throw IoTConnectivityErrorFactory.GetException(ret);
236 else if (value is bool)
238 ret = Interop.IoTConnectivity.Common.Attributes.AddBool(_resourceAttributesHandle, key, (bool)value);
239 if (ret != (int)IoTConnectivityError.None)
241 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add bool");
242 throw IoTConnectivityErrorFactory.GetException(ret);
245 else if (value is byte[])
247 byte[] val = value as byte[];
250 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get byte[] val");
251 throw new ArgumentException("Invalid Parameter");
253 ret = Interop.IoTConnectivity.Common.Attributes.AddByteStr(_resourceAttributesHandle, key, val, val.Length);
254 if (ret != (int)IoTConnectivityError.None)
256 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add bool");
257 throw IoTConnectivityErrorFactory.GetException(ret);
260 else if (value is IEnumerable)
262 IntPtr listHandle = List.GetListHandle(value);
263 ret = Interop.IoTConnectivity.Common.Attributes.AddList(_resourceAttributesHandle, key, listHandle);
264 if (ret != (int)IoTConnectivityError.None)
266 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add list");
267 throw IoTConnectivityErrorFactory.GetException(ret);
272 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Add");
273 throw IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.InvalidParameter);
275 _attributes.Add(key, value);
279 /// Clears attributes collection
282 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
283 /// attributes.Add("brightness", 50);
284 /// attributes.Clear();
288 foreach (string key in _attributes.Keys)
290 int ret = Interop.IoTConnectivity.Common.Attributes.Remove(_resourceAttributesHandle, key);
291 if (ret != (int)IoTConnectivityError.None)
293 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to clear attributes");
294 throw IoTConnectivityErrorFactory.GetException(ret);
301 /// Checks whether the given key value pair exists in attributes collection
303 /// <param name="item">The status key value pair</param>
304 /// <returns>true if exists. Otherwise, false</returns>
306 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
307 /// { "state", "ON" },
310 /// if (attributes.Contains(new KeyValuePair<string, object> ("dim", 10))
311 /// Console.WriteLine("Attribute conatins pair ('dim', 10)");
313 public bool Contains(KeyValuePair<string, object> item)
315 return _attributes.Contains(item);
319 /// Checks whether the given key exists in attributes collection
321 /// <param name="key">The status key to look for</param>
322 /// <returns>true if exists. Otherwise, false</returns>
324 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
325 /// { "state", "ON" },
328 /// if (attributes.ContainsKey("dim"))
329 /// Console.WriteLine("Attribute conatins key : dim");
331 public bool ContainsKey(string key)
333 return _attributes.ContainsKey(key);
337 /// Copies the elements of the attributes to an array, starting at a particular index.
339 /// <param name="array">The destination array</param>
340 /// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
342 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
343 /// { "state", "ON" },
346 /// KeyValuePair<string, object>[] dest = new KeyValuePair<string, object>[attributes.Count];
348 /// attributes.CopyTo(dest, index);
349 /// Console.WriteLine("Dest conatins ({0}, {1})", dest[0].Key, dest[0].Value);
351 public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
353 _attributes.CopyTo(array, arrayIndex);
357 /// Returns an enumerator that iterates through the collection.
359 /// <returns> An enumerator that can be used to iterate through the collection.</returns>
361 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
362 /// { "state", "ON" },
365 /// foreach (KeyValuePair<string, object> pair in attributes)
367 /// Console.WriteLine("key : {0}, value : {1}", pair.Key, pair.Value);
370 public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
372 return _attributes.GetEnumerator();
376 /// Removes an attribute from collection
378 /// <param name="item">The attributes element to remove</param>
379 /// <returns>true if operation is success. Otherwise, false</returns>
381 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
382 /// { "state", "ON" },
385 /// if (attributes.Remove(new KeyValuePair<string, object>("dim", 10)))
386 /// Console.WriteLine("Remove was successful");
388 public bool Remove(KeyValuePair<string, object> item)
390 return Remove(item.Key);
394 /// Removes an attribute from collection using key
396 /// <param name="key">The attributes element to remove</param>
397 /// <returns>true if operation is successful, Otherwise, false</returns>
399 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
400 /// { "state", "ON" },
403 /// if (attributes.Remove("state"))
404 /// Console.WriteLine("Remove was successful");
406 public bool Remove(string key)
408 bool isRemoved = _attributes.Remove(key);
411 int ret = Interop.IoTConnectivity.Common.Attributes.Remove(_resourceAttributesHandle, key);
412 if (ret != (int)IoTConnectivityError.None)
414 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove attributes");
415 throw IoTConnectivityErrorFactory.GetException(ret);
423 /// Gets the value associated with the specified key.
425 /// <param name="key">The key whose value to get.</param>
426 /// <param name="value"> The value associated with the specified key</param>
427 /// <returns> true if the attributes collection contains an element with the specified key; otherwise, false.</returns>
429 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
430 /// { "state", "ON" }
433 /// var isPresent = attributes.TryGetValue("state", out value);
435 /// Console.WriteLine("value : {0}", value);
437 public bool TryGetValue(string key, out object value)
439 return _attributes.TryGetValue(key, out value);
443 /// Returns an enumerator that iterates through the collection.
445 IEnumerator IEnumerable.GetEnumerator()
447 return _attributes.GetEnumerator();
451 /// Releases any unmanaged resources used by this object.
453 public void Dispose()
456 GC.SuppressFinalize(this);
460 /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
462 /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
463 protected virtual void Dispose(bool disposing)
470 // Free managed objects
473 Interop.IoTConnectivity.Common.Attributes.Destroy(_resourceAttributesHandle);
477 private void SetAttributes(IntPtr attributesHandle)
479 Interop.IoTConnectivity.Common.Attributes.AttributesCallback cb = (IntPtr attributes, string key, IntPtr userData) =>
481 Interop.IoTConnectivity.Common.DataType dataType;
482 int ret = Interop.IoTConnectivity.Common.Attributes.GetType(attributes, key, out dataType);
483 if (ret != (int)IoTConnectivityError.None)
485 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get type");
486 throw IoTConnectivityErrorFactory.GetException(ret);
489 switch ((Interop.IoTConnectivity.Common.DataType)dataType)
491 case Interop.IoTConnectivity.Common.DataType.Int:
494 ret = Interop.IoTConnectivity.Common.Attributes.GetInt(attributes, key, out value);
495 if (ret != (int)IoTConnectivityError.None)
497 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
498 throw IoTConnectivityErrorFactory.GetException(ret);
503 case Interop.IoTConnectivity.Common.DataType.Bool:
506 ret = Interop.IoTConnectivity.Common.Attributes.GetBool(attributes, key, out value);
507 if (ret != (int)IoTConnectivityError.None)
509 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
510 throw IoTConnectivityErrorFactory.GetException(ret);
515 case Interop.IoTConnectivity.Common.DataType.Double:
518 ret = Interop.IoTConnectivity.Common.Attributes.GetDouble(attributes, key, out value);
519 if (ret != (int)IoTConnectivityError.None)
521 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
522 throw IoTConnectivityErrorFactory.GetException(ret);
527 case Interop.IoTConnectivity.Common.DataType.String:
530 ret = Interop.IoTConnectivity.Common.Attributes.GetStr(attributes, key, out value);
531 if (ret != (int)IoTConnectivityError.None)
533 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
534 throw IoTConnectivityErrorFactory.GetException(ret);
539 case Interop.IoTConnectivity.Common.DataType.ByteStr:
543 ret = Interop.IoTConnectivity.Common.Attributes.GetByteStr(attributes, key, out byteStrPtr, out byteStrSize);
544 if (ret != (int)IoTConnectivityError.None)
546 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
547 throw IoTConnectivityErrorFactory.GetException(ret);
549 byte[] byteStr = new byte[byteStrSize];
550 Marshal.Copy(byteStrPtr, byteStr, 0, byteStrSize);
554 case Interop.IoTConnectivity.Common.DataType.Null:
559 case Interop.IoTConnectivity.Common.DataType.List:
562 ret = Interop.IoTConnectivity.Common.Attributes.GetList(attributes, key, out listHandle);
563 if (ret != (int)IoTConnectivityError.None)
565 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
566 throw IoTConnectivityErrorFactory.GetException(ret);
568 Add(key, List.GetList(listHandle));
571 case Interop.IoTConnectivity.Common.DataType.Attributes:
573 IntPtr attribsHandle;
574 ret = Interop.IoTConnectivity.Common.Attributes.GetAttributes(attributes, key, out attribsHandle);
575 if (ret != (int)IoTConnectivityError.None)
577 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
578 throw IoTConnectivityErrorFactory.GetException(ret);
580 Add(key, new Attributes(attribsHandle));
590 int res = Interop.IoTConnectivity.Common.Attributes.Foreach(attributesHandle, cb, IntPtr.Zero);
591 if (res != (int)IoTConnectivityError.None)
593 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove attributes");
594 throw IoTConnectivityErrorFactory.GetException(res);
599 internal static class List
601 internal static IntPtr GetListHandle(object list)
603 IntPtr listHandle = IntPtr.Zero;
607 if (list is IEnumerable<IEnumerable>)
609 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.List, out listHandle);
611 foreach (IEnumerable val in (IEnumerable<IEnumerable>)list)
613 IntPtr childList = GetListHandle(val);
614 ret = Interop.IoTConnectivity.Common.List.AddList(listHandle, childList, pos++);
615 if (ret != (int)IoTConnectivityError.None)
617 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
618 Interop.IoTConnectivity.Common.List.Destroy(childList);
619 throw IoTConnectivityErrorFactory.GetException(ret);
623 else if (list is IEnumerable<int>)
625 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Int, out listHandle);
627 foreach (int val in (IEnumerable<int>)list)
629 ret = Interop.IoTConnectivity.Common.List.AddInt(listHandle, val, pos++);
630 if (ret != (int)IoTConnectivityError.None)
632 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
633 throw IoTConnectivityErrorFactory.GetException(ret);
637 else if (list is IEnumerable<string>)
639 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.String, out listHandle);
641 foreach (string val in (IEnumerable<string>)list)
643 ret = Interop.IoTConnectivity.Common.List.AddStr(listHandle, val, pos++);
644 if (ret != (int)IoTConnectivityError.None)
646 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add str");
647 throw IoTConnectivityErrorFactory.GetException(ret);
651 else if (list is IEnumerable<double>)
653 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Double, out listHandle);
655 foreach (double val in (IEnumerable<double>)list)
657 ret = Interop.IoTConnectivity.Common.List.AddDouble(listHandle, val, pos++);
658 if (ret != (int)IoTConnectivityError.None)
660 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add double");
661 throw IoTConnectivityErrorFactory.GetException(ret);
665 else if (list is IEnumerable<bool>)
667 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Bool, out listHandle);
669 foreach (bool val in (IEnumerable<bool>)list)
671 ret = Interop.IoTConnectivity.Common.List.AddBool(listHandle, val, pos++);
672 if (ret != (int)IoTConnectivityError.None)
674 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add bool");
675 throw IoTConnectivityErrorFactory.GetException(ret);
679 else if (list is IEnumerable<Attributes>)
681 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Attributes, out listHandle);
683 foreach (Attributes val in (IEnumerable<Attributes>)list)
685 ret = Interop.IoTConnectivity.Common.List.AddAttributes(listHandle, val._resourceAttributesHandle, pos++);
686 if (ret != (int)IoTConnectivityError.None)
688 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
689 throw IoTConnectivityErrorFactory.GetException(ret);
693 else if (list is IEnumerable<byte[]>)
695 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.ByteStr, out listHandle);
697 foreach (byte[] val in (IEnumerable<byte[]>)list)
699 ret = Interop.IoTConnectivity.Common.List.AddByteStr(listHandle, val, val.Length, pos++);
700 if (ret != (int)IoTConnectivityError.None)
702 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add byte[]");
703 throw IoTConnectivityErrorFactory.GetException(ret);
709 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to GetListHandle");
710 throw IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.InvalidParameter);
715 internal static object GetList(IntPtr listHandle)
719 int ret = Interop.IoTConnectivity.Common.List.GetType(listHandle, out type);
720 if (ret != (int)IoTConnectivityError.None)
722 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get type");
723 throw IoTConnectivityErrorFactory.GetException(ret);
725 switch ((Interop.IoTConnectivity.Common.DataType)type)
727 case Interop.IoTConnectivity.Common.DataType.Int:
729 list = new List<int>();
730 Interop.IoTConnectivity.Common.List.IntCallback cb = (int pos, int value, IntPtr userData) =>
735 ret = Interop.IoTConnectivity.Common.List.ForeachInt(listHandle, cb, IntPtr.Zero);
738 case Interop.IoTConnectivity.Common.DataType.Bool:
740 list = new List<bool>();
741 Interop.IoTConnectivity.Common.List.BoolCallback cb = (int pos, bool value, IntPtr userData) =>
746 ret = Interop.IoTConnectivity.Common.List.ForeachBool(listHandle, cb, IntPtr.Zero);
749 case Interop.IoTConnectivity.Common.DataType.Double:
751 list = new List<double>();
752 Interop.IoTConnectivity.Common.List.DoubleCallback cb = (int pos, double value, IntPtr userData) =>
757 ret = Interop.IoTConnectivity.Common.List.ForeachDouble(listHandle, cb, IntPtr.Zero);
760 case Interop.IoTConnectivity.Common.DataType.String:
762 list = new List<string>();
763 Interop.IoTConnectivity.Common.List.StrCallback cb = (int pos, string value, IntPtr userData) =>
768 ret = Interop.IoTConnectivity.Common.List.ForeachStr(listHandle, cb, IntPtr.Zero);
771 case Interop.IoTConnectivity.Common.DataType.Attributes:
773 list = new List<Attributes>();
774 Interop.IoTConnectivity.Common.List.AttribsCallback cb = (int pos, IntPtr value, IntPtr userData) =>
776 list.Add(new Attributes(value));
779 ret = Interop.IoTConnectivity.Common.List.ForeachAttributes(listHandle, cb, IntPtr.Zero);
782 case Interop.IoTConnectivity.Common.DataType.ByteStr:
784 list = new List<byte[]>();
785 Interop.IoTConnectivity.Common.List.ByteStrCallback cb = (int pos, byte[] value, int len, IntPtr userData) =>
790 ret = Interop.IoTConnectivity.Common.List.ForeachByteStr(listHandle, cb, IntPtr.Zero);
793 case Interop.IoTConnectivity.Common.DataType.List:
795 list = new List<List<object>>();
796 Interop.IoTConnectivity.Common.List.ListCallback cb = (int pos, IntPtr value, IntPtr userData) =>
798 object childList = GetList(value);
799 if (childList != null)
803 ret = Interop.IoTConnectivity.Common.List.ForeachList(listHandle, cb, IntPtr.Zero);
809 if (ret != (int)IoTConnectivityError.None)
811 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
812 throw IoTConnectivityErrorFactory.GetException(ret);