2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System.ComponentModel;
22 /// A map of property values, the key type could be string or Property::Index.
24 /// <since_tizen> 3 </since_tizen>
25 public class PropertyMap : Disposable
31 /// <since_tizen> 3 </since_tizen>
32 public PropertyMap() : this(Interop.PropertyMap.new_Property_Map__SWIG_0(), true)
34 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
38 /// The copy constructor.
40 /// <param name="other">The map to copy from.</param>
41 /// <since_tizen> 3 </since_tizen>
42 public PropertyMap(PropertyMap other) : this(Interop.PropertyMap.new_Property_Map__SWIG_1(PropertyMap.getCPtr(other)), true)
44 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
47 internal PropertyMap(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
52 /// The operator to access the element with the specified string key.<br />
53 /// If an element with the key does not exist, then it is created.<br />
55 /// <param name="key">The key whose value to access.</param>
56 /// <returns>A value for the element with the specified key.</returns>
57 /// <since_tizen> 3 </since_tizen>
58 public PropertyValue this[string key]
62 return ValueOfIndex(key);
67 /// The operator to access the element with the specified index key.<br />
68 /// If an element with the key does not exist, then it is created.<br />
70 /// <param name="key">The key whose value to access.</param>
71 /// <returns>A value for the element with the specified key.</returns>
72 /// <since_tizen> 3 </since_tizen>
73 public PropertyValue this[int key]
77 return ValueOfIndex(key);
82 /// Retrieves the number of elements in the map.
84 /// <returns>The number of elements in the map.</returns>
85 /// <since_tizen> 3 </since_tizen>
88 uint ret = Interop.PropertyMap.Property_Map_Count(swigCPtr);
89 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
94 /// Returns whether the map is empty.
96 /// <returns>Returns true if empty, false otherwise.</returns>
97 /// <since_tizen> 3 </since_tizen>
100 bool ret = Interop.PropertyMap.Property_Map_Empty(swigCPtr);
101 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106 /// Inserts the key-value pair in the map, with the key type as string.<br />
107 /// Does not check for duplicates.<br />
109 /// <param name="key">The key to insert.</param>
110 /// <param name="value">The value to insert.</param>
111 /// <since_tizen> 3 </since_tizen>
112 public void Insert(string key, PropertyValue value)
114 Interop.PropertyMap.Property_Map_Insert__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value));
115 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119 /// Inserts the key-value pair in the map, with the key type as index.<br />
120 /// Does not check for duplicates.<br />
122 /// <param name="key">The key to insert.</param>
123 /// <param name="value">The value to insert.</param>
124 /// <since_tizen> 3 </since_tizen>
125 public void Insert(int key, PropertyValue value)
127 Interop.PropertyMap.Property_Map_Insert__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value));
128 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132 /// Inserts the key-value pair in the map, with the key type as string.<br />
133 /// Does not check for duplicates.<br />
135 /// <param name="key">The key to insert.</param>
136 /// <param name="value">The value to insert.</param>
137 /// <returns>Returns a reference to this object.</returns>
138 /// <since_tizen> 3 </since_tizen>
139 public PropertyMap Add(string key, PropertyValue value)
141 PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value)), false);
142 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147 /// Inserts the key-value pair in the map, with the key type as string.<br />
148 /// Does not check for duplicates.<br />
150 /// <param name="key">The key to insert.</param>
151 /// <param name="value">The value to insert.</param>
152 /// <returns>Returns a reference to this object.</returns>
153 /// <since_tizen> 3 </since_tizen>
154 public PropertyMap Add(int key, PropertyValue value)
156 PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value)), false);
157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 /// Inserts the keyvalue to the map.<br />
163 /// Does not check for duplicates.<br />
165 /// <param name="keyValue">The keyvalue to insert.</param>
166 /// <returns>Returns a reference to this object.</returns>
167 public PropertyMap Add(KeyValue keyValue)
169 PropertyMap ret = new PropertyMap();
170 if ( keyValue.KeyInt != null )
172 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, (int)keyValue.KeyInt, PropertyValue.getCPtr(keyValue.TrueValue)), false);
174 else if ( keyValue.KeyString != null )
176 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, keyValue.KeyString, PropertyValue.getCPtr(keyValue.TrueValue)), false);
178 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 /// Retrieves the value at the specified position.
186 /// <param name="position">The specified position.</param>
187 /// <returns>A reference to the value at the specified position.</returns>
188 /// <since_tizen> 3 </since_tizen>
189 public PropertyValue GetValue(uint position)
191 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_GetValue(swigCPtr, position), false);
192 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197 /// Retrieves the key at the specified position.
199 /// <param name="position">The specified position.</param>
200 /// <returns>A copy of the key at the specified position.</returns>
201 /// <since_tizen> 3 </since_tizen>
202 public PropertyKey GetKeyAt(uint position)
204 PropertyKey ret = new PropertyKey(Interop.PropertyMap.Property_Map_GetKeyAt(swigCPtr, position), true);
205 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210 /// Finds the value for the specified key if it exists.
212 /// <param name="key">The key to find.</param>
213 /// <returns>The value if it exists, an empty object otherwise.</returns>
214 /// <since_tizen> 3 </since_tizen>
215 public PropertyValue Find(int key)
217 global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_2(swigCPtr, key);
218 PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224 /// Finds the value for the specified keys if either exist.
226 /// <param name="indexKey">The index key to find.</param>
227 /// <param name="stringKey">The string key to find.</param>
228 /// <returns>The value if it exists, an empty object otherwise.</returns>
229 /// <since_tizen> 3 </since_tizen>
230 public PropertyValue Find(int indexKey, string stringKey)
232 global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_3(swigCPtr, indexKey, stringKey);
233 PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241 /// <since_tizen> 3 </since_tizen>
244 Interop.PropertyMap.Property_Map_Clear(swigCPtr);
245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249 /// Merges values from the map 'from' to the current.<br />
250 /// Any values in 'from' will overwrite the values in the current map.<br />
252 /// <param name="from">The map to merge from.</param>
253 /// <since_tizen> 3 </since_tizen>
254 public void Merge(PropertyMap from)
256 Interop.PropertyMap.Property_Map_Merge(swigCPtr, PropertyMap.getCPtr(from));
257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261 /// Retrieves the element with the specified string key.
263 /// <param name="key">The key whose value to retrieve.</param>
264 /// <returns>The value for the element with the specified key.</returns>
265 internal PropertyValue ValueOfIndex(string key)
267 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_0(swigCPtr, key), false);
268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273 /// Retrieves the element with the specified index key.
275 /// <param name="key">The key whose value to retrieve.</param>
276 /// <returns>The value for the element with the specified key.</returns>
277 internal PropertyValue ValueOfIndex(int key)
279 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_2(swigCPtr, key), false);
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyMap obj)
286 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
289 /// This will not be public opened.
290 [EditorBrowsable(EditorBrowsableState.Never)]
291 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
293 Interop.PropertyMap.delete_Property_Map(swigCPtr);