private void Initialize() { //If the query is not set yet we can't do it if (null == query) { throw new InvalidOperationException(); } //If we're not connected yet, this is the time to do it... #pragma warning disable CA2002 lock (this) #pragma warning restore CA2002 { if (null == scope) { scope = ManagementScope._Clone(null); } } lock (scope) { if (!scope.IsConnected) { scope.Initialize(); } } }
private void Initialize() { if (this.query != null) { lock (this) { if (this.scope == null) { this.scope = ManagementScope._Clone(null); } } lock (this.scope) { if (!this.scope.IsConnected) { this.scope.Initialize(); } } return; } else { throw new InvalidOperationException(); } }
public ManagementEventWatcher(ManagementScope scope, EventQuery query, EventWatcherOptions options) { if (scope != null) { this.scope = ManagementScope._Clone(scope, new IdentifierChangedEventHandler(this.HandleIdentifierChange)); } else { this.scope = ManagementScope._Clone(null, new IdentifierChangedEventHandler(this.HandleIdentifierChange)); } if (query != null) { this.query = (EventQuery)query.Clone(); } else { this.query = new EventQuery(); } this.query.IdentifierChanged += new IdentifierChangedEventHandler(this.HandleIdentifierChange); if (options != null) { this.options = (EventWatcherOptions)options.Clone(); } else { this.options = new EventWatcherOptions(); } this.options.IdentifierChanged += new IdentifierChangedEventHandler(this.HandleIdentifierChange); this.enumWbem = null; this.cachedCount = 0; this.cacheIndex = 0; this.sink = null; this.delegateInvoker = new WmiDelegateInvoker(this); }
//Constructor internal ManagementObjectCollection( ManagementScope scope, EnumerationOptions options, IEnumWbemClassObject enumWbem) { if (null != options) { this.options = (EnumerationOptions)options.Clone(); } else { this.options = new EnumerationOptions(); } if (null != scope) { this.scope = (ManagementScope)scope.Clone(); } else { this.scope = ManagementScope._Clone(null); } this.enumWbem = enumWbem; }
internal static ManagementClass GetManagementClass(IWbemClassObjectFreeThreaded wbemObject, ManagementScope scope) { ManagementClass managementClass = new ManagementClass(); managementClass.path = new ManagementPath(ManagementPath.GetManagementPath(wbemObject)); if (scope != null) { managementClass.scope = ManagementScope._Clone(scope); } managementClass.wbemObject = wbemObject; return(managementClass); }
internal static ManagementClass GetManagementClass(IWbemClassObjectFreeThreaded wbemObject, ManagementScope scope) { ManagementClass class2 = new ManagementClass { path = new ManagementPath(ManagementPath.GetManagementPath(wbemObject)) }; if (scope != null) { class2.scope = ManagementScope._Clone(scope); } class2.wbemObject = wbemObject; return(class2); }
public ManagementObjectSearcher(ManagementScope scope, ObjectQuery query, EnumerationOptions options) { this.scope = ManagementScope._Clone(scope); if (query != null) { this.query = (ObjectQuery)query.Clone(); } else { this.query = new ObjectQuery(); } if (options != null) { this.options = (EnumerationOptions)options.Clone(); } else { this.options = new EnumerationOptions(); } }
internal static ManagementClass GetManagementClass(IWbemClassObjectFreeThreaded wbemObject, ManagementClass mgObj) { ManagementClass class2 = new ManagementClass { wbemObject = wbemObject }; if (mgObj != null) { class2.scope = ManagementScope._Clone(mgObj.scope); ManagementPath path = mgObj.Path; if (path != null) { class2.path = ManagementPath._Clone(path); } object pVal = null; int pType = 0; int errorCode = wbemObject.Get_("__CLASS", 0, ref pVal, ref pType, ref pType); if (errorCode < 0) { if ((errorCode & 0xfffff000L) == 0x80041000L) { ManagementException.ThrowWithExtendedInfo((ManagementStatus)errorCode); } else { Marshal.ThrowExceptionForHR(errorCode); } } if (pVal != DBNull.Value) { class2.path.internalClassName = (string)pVal; } ObjectGetOptions options = mgObj.Options; if (options != null) { class2.options = ObjectGetOptions._Clone(options); } } return(class2); }
internal static ManagementClass GetManagementClass(IWbemClassObjectFreeThreaded wbemObject, ManagementClass mgObj) { ManagementClass managementClass = new ManagementClass(); managementClass.wbemObject = wbemObject; if (mgObj != null) { managementClass.scope = ManagementScope._Clone(mgObj.scope); ManagementPath path = mgObj.Path; if (path != null) { managementClass.path = ManagementPath._Clone(path); } object obj = null; int num = 0; int num1 = wbemObject.Get_("__CLASS", 0, ref obj, ref num, ref num); if (num1 < 0) { if (((long)num1 & (long)-4096) != (long)-2147217408) { Marshal.ThrowExceptionForHR(num1); } else { ManagementException.ThrowWithExtendedInfo((ManagementStatus)num1); } } if (obj != DBNull.Value) { managementClass.path.internalClassName = (string)obj; } ObjectGetOptions options = mgObj.Options; if (options != null) { managementClass.options = ObjectGetOptions._Clone(options); } } return(managementClass); }
public ManagementScope Clone() { return(ManagementScope._Clone(this)); }
internal static ManagementScope _Clone(ManagementScope scope) { return(ManagementScope._Clone(scope, null)); }