/// <summary> /// Creates a new instance of the Accelerometer object. /// </summary> public Accelerometer() { if (instanceCount >= MaxSensorCount) throw new SensorFailedException("The limit of 10 simultaneous instances of the Accelerometer class per application has been exceeded."); ++instanceCount; state = sensor != null ? SensorState.Initializing : SensorState.NotSupported; listener = new SensorListener(); }
/// <summary> /// Creates a new instance of the Compass object. /// </summary> public Compass() { if (instanceCount >= MaxSensorCount) { throw new SensorFailedException("The limit of 10 simultaneous instances of the Compass class per application has been exceeded."); } ++instanceCount; state = sensorMagneticField != null ? SensorState.Initializing : SensorState.NotSupported; listener = new SensorListener(); }
public Accelerometer() { if (!IsSupported) { throw new AccelerometerFailedException("Failed to start accelerometer data acquisition. No default sensor found.", -1); } else if (instanceCount >= MaxSensorCount) { throw new SensorFailedException(string.Format("The limit of {0} simultaneous instances of the Accelerometer class per application has been exceeded.", MaxSensorCount)); } ++instanceCount; #if ANDROID state = sensor != null ? SensorState.Initializing : SensorState.NotSupported; listener = new SensorListener(); #elif iOS this.TimeBetweenUpdatesChanged += this.UpdateInterval; readingChanged += ReadingChangedHandler; #endif }