2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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.
19 namespace Tizen.Location.Geofence
22 /// The geofence status describes the current state and duration of a geofence.
23 /// <list type="bullet">
24 /// <item><description>State: The state is specified by the current state of the fence.</description></item>
25 /// <item><description>Duration: Geofence is specified by the duration of the current state.</description></item>
28 /// <since_tizen> 3 </since_tizen>
29 public class FenceStatus : IDisposable
31 private bool _disposed = false;
33 internal IntPtr Handle
40 /// Creates a new geofence status.
42 /// <since_tizen> 3 </since_tizen>
43 /// <param name="fenceId">The geofence ID.</param>
44 /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
45 /// <exception cref="NotSupportedException">In case of geofence is not supported.</exception>
46 public FenceStatus(int fenceId)
49 GeofenceError ret = (GeofenceError)Interop.GeofenceStatus.Create(fenceId, out handle);
50 if (ret != GeofenceError.None)
52 throw GeofenceErrorFactory.CreateException(ret, "Failed to create Geofence Status instance");
59 /// The destructor of the FenceStatus class.
61 /// <since_tizen> 3 </since_tizen>
68 /// Gets the state of geofence.
70 /// <since_tizen> 3 </since_tizen>
71 /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception>
72 public GeofenceState State
77 GeofenceError ret = (GeofenceError)Interop.GeofenceStatus.State(Handle, out state);
78 if (ret != GeofenceError.None)
80 Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get FenceState");
88 /// Gets the amount of seconds, the geofence is in the current state.
90 /// <since_tizen> 3 </since_tizen>
91 /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception>
97 GeofenceError ret = (GeofenceError)Interop.GeofenceStatus.Duration(Handle, out result);
98 if (ret != GeofenceError.None)
100 Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get FenceDuration");
108 /// The overloaded Dispose API for destroying the fence handle.
110 /// <since_tizen> 3 </since_tizen>
111 public void Dispose()
114 GC.SuppressFinalize(this);
120 /// <since_tizen> 3 </since_tizen>
121 protected virtual void Dispose(bool disposing)
126 if (Handle != IntPtr.Zero)
128 Interop.GeofenceStatus.Destroy(Handle);
129 Handle = IntPtr.Zero;