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);
71 /// The operator to access the element with the specified index key.<br />
72 /// If an element with the key does not exist, then it is created.<br />
74 /// <param name="key">The key whose value to access.</param>
75 /// <returns>A value for the element with the specified key.</returns>
76 /// <since_tizen> 3 </since_tizen>
77 public PropertyValue this[int key]
81 return ValueOfIndex(key);
90 /// Retrieves the number of elements in the map.
92 /// <returns>The number of elements in the map.</returns>
93 /// <since_tizen> 3 </since_tizen>
96 uint ret = Interop.PropertyMap.Property_Map_Count(swigCPtr);
97 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102 /// Returns whether the map is empty.
104 /// <returns>Returns true if empty, false otherwise.</returns>
105 /// <since_tizen> 3 </since_tizen>
108 bool ret = Interop.PropertyMap.Property_Map_Empty(swigCPtr);
109 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114 /// Inserts the key-value pair in the map, with the key type as string.<br />
115 /// Does not check for duplicates.<br />
117 /// <param name="key">The key to insert.</param>
118 /// <param name="value">The value to insert.</param>
119 /// <since_tizen> 3 </since_tizen>
120 public void Insert(string key, PropertyValue value)
122 Interop.PropertyMap.Property_Map_Insert__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value));
123 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127 /// Inserts the key-value pair in the map, with the key type as index.<br />
128 /// Does not check for duplicates.<br />
130 /// <param name="key">The key to insert.</param>
131 /// <param name="value">The value to insert.</param>
132 /// <since_tizen> 3 </since_tizen>
133 public void Insert(int key, PropertyValue value)
135 Interop.PropertyMap.Property_Map_Insert__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value));
136 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140 /// Inserts the key-value pair in the map, with the key type as string.<br />
141 /// Does not check for duplicates.<br />
143 /// <param name="key">The key to insert.</param>
144 /// <param name="value">The value to insert.</param>
145 /// <returns>Returns a reference to this object.</returns>
146 /// <since_tizen> 3 </since_tizen>
147 public PropertyMap Add(string key, PropertyValue value)
149 PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value)), false);
150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155 /// Inserts the key-value pair in the map, with the key type as string.<br />
156 /// Does not check for duplicates.<br />
158 /// <param name="key">The key to insert.</param>
159 /// <param name="value">The value to insert.</param>
160 /// <returns>Returns a reference to this object.</returns>
161 /// <since_tizen> 3 </since_tizen>
162 public PropertyMap Add(int key, PropertyValue value)
164 PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value)), false);
165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170 /// Inserts the keyvalue to the map.<br />
171 /// Does not check for duplicates.<br />
173 /// <param name="keyValue">The keyvalue to insert.</param>
174 /// <returns>Returns a reference to this object.</returns>
175 public PropertyMap Add(KeyValue keyValue)
177 PropertyMap ret = new PropertyMap();
178 if ( keyValue.KeyInt != null )
180 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, (int)keyValue.KeyInt, PropertyValue.getCPtr(keyValue.TrueValue)), false);
182 else if ( keyValue.KeyString != null )
184 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, keyValue.KeyString, PropertyValue.getCPtr(keyValue.TrueValue)), false);
186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192 /// Retrieves the value at the specified position.
194 /// <param name="position">The specified position.</param>
195 /// <returns>A reference to the value at the specified position.</returns>
196 /// <since_tizen> 3 </since_tizen>
197 public PropertyValue GetValue(uint position)
199 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_GetValue(swigCPtr, position), false);
200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205 /// Retrieves the key at the specified position.
207 /// <param name="position">The specified position.</param>
208 /// <returns>A copy of the key at the specified position.</returns>
209 /// <since_tizen> 3 </since_tizen>
210 public PropertyKey GetKeyAt(uint position)
212 PropertyKey ret = new PropertyKey(Interop.PropertyMap.Property_Map_GetKeyAt(swigCPtr, position), true);
213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218 /// Finds the value for the specified key if it exists.
220 /// <param name="key">The key to find.</param>
221 /// <returns>The value if it exists, an empty object otherwise.</returns>
222 /// <since_tizen> 3 </since_tizen>
223 public PropertyValue Find(int key)
225 global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_2(swigCPtr, key);
226 PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
227 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 /// Finds the value for the specified keys if either exist.
234 /// <param name="indexKey">The index key to find.</param>
235 /// <param name="stringKey">The string key to find.</param>
236 /// <returns>The value if it exists, an empty object otherwise.</returns>
237 /// <since_tizen> 3 </since_tizen>
238 public PropertyValue Find(int indexKey, string stringKey)
240 global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_3(swigCPtr, indexKey, stringKey);
241 PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249 /// <since_tizen> 3 </since_tizen>
252 Interop.PropertyMap.Property_Map_Clear(swigCPtr);
253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257 /// Merges values from the map 'from' to the current.<br />
258 /// Any values in 'from' will overwrite the values in the current map.<br />
260 /// <param name="from">The map to merge from.</param>
261 /// <since_tizen> 3 </since_tizen>
262 public void Merge(PropertyMap from)
264 Interop.PropertyMap.Property_Map_Merge(swigCPtr, PropertyMap.getCPtr(from));
265 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269 /// Retrieves the element with the specified string key.
271 /// <param name="key">The key whose value to retrieve.</param>
272 /// <returns>The value for the element with the specified key.</returns>
273 internal PropertyValue ValueOfIndex(string key)
275 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_0(swigCPtr, key), false);
276 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
281 /// Retrieves the element with the specified index key.
283 /// <param name="key">The key whose value to retrieve.</param>
284 /// <returns>The value for the element with the specified key.</returns>
285 internal PropertyValue ValueOfIndex(int key)
287 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_2(swigCPtr, key), false);
288 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyMap obj)
294 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
297 internal void SetValue(int key, PropertyValue value)
299 Interop.PropertyMap.Property_Map_SetValue_IntKey(swigCPtr, key, PropertyValue.getCPtr(value));
300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303 internal void SetValue(string key, PropertyValue value)
305 Interop.PropertyMap.Property_Map_SetValue_StringKey(swigCPtr, key, PropertyValue.getCPtr(value));
306 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309 /// This will not be public opened.
310 [EditorBrowsable(EditorBrowsableState.Never)]
311 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
313 Interop.PropertyMap.delete_Property_Map(swigCPtr);