namespace Tizen.Maps
{
/// <summary>
- /// Place Category information, used in Place Discovery and Search requests
+ /// Place category information, used in place discovery and search requests.
/// </summary>
- public class PlaceCategory
+ /// <since_tizen> 3 </since_tizen>
+ public class PlaceCategory : IDisposable
{
internal Interop.PlaceCategoryHandle handle;
- protected string _id;
- protected string _name;
- protected string _url;
/// <summary>
- /// Constructs search category object
+ /// Constructs a search category object.
/// </summary>
- /// <exception cref="System.InvalidOperationException">Throws if native operation failed to allocate memory</exception>
+ /// <since_tizen> 3 </since_tizen>
+ /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory.</exception>
public PlaceCategory()
{
- IntPtr nativeHandle;
- var err = Interop.PlaceCategory.Create(out nativeHandle);
- err.ThrowIfFailed("Failed to create native handle for Place Category");
+ handle = new Interop.PlaceCategoryHandle();
+ }
- handle = new Interop.PlaceCategoryHandle(nativeHandle);
+ internal PlaceCategory(Interop.PlaceCategoryHandle nativeHandle)
+ {
+ handle = nativeHandle;
}
- internal PlaceCategory(IntPtr nativeHandle)
+ /// <summary>
+ /// Destroy the PlaceCategory object.
+ /// </summary>
+ ~PlaceCategory()
{
- handle = new Interop.PlaceCategoryHandle(nativeHandle);
- Initialize();
+ Dispose(false);
}
/// <summary>
- /// ID for this category
+ /// Gets or sets an ID for this category.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Id
{
- get
- {
- return _id;
- }
- set
- {
- var err = Interop.PlaceCategory.SetId(handle, value);
- if (err.WarnIfFailed("Failed to set id for place category"))
- {
- _id = value;
- }
- }
+ get { return handle.Id; }
+ set { handle.Id = value; }
}
/// <summary>
- /// Name for this category
+ /// Gets or sets a name for this category.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Name
{
- get
- {
- return _name;
- }
- set
- {
- var err = Interop.PlaceCategory.SetName(handle, value);
- if (err.WarnIfFailed("Failed to set name for place category"))
- {
- _name = value;
- }
- }
+ get { return handle.Name; }
+ set { handle.Name = value; }
}
/// <summary>
- /// URL for this category
+ /// Gets or sets a URL for this category.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Url
{
- get
- {
- return _url;
- }
- set
+ get { return handle.Url; }
+ set { handle.Url = value; }
+ }
+
+ /// <summary>
+ /// Returns a string that represents this object.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <returns>Returns a string which presents this object.</returns>
+ public override string ToString()
+ {
+ return $"{Name}";
+ }
+
+ #region IDisposable Support
+ private bool _disposedValue = false;
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
+ /// <since_tizen> 3 </since_tizen>
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposedValue)
{
- var err = Interop.PlaceCategory.SetUrl(handle, value);
- if (err.WarnIfFailed("Failed to set URL for place category"))
- {
- _url = value;
- }
+ handle?.Dispose();
+ _disposedValue = true;
}
}
- internal void Initialize()
+ /// <summary>
+ /// Releases all the resources used by this object.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public void Dispose()
{
- Interop.PlaceCategory.GetId(handle, out _id);
- Interop.PlaceCategory.GetName(handle, out _name);
- Interop.PlaceCategory.GetUrl(handle, out _url);
+ Dispose(true);
+ GC.SuppressFinalize(this);
}
+ #endregion
}
}