Ejemplo n.º 1
0
        public HorusDriverInstanceSummary CreateDriverInstance(ISession session, string device, string driverName, string interfaceName)
        {
            if (string.Equals(interfaceName, "ICamera", StringComparison.InvariantCultureIgnoreCase))
            {
                HorusDeviceSummary summary = session.LocalHorusSession.EnumDevices<ICamera>()
                            .FirstOrDefault(x =>
                                string.Equals(x.DeviceName, device, StringComparison.CurrentCultureIgnoreCase) &&
                                string.Equals(x.DeviceDriver.DriverName, driverName, StringComparison.CurrentCultureIgnoreCase));

                HorusCamera camera = session.LocalHorusSession.CreateCameraInstance(summary);
                string objectId = Guid.NewGuid().ToString();

                session.AddSessionObject(objectId, camera);

                return new HorusDriverInstanceSummary(objectId);
            }
            else if (string.Equals(interfaceName, "IVideo", StringComparison.InvariantCultureIgnoreCase))
            {
                HorusDeviceSummary summary = session.LocalHorusSession.EnumDevices<IVideo>()
                            .FirstOrDefault(x =>
                                string.Equals(x.DeviceName, device, StringComparison.CurrentCultureIgnoreCase) &&
                                string.Equals(x.DeviceDriver.DriverName, driverName, StringComparison.CurrentCultureIgnoreCase));

                HorusVideo video = session.LocalHorusSession.CreateVideoInstance(summary);
                string objectId = Guid.NewGuid().ToString();
                session.AddSessionObject(objectId, video);

                return new HorusDriverInstanceSummary(objectId);
            }

            return null;
        }