Example #1
0
        public GeofenceBuilder ThenSetGeocircle(IGeoshape geocricle)
        {
            if (geocricle.GeoshapeType != GeoshapeType.Geocircle)
            {
                throw new ArgumentException($"{nameof(GeofenceBuilder)} can use only {nameof(Geocircle)} as {nameof(IGeoshape)}");
            }

            _geoshape = geocricle as Geocircle;
            return(this);
        }
Example #2
0
 public Geofence(string id, IGeoshape geoshape, MonitoredGeofenceStates monitoredStates, bool singleUse, TimeSpan dwellTime, DateTimeOffset startTime, TimeSpan duration)
 {
     Duration        = duration;
     DwellTime       = dwellTime;
     Geoshape        = geoshape;
     Id              = id;
     MonitoredStates = monitoredStates;
     SingleUse       = singleUse;
     StartTime       = startTime;
 }
Example #3
0
        /// <summary>
        /// Initializes a new Geofence object given the id and the shape of the geofence.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="geoshape"></param>
        public Geofence(string id, IGeoshape geoshape)
        {
#if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE
            _fence = new Windows.Devices.Geolocation.Geofencing.Geofence(id, (Windows.Devices.Geolocation.Geocircle)((Geocircle)geoshape));
#elif __UNIFIED__
            _shape = (Geocircle)geoshape;

            if(_shape.Radius > GeofenceMonitor.Current.maxRegion)
            {
                throw new PlatformNotSupportedException("Geofence Radius is greater than the maximum supported on this platform");
            }

            _region = new CLCircularRegion(new CLLocationCoordinate2D(_shape.Center.Latitude, _shape.Center.Longitude), _shape.Radius, id);
#else
                throw new PlatformNotSupportedException();
#endif
        }
Example #4
0
        /// <summary>
        /// Initializes a new Geofence object given the id and the shape of the geofence.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="geoshape"></param>
        public Geofence(string id, IGeoshape geoshape)
        {
#if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE
            _fence = new Windows.Devices.Geolocation.Geofencing.Geofence(id, (Windows.Devices.Geolocation.Geocircle)((Geocircle)geoshape));
#elif __UNIFIED__
            _shape = (Geocircle)geoshape;
            if (_shape.Radius > GeofenceMonitor.Current.maxRegion)
            {
                throw new PlatformNotSupportedException("Geofence Radius is greater than the maximum supported on this platform");
            }

            if (id != _shape.Id)
            {
                // replace with correctly named CLRegion
                _shape = new CLCircularRegion(new CLLocationCoordinate2D(_shape.Center.Latitude, _shape.Center.Longitude), _shape.Radius, id);
            }
#elif TIZEN
            _id    = id;
            _shape = ((Geocircle)geoshape);
#else
            throw new PlatformNotSupportedException();
#endif
        }
Example #5
0
 public Geofence(string id, IGeoshape geoshape, MonitoredGeofenceStates monitoredStates, bool singleUse, TimeSpan dwellTime)
     : this(id, geoshape, monitoredStates, singleUse, dwellTime, new DateTimeOffset(1601, 1, 1, 0, 0, 0, TimeSpan.FromSeconds(0)), TimeSpan.FromSeconds(0))
 {
 }
Example #6
0
 public Geofence(string id, IGeoshape geoshape, MonitoredGeofenceStates monitoredStates, bool singleUse)
     : this(id, geoshape, monitoredStates, singleUse, TimeSpan.FromSeconds(10))
 {
 }
Example #7
0
 public Geofence(string id, IGeoshape geoshape)
     : this(id, geoshape, MonitoredGeofenceStates.Entered | MonitoredGeofenceStates.Exited, false)
 {
 }