Tizen.Maps Setup
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / PlaceCategory.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18
19 namespace Tizen.Maps
20 {
21     /// <summary>
22     /// Place Category information, used in Place Discovery and Search requests
23     /// </summary>
24     public class PlaceCategory
25     {
26         internal Interop.PlaceCategoryHandle handle;
27         protected string _id;
28         protected string _name;
29         protected string _url;
30
31         /// <summary>
32         /// Constructs search category object
33         /// </summary>
34         /// <exception cref="System.InvalidOperationException">Throws if native operation failed to allocate memory</exception>
35         public PlaceCategory()
36         {
37             IntPtr nativeHandle;
38             var err = Interop.PlaceCategory.Create(out nativeHandle);
39             err.ThrowIfFailed("Failed to create native handle for Place Category");
40
41             handle = new Interop.PlaceCategoryHandle(nativeHandle);
42         }
43
44         internal PlaceCategory(IntPtr nativeHandle)
45         {
46             handle = new Interop.PlaceCategoryHandle(nativeHandle);
47             Initialize();
48         }
49
50         /// <summary>
51         /// ID for this category
52         /// </summary>
53         public string Id
54         {
55             get
56             {
57                 return _id;
58             }
59             set
60             {
61                 var err = Interop.PlaceCategory.SetId(handle, value);
62                 if (err.WarnIfFailed("Failed to set id for place category"))
63                 {
64                     _id = value;
65                 }
66             }
67         }
68
69         /// <summary>
70         /// Name for this category
71         /// </summary>
72         public string Name
73         {
74             get
75             {
76                 return _name;
77             }
78             set
79             {
80                 var err = Interop.PlaceCategory.SetName(handle, value);
81                 if (err.WarnIfFailed("Failed to set name for place category"))
82                 {
83                     _name = value;
84                 }
85             }
86         }
87
88         /// <summary>
89         /// URL for this category
90         /// </summary>
91         public string Url
92         {
93             get
94             {
95                 return _url;
96             }
97             set
98             {
99                 var err = Interop.PlaceCategory.SetUrl(handle, value);
100                 if (err.WarnIfFailed("Failed to set URL for place category"))
101                 {
102                     _url = value;
103                 }
104             }
105         }
106
107         internal void Initialize()
108         {
109             var err = Interop.PlaceCategory.GetId(handle, out _id);
110             err.WarnIfFailed("Failed to get id for place category");
111
112             err = Interop.PlaceCategory.GetName(handle, out _name);
113             err.WarnIfFailed("Failed to get name for place category");
114
115             err = Interop.PlaceCategory.GetUrl(handle, out _url);
116             err.WarnIfFailed("Failed to get URL for place category");
117         }
118     }
119 }