private static IEnumerable <DeviceNode> GetDeviceList(OptionalGuid class_guid, string enumerator, DiGetClassFlags flags) { var devices = new List <DeviceNode>(); DeviceNativeMethods.CM_Locate_DevNodeW(out int root, null, 0).ToNtStatus().ToNtException(); using (var p = DeviceNativeMethods.SetupDiGetClassDevsW(class_guid, enumerator, IntPtr.Zero, flags)) { if (p.IsInvalid) { Win32Utils.GetLastWin32Error().ToNtException(); } int index = 0; int size = Marshal.SizeOf(typeof(SP_DEVINFO_DATA)); SP_DEVINFO_DATA dev_info = new SP_DEVINFO_DATA() { cbSize = size }; while (DeviceNativeMethods.SetupDiEnumDeviceInfo(p, index++, ref dev_info)) { if (dev_info.DevInst != root) { devices.Add(new DeviceNode(dev_info.DevInst)); } dev_info.cbSize = size; } return(devices.AsReadOnly()); } }
public Reader TryGetReader(Book book) { OptionalGuid res = _rental.TryGet(book.Id); if (res.ContainsResult) { return(_readers.TryGet(res.Id)); } return(null); }
public bool TryReturnBook(Book book, Reader reader) { if (!_rental.GetBookRentStatus(book.Id)) { return(false); } OptionalGuid result = _rental.TryGet(book.Id); if (result.ContainsResult) { if (result.Id.Equals(reader.Id)) { return(_rental.TryUpdate(book.Id, Guid.Empty)); } } return(false); }
internal static extern bool AuditEnumerateSubCategories( OptionalGuid pAuditCategoryGuid, bool bRetrieveAllSubCategories, out SafeAuditBuffer ppAuditSubCategoriesArray, out uint pdwCountReturned );