1 /// Copyright 2016 by Samsung Electronics, Inc.,
3 /// This software is the confidential and proprietary information
4 /// of Samsung Electronics, Inc. ("Confidential Information"). You
5 /// shall not disclose such Confidential Information and shall use
6 /// it only in accordance with the terms of the license agreement
7 /// you entered into with Samsung.
10 using System.Collections;
11 using System.Collections.Generic;
12 using System.Runtime.InteropServices;
14 namespace Tizen.Network.IoTConnectivity
17 /// This class represents current attributes of a resource.
18 /// It provides API to manage attributes.
19 /// This class is accessed by using a constructor to create a new instance of this object.
21 public class Attributes : IDictionary<string, object>, IDisposable
23 internal IntPtr _resourceAttributesHandle = IntPtr.Zero;
24 private readonly IDictionary<string, object> _attributes = new Dictionary<string, object>();
25 private bool _disposed = false;
28 /// The Attributes constructor
31 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
35 int ret = Interop.IoTConnectivity.Common.Attributes.Create(out _resourceAttributesHandle);
36 if (ret != (int)IoTConnectivityError.None)
38 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create attributes handle");
39 throw IoTConnectivityErrorFactory.GetException(ret);
43 internal Attributes(IntPtr attributesHandleToClone)
45 int ret = Interop.IoTConnectivity.Common.Attributes.Clone(attributesHandleToClone, out _resourceAttributesHandle);
46 if (ret != (int)IoTConnectivityError.None)
48 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create attributes handle");
49 throw IoTConnectivityErrorFactory.GetException(ret);
52 SetAttributes(attributesHandleToClone);
56 /// Destructor of the Attributes class.
64 /// Gets the number of keys
67 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
68 /// attributes.Add("brightness", 50);
69 /// var count = attributes.Count;
70 /// Console.WriteLine("There are {0} keys in the attribute object", count);
76 return _attributes.Count;
81 /// Represents whether attribute is readonly
84 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
85 /// { "state", "ON" },
88 /// if (attributes.IsReadOnly)
89 /// Console.WriteLine("Read only attribute");
91 public bool IsReadOnly
95 return _attributes.IsReadOnly;
100 /// Contains all the attribute keys
103 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
104 /// { "state", "ON" },
107 /// var keys = attributes.Keys;
108 /// Console.WriteLine("Attribute contains keys {0} and {1}", keys.ElementAt(0), keys.ElementAt(1));
110 public ICollection<string> Keys
114 return _attributes.Keys;
119 /// Contains all the attribute values
122 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
123 /// { "state", "ON" },
126 /// var values = attributes.Values;
127 /// Console.WriteLine("Attribute contains values {0} and {1}", values.ElementAt(0), values.ElementAt(1));
129 public ICollection<object> Values
133 return _attributes.Values;
138 /// Gets or sets the attribute with the specified key.
140 /// <param name="key">The key of the attribute to get or set.</param>
141 /// <returns>The element with the specified key.</returns>
143 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
144 /// attributes["state"] = "ON";
145 /// Console.WriteLine("Attribute value for key 'state' : {0}", attributes["state"]);
147 public object this[string key]
151 if (_attributes.ContainsKey(key))
152 return _attributes[key];
164 /// Adds attribute key and value as a key value pair
166 /// <param name="item">The key value pair to add</param>
168 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
169 /// attributes.Add(new KeyValuePair<string, object> ("state", "ON"));
171 public void Add(KeyValuePair<string, object> item)
173 Add(item.Key, item.Value);
177 /// Adds an attribute
179 /// <param name="key">The key representing the attribute</param>
180 /// <param name="value">The value representing the attribute</param>
182 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
183 /// attributes.Add("brightness", 50);
185 public void Add(string key, object value)
190 ret = Interop.IoTConnectivity.Common.Attributes.AddInt(_resourceAttributesHandle, key, (int)value);
191 if (ret != (int)IoTConnectivityError.None)
193 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add int");
194 throw IoTConnectivityErrorFactory.GetException(ret);
197 else if (value is Attributes)
199 Attributes attribs = (Attributes)value;
200 ret = Interop.IoTConnectivity.Common.Attributes.AddAttributes(_resourceAttributesHandle, key, attribs._resourceAttributesHandle);
201 if (ret != (int)IoTConnectivityError.None)
203 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
204 throw IoTConnectivityErrorFactory.GetException(ret);
207 else if (value is string)
209 ret = Interop.IoTConnectivity.Common.Attributes.AddStr(_resourceAttributesHandle, key, (string)value);
210 if (ret != (int)IoTConnectivityError.None)
212 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add string");
213 throw IoTConnectivityErrorFactory.GetException(ret);
216 else if (value is double)
218 ret = Interop.IoTConnectivity.Common.Attributes.AddDouble(_resourceAttributesHandle, key, (double)value);
219 if (ret != (int)IoTConnectivityError.None)
221 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add double");
222 throw IoTConnectivityErrorFactory.GetException(ret);
225 else if (value is bool)
227 ret = Interop.IoTConnectivity.Common.Attributes.AddBool(_resourceAttributesHandle, key, (bool)value);
228 if (ret != (int)IoTConnectivityError.None)
230 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add bool");
231 throw IoTConnectivityErrorFactory.GetException(ret);
234 else if (value is byte[])
236 byte[] val = value as byte[];
239 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get byte[] val");
240 throw new ArgumentException("Invalid Parameter");
242 ret = Interop.IoTConnectivity.Common.Attributes.AddByteStr(_resourceAttributesHandle, key, val, val.Length);
243 if (ret != (int)IoTConnectivityError.None)
245 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add bool");
246 throw IoTConnectivityErrorFactory.GetException(ret);
249 else if (value is IEnumerable)
251 IntPtr listHandle = List.GetListHandle(value);
252 ret = Interop.IoTConnectivity.Common.Attributes.AddList(_resourceAttributesHandle, key, listHandle);
253 if (ret != (int)IoTConnectivityError.None)
255 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add list");
256 throw IoTConnectivityErrorFactory.GetException(ret);
261 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Add");
262 throw IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.InvalidParameter);
264 _attributes.Add(key, value);
268 /// Clears attributes collection
271 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
272 /// attributes.Add("brightness", 50);
273 /// attributes.Clear();
277 foreach (string key in _attributes.Keys)
279 int ret = Interop.IoTConnectivity.Common.Attributes.Remove(_resourceAttributesHandle, key);
280 if (ret != (int)IoTConnectivityError.None)
282 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to clear attributes");
283 throw IoTConnectivityErrorFactory.GetException(ret);
290 /// Checks whether the given key value pair exists in attributes collection
292 /// <param name="item">The status key value pair</param>
293 /// <returns>true if exists. Otherwise, false</returns>
295 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
296 /// { "state", "ON" },
299 /// if (attributes.Contains(new KeyValuePair<string, object> ("dim", 10))
300 /// Console.WriteLine("Attribute conatins pair ('dim', 10)");
302 public bool Contains(KeyValuePair<string, object> item)
304 return _attributes.Contains(item);
308 /// Checks whether the given key exists in attributes collection
310 /// <param name="key">The status key to look for</param>
311 /// <returns>true if exists. Otherwise, false</returns>
313 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
314 /// { "state", "ON" },
317 /// if (attributes.ContainsKey("dim"))
318 /// Console.WriteLine("Attribute conatins key : dim");
320 public bool ContainsKey(string key)
322 return _attributes.ContainsKey(key);
326 /// Copies the elements of the attributes to an array, starting at a particular index.
328 /// <param name="array">The destination array</param>
329 /// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
331 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
332 /// { "state", "ON" },
335 /// KeyValuePair<string, object>[] dest = new KeyValuePair<string, object>[attributes.Count];
337 /// attributes.CopyTo(dest, index);
338 /// Console.WriteLine("Dest conatins ({0}, {1})", dest[0].Key, dest[0].Value);
340 public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
342 _attributes.CopyTo(array, arrayIndex);
346 /// Returns an enumerator that iterates through the collection.
348 /// <returns> An enumerator that can be used to iterate through the collection.</returns>
350 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
351 /// { "state", "ON" },
354 /// foreach (KeyValuePair<string, object> pair in attributes)
356 /// Console.WriteLine("key : {0}, value : {1}", pair.Key, pair.Value);
359 public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
361 return _attributes.GetEnumerator();
365 /// Removes an attribute from collection
367 /// <param name="item">The attributes element to remove</param>
368 /// <returns>true if operation is success. Otherwise, false</returns>
370 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
371 /// { "state", "ON" },
374 /// if (attributes.Remove(new KeyValuePair<string, object>("dim", 10)))
375 /// Console.WriteLine("Remove was successful");
377 public bool Remove(KeyValuePair<string, object> item)
379 return Remove(item.Key);
383 /// Removes an attribute from collection using key
385 /// <param name="key">The attributes element to remove</param>
386 /// <returns>true if operation is successful, Otherwise, false</returns>
388 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
389 /// { "state", "ON" },
392 /// if (attributes.Remove("state"))
393 /// Console.WriteLine("Remove was successful");
395 public bool Remove(string key)
397 bool isRemoved = _attributes.Remove(key);
400 int ret = Interop.IoTConnectivity.Common.Attributes.Remove(_resourceAttributesHandle, key);
401 if (ret != (int)IoTConnectivityError.None)
403 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove attributes");
404 throw IoTConnectivityErrorFactory.GetException(ret);
412 /// Gets the value associated with the specified key.
414 /// <param name="key">The key whose value to get.</param>
415 /// <param name="value"> The value associated with the specified key</param>
416 /// <returns> true if the attributes collection contains an element with the specified key; otherwise, false.</returns>
418 /// Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
419 /// { "state", "ON" }
422 /// var isPresent = attributes.TryGetValue("state", out value);
424 /// Console.WriteLine("value : {0}", value);
426 public bool TryGetValue(string key, out object value)
428 return _attributes.TryGetValue(key, out value);
432 /// Returns an enumerator that iterates through the collection.
434 IEnumerator IEnumerable.GetEnumerator()
436 return _attributes.GetEnumerator();
440 /// Releases any unmanaged resources used by this object.
442 public void Dispose()
445 GC.SuppressFinalize(this);
449 /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
451 /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
452 protected virtual void Dispose(bool disposing)
459 // Free managed objects
462 Interop.IoTConnectivity.Common.Attributes.Destroy(_resourceAttributesHandle);
466 private void SetAttributes(IntPtr attributesHandle)
468 Interop.IoTConnectivity.Common.Attributes.AttributesCallback cb = (IntPtr attributes, string key, IntPtr userData) =>
470 Interop.IoTConnectivity.Common.DataType dataType;
471 int ret = Interop.IoTConnectivity.Common.Attributes.GetType(attributes, key, out dataType);
472 if (ret != (int)IoTConnectivityError.None)
474 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get type");
475 throw IoTConnectivityErrorFactory.GetException(ret);
478 switch ((Interop.IoTConnectivity.Common.DataType)dataType)
480 case Interop.IoTConnectivity.Common.DataType.Int:
483 ret = Interop.IoTConnectivity.Common.Attributes.GetInt(attributes, key, out value);
484 if (ret != (int)IoTConnectivityError.None)
486 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
487 throw IoTConnectivityErrorFactory.GetException(ret);
492 case Interop.IoTConnectivity.Common.DataType.Bool:
495 ret = Interop.IoTConnectivity.Common.Attributes.GetBool(attributes, key, out value);
496 if (ret != (int)IoTConnectivityError.None)
498 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
499 throw IoTConnectivityErrorFactory.GetException(ret);
504 case Interop.IoTConnectivity.Common.DataType.Double:
507 ret = Interop.IoTConnectivity.Common.Attributes.GetDouble(attributes, key, out value);
508 if (ret != (int)IoTConnectivityError.None)
510 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
511 throw IoTConnectivityErrorFactory.GetException(ret);
516 case Interop.IoTConnectivity.Common.DataType.String:
519 ret = Interop.IoTConnectivity.Common.Attributes.GetStr(attributes, key, out value);
520 if (ret != (int)IoTConnectivityError.None)
522 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
523 throw IoTConnectivityErrorFactory.GetException(ret);
528 case Interop.IoTConnectivity.Common.DataType.ByteStr:
532 ret = Interop.IoTConnectivity.Common.Attributes.GetByteStr(attributes, key, out byteStrPtr, out byteStrSize);
533 if (ret != (int)IoTConnectivityError.None)
535 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
536 throw IoTConnectivityErrorFactory.GetException(ret);
538 byte[] byteStr = new byte[byteStrSize];
539 Marshal.Copy(byteStrPtr, byteStr, 0, byteStrSize);
543 case Interop.IoTConnectivity.Common.DataType.Null:
548 case Interop.IoTConnectivity.Common.DataType.List:
551 ret = Interop.IoTConnectivity.Common.Attributes.GetList(attributes, key, out listHandle);
552 if (ret != (int)IoTConnectivityError.None)
554 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
555 throw IoTConnectivityErrorFactory.GetException(ret);
557 Add(key, List.GetList(listHandle));
560 case Interop.IoTConnectivity.Common.DataType.Attributes:
562 IntPtr attribsHandle;
563 ret = Interop.IoTConnectivity.Common.Attributes.GetAttributes(attributes, key, out attribsHandle);
564 if (ret != (int)IoTConnectivityError.None)
566 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
567 throw IoTConnectivityErrorFactory.GetException(ret);
569 Add(key, new Attributes(attribsHandle));
579 int res = Interop.IoTConnectivity.Common.Attributes.Foreach(attributesHandle, cb, IntPtr.Zero);
580 if (res != (int)IoTConnectivityError.None)
582 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove attributes");
583 throw IoTConnectivityErrorFactory.GetException(res);
588 internal static class List
590 internal static IntPtr GetListHandle(object list)
592 IntPtr listHandle = IntPtr.Zero;
596 if (list is IEnumerable<IEnumerable>)
598 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.List, out listHandle);
600 foreach (IEnumerable val in (IEnumerable<IEnumerable>)list)
602 IntPtr childList = GetListHandle(val);
603 ret = Interop.IoTConnectivity.Common.List.AddList(listHandle, childList, pos++);
604 if (ret != (int)IoTConnectivityError.None)
606 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
607 Interop.IoTConnectivity.Common.List.Destroy(childList);
608 throw IoTConnectivityErrorFactory.GetException(ret);
612 else if (list is IEnumerable<int>)
614 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Int, out listHandle);
616 foreach (int val in (IEnumerable<int>)list)
618 ret = Interop.IoTConnectivity.Common.List.AddInt(listHandle, val, pos++);
619 if (ret != (int)IoTConnectivityError.None)
621 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
622 throw IoTConnectivityErrorFactory.GetException(ret);
626 else if (list is IEnumerable<string>)
628 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.String, out listHandle);
630 foreach (string val in (IEnumerable<string>)list)
632 ret = Interop.IoTConnectivity.Common.List.AddStr(listHandle, val, pos++);
633 if (ret != (int)IoTConnectivityError.None)
635 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add str");
636 throw IoTConnectivityErrorFactory.GetException(ret);
640 else if (list is IEnumerable<double>)
642 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Double, out listHandle);
644 foreach (double val in (IEnumerable<double>)list)
646 ret = Interop.IoTConnectivity.Common.List.AddDouble(listHandle, val, pos++);
647 if (ret != (int)IoTConnectivityError.None)
649 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add double");
650 throw IoTConnectivityErrorFactory.GetException(ret);
654 else if (list is IEnumerable<bool>)
656 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Bool, out listHandle);
658 foreach (bool val in (IEnumerable<bool>)list)
660 ret = Interop.IoTConnectivity.Common.List.AddBool(listHandle, val, pos++);
661 if (ret != (int)IoTConnectivityError.None)
663 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add bool");
664 throw IoTConnectivityErrorFactory.GetException(ret);
668 else if (list is IEnumerable<Attributes>)
670 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Attributes, out listHandle);
672 foreach (Attributes val in (IEnumerable<Attributes>)list)
674 ret = Interop.IoTConnectivity.Common.List.AddAttributes(listHandle, val._resourceAttributesHandle, pos++);
675 if (ret != (int)IoTConnectivityError.None)
677 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add attributes");
678 throw IoTConnectivityErrorFactory.GetException(ret);
682 else if (list is IEnumerable<byte[]>)
684 ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.ByteStr, out listHandle);
686 foreach (byte[] val in (IEnumerable<byte[]>)list)
688 ret = Interop.IoTConnectivity.Common.List.AddByteStr(listHandle, val, val.Length, pos++);
689 if (ret != (int)IoTConnectivityError.None)
691 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add byte[]");
692 throw IoTConnectivityErrorFactory.GetException(ret);
698 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to GetListHandle");
699 throw IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.InvalidParameter);
704 internal static object GetList(IntPtr listHandle)
708 int ret = Interop.IoTConnectivity.Common.List.GetType(listHandle, out type);
709 if (ret != (int)IoTConnectivityError.None)
711 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get type");
712 throw IoTConnectivityErrorFactory.GetException(ret);
714 switch ((Interop.IoTConnectivity.Common.DataType)type)
716 case Interop.IoTConnectivity.Common.DataType.Int:
718 list = new List<int>();
719 Interop.IoTConnectivity.Common.List.IntCallback cb = (int pos, int value, IntPtr userData) =>
724 ret = Interop.IoTConnectivity.Common.List.ForeachInt(listHandle, cb, IntPtr.Zero);
727 case Interop.IoTConnectivity.Common.DataType.Bool:
729 list = new List<bool>();
730 Interop.IoTConnectivity.Common.List.BoolCallback cb = (int pos, bool value, IntPtr userData) =>
735 ret = Interop.IoTConnectivity.Common.List.ForeachBool(listHandle, cb, IntPtr.Zero);
738 case Interop.IoTConnectivity.Common.DataType.Double:
740 list = new List<double>();
741 Interop.IoTConnectivity.Common.List.DoubleCallback cb = (int pos, double value, IntPtr userData) =>
746 ret = Interop.IoTConnectivity.Common.List.ForeachDouble(listHandle, cb, IntPtr.Zero);
749 case Interop.IoTConnectivity.Common.DataType.String:
751 list = new List<string>();
752 Interop.IoTConnectivity.Common.List.StrCallback cb = (int pos, string value, IntPtr userData) =>
757 ret = Interop.IoTConnectivity.Common.List.ForeachStr(listHandle, cb, IntPtr.Zero);
760 case Interop.IoTConnectivity.Common.DataType.Attributes:
762 list = new List<Attributes>();
763 Interop.IoTConnectivity.Common.List.AttribsCallback cb = (int pos, IntPtr value, IntPtr userData) =>
765 list.Add(new Attributes(value));
768 ret = Interop.IoTConnectivity.Common.List.ForeachAttributes(listHandle, cb, IntPtr.Zero);
771 case Interop.IoTConnectivity.Common.DataType.ByteStr:
773 list = new List<byte[]>();
774 Interop.IoTConnectivity.Common.List.ByteStrCallback cb = (int pos, byte[] value, int len, IntPtr userData) =>
779 ret = Interop.IoTConnectivity.Common.List.ForeachByteStr(listHandle, cb, IntPtr.Zero);
782 case Interop.IoTConnectivity.Common.DataType.List:
784 list = new List<List<object>>();
785 Interop.IoTConnectivity.Common.List.ListCallback cb = (int pos, IntPtr value, IntPtr userData) =>
787 object childList = GetList(value);
791 ret = Interop.IoTConnectivity.Common.List.ForeachList(listHandle, cb, IntPtr.Zero);
797 if (ret != (int)IoTConnectivityError.None)
799 Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes");
800 throw IoTConnectivityErrorFactory.GetException(ret);