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.
24 /// <item>State: The state is specified by the current state of the fence.</item>
25 /// <item>Duration: Geofence is specified by the duration of the current state.</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 /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
44 /// <exception cref="NotSupportedException">In case of geofence is not supported.</exception>
45 public FenceStatus(int fenceId)
48 GeofenceError ret = (GeofenceError)Interop.GeofenceStatus.Create(fenceId, out handle);
49 if (ret != GeofenceError.None)
51 throw GeofenceErrorFactory.CreateException(ret, "Failed to create Geofence Status instance");
63 /// Gets the state of geofence.
65 /// <since_tizen> 3 </since_tizen>
66 /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception>
67 public GeofenceState State
72 GeofenceError ret = (GeofenceError)Interop.GeofenceStatus.State(Handle, out state);
73 if (ret != GeofenceError.None)
75 Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get FenceState");
83 /// Gets the amount of seconds, the geofence is in the current state.
85 /// <since_tizen> 3 </since_tizen>
86 /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception>
92 GeofenceError ret = (GeofenceError)Interop.GeofenceStatus.Duration(Handle, out result);
93 if (ret != GeofenceError.None)
95 Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get FenceDuration");
103 /// The overloaded Dispose API for destroying the fence handle.
105 /// <since_tizen> 3 </since_tizen>
106 public void Dispose()
109 GC.SuppressFinalize(this);
112 private void Dispose(bool disposing)
117 if (Handle != IntPtr.Zero)
119 Interop.GeofenceStatus.Destroy(Handle);
120 Handle = IntPtr.Zero;