/// <summary> /// Returns the type of input requested or raises Exception /// </summary> /// <param name="type"></param> /// <param name="buffermode"></param> /// <returns></returns> /// <exception cref="Exception"></exception> public T CreateInputObject <T>(bool bufferMode, string vendor) where T : InputObject { InputObject obj = null; foreach (InputObjectFactory factory in this._factories) { if (factory.FreeDeviceCount <T>() > 0) { if (vendor == null || vendor == String.Empty || factory.VendorExists <T>(vendor)) { obj = factory.CreateInputObject <T>(this, bufferMode, vendor); if (obj != null) { this._createdInputObjects.Add(obj, factory); break; } } } } if (obj == null) { throw new Exception("No devices match requested type."); } try { obj.Initialize(); } catch (Exception e) { obj.Dispose(); obj = null; throw e; //rethrow } return((T)obj); }
void InputObjectFactory.DestroyInputObject(InputObject obj) { obj.Dispose(); }