1    	//  =========================================================================
2    	//  
3    	//                             INTEL CONFIDENTIAL
4    	//                            Copyright 2005 - 2015
5    	//                    Intel Corporation All Rights Reserved. 
6    	//  
7    	//  =========================================================================
8    	//  The source code contained or described herein and all documents 
9    	//  related to the source code ("Material") are owned by Intel Corporation 
10   	//  or its suppliers or licensors. Title to the Material remains with 
11   	//  Intel Corporation or its suppliers and licensors. The Material contains 
12   	//  trade secrets and proprietary and confidential information of Intel or 
13   	//  its suppliers and licensors. The Material is protected by worldwide 
14   	//  copyright and trade secret laws and treaty provisions. No part of the 
15   	//  Material may be used, copied, reproduced, modified, published, uploaded, 
16   	//  posted, transmitted, distributed, or disclosed in any way without Intel’s 
17   	//  prior express written permission.
18   	//  
19   	//  No license under any patent, copyright, trade secret or other intellectual 
20   	//  property right is granted to or conferred upon you by disclosure or 
21   	//  delivery of the Materials, either expressly, by implication, inducement, 
22   	//  estoppel or otherwise. Any license under such intellectual property rights 
23   	//  must be express and approved by Intel in writing.
24   	//  ==========================================================================
25   	
26   	using System;
27   	using System.Collections.Generic;
28   	using System.ComponentModel;
29   	using System.Runtime.InteropServices;
30   	
31   	namespace Intel.Tools.DeviceManager
32   	{
33   		public class DeviceList : List<Device>, IDisposable
34   		{
35   			#region IDisposable Members
36   	
(1) Event close_implementation: Method that closes the resource.
Also see events: [resource_ctor]
37   			public void Dispose()
38   			{
39   				if (!this.IsDisposed)
40   				{
41   					if (!Win32Interop.SetupDiDestroyDeviceInfoList(this.DeviceInfoSet))
42   					{
43   						int error = Marshal.GetLastWin32Error();
44   						this.DeviceInfoSet = IntPtr.Zero;
45   						if (error != 0)
46   							throw new Win32Exception(error);
47   					}
48   					this.DeviceInfoSet = IntPtr.Zero;
49   					this.Clear();
50   				}
51   			}
52   	
53   			#endregion
54   	
55   			internal DeviceList Current { get; set; }
56   	
57   			internal bool IsDisposed
58   			{ get { return this.DeviceInfoSet == IntPtr.Zero; } }
59   	
60   			private IntPtr? _DeviceInfoSet;
61   			internal IntPtr DeviceInfoSet
62   			{
63   				get
(1) Event noescape: "Intel.Tools.DeviceManager.DeviceList.DeviceInfoSet.get()" does not free or save its parameter "this".
64   				{
65   					//DeviceInfoSet lifecycle:
66   					//  Starts as null
67   					//  Gets instantiated to some IntPtr when active
68   					//  Set to IntPtr.Zero when disposed.
69   	
(1) Event cond_true: Condition "!this._DeviceInfoSet.HasValue", taking true branch.
70   					if (!this._DeviceInfoSet.HasValue)
71   					{
(2) Event throw_uncaught: Throwing "System.Exception" from call to "GetDeviceInfoSet"; exiting method with uncaught exception. [details]
72   						this._DeviceInfoSet = GetDeviceInfoSet();
73   					}
74   					return this._DeviceInfoSet.Value;
75   				}
76   				private set { this._DeviceInfoSet = value; }
77   			}
78   	
(2) Event resource_ctor: Constructing an object of type "Intel.Tools.DeviceManager.DeviceList", which implements "System.IDisposable".
Also see events: [close_implementation]
79   			internal DeviceList() { }
80   	
81   			~DeviceList()
82   			{
83   				this.Dispose();
84   			}
85   	
86   			/// <summary>
87   			/// Do not call this method except in DeviceList.DeviceInfoSet property 'get' method.
88   			/// </summary>
89   			private static IntPtr GetDeviceInfoSet()
90   			{
91   				IntPtr deviceInfoSet;
92   	
93   				//Get the device info set of all present devices.
94   				deviceInfoSet = Win32Interop.SetupDiGetClassDevs(IntPtr.Zero, null, IntPtr.Zero, (int)(DeviceInfoSetType.AllClasses | DeviceInfoSetType.Present));
(1) Event cond_true: Condition "deviceInfoSet == System.IntPtr.Zero", taking true branch.
95   				if (deviceInfoSet == IntPtr.Zero)
(2) Event throw_uncaught: Throwing "System.Exception"; exiting method with uncaught exception.
96   					throw new Exception("Failed to get device information list.");
97   	
98   				return deviceInfoSet;
99   			}
100  		}
101  	}
102