Example #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            SmartPlugConnection smartPlugConnection = new SmartPlugConnection();

            smartPlugConnection.Open();

            EmeterEntityRepository           emeterEntityRepository           = new EmeterEntityRepository(smartPlugConnection);
            HtSensorEntityRepository         htSensorEntityRepository         = new HtSensorEntityRepository(smartPlugConnection);
            DoorWindowSensorEntityRepository doorWindowSensorEntityRepository = new DoorWindowSensorEntityRepository(smartPlugConnection);
            WeatherEntityRepository          weatherEntityRepository          = new WeatherEntityRepository(smartPlugConnection);

            services.AddSingleton(emeterEntityRepository);
            services.AddSingleton(htSensorEntityRepository);
            services.AddSingleton(doorWindowSensorEntityRepository);
            services.AddSingleton(weatherEntityRepository);
        }
 public SensorController(HtSensorEntityRepository htSensorEntityRepository, DoorWindowSensorEntityRepository doorWindowSensorEntityRepository)
 {
     this.htSensorEntityRepository         = htSensorEntityRepository;
     this.doorWindowSensorEntityRepository = doorWindowSensorEntityRepository;
 }