public void GetRelationshipClasses(ManagementOperationObserver watcher, string relationshipClass, string relationshipQualifier, string thisRole, EnumerationOptions options) { EnumerationOptions enumerationOption; if (this.Path == null || this.Path.Path == null || this.Path.Path.Length == 0) { throw new InvalidOperationException(); } else { if (watcher != null) { this.Initialize(true); if (options != null) { enumerationOption = (EnumerationOptions)options.Clone(); } else { enumerationOption = new EnumerationOptions(); } EnumerationOptions enumerationOption1 = enumerationOption; enumerationOption1.EnumerateDeep = true; enumerationOption1.ReturnImmediately = false; if (watcher.HaveListenersForProgress) { enumerationOption1.SendStatus = true; } WmiEventSink newSink = watcher.GetNewSink(base.Scope, enumerationOption1.Context); RelationshipQuery relationshipQuery = new RelationshipQuery(true, this.Path.Path, relationshipClass, relationshipQualifier, thisRole); SecurityHandler securityHandler = base.Scope.GetSecurityHandler(); int num = this.scope.GetSecuredIWbemServicesHandler(base.Scope.GetIWbemServices()).ExecQueryAsync_(relationshipQuery.QueryLanguage, relationshipQuery.QueryString, enumerationOption1.Flags, enumerationOption1.GetContext(), newSink.Stub); if (securityHandler != null) { securityHandler.Reset(); } if (num < 0) { watcher.RemoveSink(newSink); if (((long)num & (long)-4096) != (long)-2147217408) { Marshal.ThrowExceptionForHR(num); } else { ManagementException.ThrowWithExtendedInfo((ManagementStatus)num); return; } } return; } else { throw new ArgumentNullException("watcher"); } } }
public ManagementObjectCollection GetRelationshipClasses(string relationshipClass, string relationshipQualifier, string thisRole, EnumerationOptions options) { EnumerationOptions enumerationOption; if (this.Path == null || this.Path.Path == null || this.Path.Path.Length == 0) { throw new InvalidOperationException(); } else { this.Initialize(false); IEnumWbemClassObject enumWbemClassObject = null; if (options != null) { enumerationOption = options; } else { enumerationOption = new EnumerationOptions(); } EnumerationOptions enumerationOption1 = enumerationOption; enumerationOption1.EnumerateDeep = true; RelationshipQuery relationshipQuery = new RelationshipQuery(true, this.Path.Path, relationshipClass, relationshipQualifier, thisRole); SecurityHandler securityHandler = null; int num = 0; try { securityHandler = base.Scope.GetSecurityHandler(); num = this.scope.GetSecuredIWbemServicesHandler(base.Scope.GetIWbemServices()).ExecQuery_(relationshipQuery.QueryLanguage, relationshipQuery.QueryString, enumerationOption1.Flags, enumerationOption1.GetContext(), ref enumWbemClassObject); } finally { if (securityHandler != null) { securityHandler.Reset(); } } if (num < 0) { if (((long)num & (long)-4096) != (long)-2147217408) { Marshal.ThrowExceptionForHR(num); } else { ManagementException.ThrowWithExtendedInfo((ManagementStatus)num); } } return(new ManagementObjectCollection(base.Scope, enumerationOption1, enumWbemClassObject)); } }
public void GetRelationshipClasses(ManagementOperationObserver watcher, string relationshipClass, string relationshipQualifier, string thisRole, EnumerationOptions options) { if (((this.Path == null) || (this.Path.Path == null)) || (this.Path.Path.Length == 0)) { throw new InvalidOperationException(); } if (watcher == null) { throw new ArgumentNullException("watcher"); } this.Initialize(true); EnumerationOptions options2 = (options != null) ? ((EnumerationOptions)options.Clone()) : new EnumerationOptions(); options2.EnumerateDeep = true; options2.ReturnImmediately = false; if (watcher.HaveListenersForProgress) { options2.SendStatus = true; } WmiEventSink newSink = watcher.GetNewSink(base.Scope, options2.Context); RelationshipQuery query = new RelationshipQuery(true, this.Path.Path, relationshipClass, relationshipQualifier, thisRole); SecurityHandler securityHandler = null; int errorCode = 0; securityHandler = base.Scope.GetSecurityHandler(); errorCode = base.scope.GetSecuredIWbemServicesHandler(base.Scope.GetIWbemServices()).ExecQueryAsync_(query.QueryLanguage, query.QueryString, options2.Flags, options2.GetContext(), newSink.Stub); if (securityHandler != null) { securityHandler.Reset(); } if (errorCode < 0) { watcher.RemoveSink(newSink); if ((errorCode & 0xfffff000L) == 0x80041000L) { ManagementException.ThrowWithExtendedInfo((ManagementStatus)errorCode); } else { Marshal.ThrowExceptionForHR(errorCode); } } }
public ManagementObjectCollection GetRelationshipClasses(string relationshipClass, string relationshipQualifier, string thisRole, EnumerationOptions options) { if (((this.Path == null) || (this.Path.Path == null)) || (this.Path.Path.Length == 0)) { throw new InvalidOperationException(); } this.Initialize(false); IEnumWbemClassObject ppEnum = null; EnumerationOptions options2 = (options != null) ? options : new EnumerationOptions(); options2.EnumerateDeep = true; RelationshipQuery query = new RelationshipQuery(true, this.Path.Path, relationshipClass, relationshipQualifier, thisRole); SecurityHandler securityHandler = null; int errorCode = 0; try { securityHandler = base.Scope.GetSecurityHandler(); errorCode = base.scope.GetSecuredIWbemServicesHandler(base.Scope.GetIWbemServices()).ExecQuery_(query.QueryLanguage, query.QueryString, options2.Flags, options2.GetContext(), ref ppEnum); } finally { if (securityHandler != null) { securityHandler.Reset(); } } if (errorCode < 0) { if ((errorCode & 0xfffff000L) == 0x80041000L) { ManagementException.ThrowWithExtendedInfo((ManagementStatus)errorCode); } else { Marshal.ThrowExceptionForHR(errorCode); } } return(new ManagementObjectCollection(base.Scope, options2, ppEnum)); }
/// <summary> /// <para> Retrieves relationship classes that relate this class to others, according to /// specified options.</para> /// </summary> /// <param name='relationshipClass'><para> All resulting relationship classes must derive from this class.</para></param> /// <param name=' relationshipQualifier'>Resulting relationship classes must have this qualifier.</param> /// <param name=' thisRole'>The source class must have this role in the resulting relationship classes.</param> /// <param name=' options'>Specifies options for retrieving the results.</param> /// <returns> /// <para>A collection of association classes /// that relate this class to others, according to the specified options.</para> /// </returns> public ManagementObjectCollection GetRelationshipClasses( string relationshipClass, string relationshipQualifier, string thisRole, EnumerationOptions options) { if ((null == Path) || (null == Path.Path) || (0 == Path.Path.Length)) throw new InvalidOperationException(); Initialize ( false ) ; IEnumWbemClassObject enumWbem = null; EnumerationOptions o = (null != options) ? options : new EnumerationOptions(); //Ensure EnumerateDeep flag is turned off as it's invalid for queries o.EnumerateDeep = true; RelationshipQuery q = new RelationshipQuery(true, Path.Path, relationshipClass, relationshipQualifier, thisRole); SecurityHandler securityHandler = null; int status = (int)ManagementStatus.NoError; //Execute WMI query try { securityHandler = Scope.GetSecurityHandler(); status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices() ).ExecQuery_( q.QueryLanguage, q.QueryString, o.Flags, o.GetContext(), ref enumWbem); } finally { if (securityHandler != null) securityHandler.Reset(); } if (status < 0) { if ((status & 0xfffff000) == 0x80041000) ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); else Marshal.ThrowExceptionForHR(status); } //Create collection object return new ManagementObjectCollection(Scope, o, enumWbem); }
/// <summary> /// <para>Retrieves relationship classes that relate the class according to the specified /// options, asynchronously.</para> /// </summary> /// <param name='watcher'>The handler for progress and results of the asynchronous operation.</param> /// <param name='relationshipClass'><para>The class from which all resulting relationship classes must derive.</para></param> /// <param name=' relationshipQualifier'>The qualifier which the resulting relationship classes must have.</param> /// <param name=' thisRole'>The role which the source class must have in the resulting relationship classes.</param> /// <param name=' options'> The options for retrieving the results.</param> /// <returns> /// <para>A collection of association classes /// relating this class to others, according to the given options.</para> /// </returns> public void GetRelationshipClasses( ManagementOperationObserver watcher, string relationshipClass, string relationshipQualifier, string thisRole, EnumerationOptions options) { if ((null == Path) || (null == Path.Path) || (0 == Path.Path.Length)) throw new InvalidOperationException(); if (null == watcher) throw new ArgumentNullException("watcher"); else { Initialize ( true ) ; EnumerationOptions o = (null != options) ? (EnumerationOptions)options.Clone() : new EnumerationOptions(); //Ensure EnumerateDeep flag is turned off as it's invalid for queries o.EnumerateDeep = true; // Ensure we switch off ReturnImmediately as this is invalid for async calls o.ReturnImmediately = false; // If someone has registered for progress, make sure we flag it if (watcher.HaveListenersForProgress) o.SendStatus = true; WmiEventSink sink = watcher.GetNewSink(Scope, o.Context); RelationshipQuery q = new RelationshipQuery(true, Path.Path, relationshipClass, relationshipQualifier, thisRole); SecurityHandler securityHandler = null; int status = (int)ManagementStatus.NoError; securityHandler = Scope.GetSecurityHandler(); status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices()).ExecQueryAsync_( q.QueryLanguage, q.QueryString, o.Flags, o.GetContext(), sink.Stub); if (securityHandler != null) securityHandler.Reset(); if (status < 0) { watcher.RemoveSink(sink); if ((status & 0xfffff000) == 0x80041000) ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); else Marshal.ThrowExceptionForHR(status); } } }
public ManagementObjectCollection GetRelationships(string relationshipClass, string relationshipQualifier, string thisRole, bool classDefinitionsOnly, EnumerationOptions options) { EnumerationOptions enumerationOption; if (this.path == null || this.path.Path.Length == 0) { throw new InvalidOperationException(); } else { this.Initialize(false); IEnumWbemClassObject enumWbemClassObject = null; if (options != null) { enumerationOption = options; } else { enumerationOption = new EnumerationOptions(); } EnumerationOptions enumerationOption1 = enumerationOption; RelationshipQuery relationshipQuery = new RelationshipQuery(this.path.Path, relationshipClass, relationshipQualifier, thisRole, classDefinitionsOnly); enumerationOption1.EnumerateDeep = true; SecurityHandler securityHandler = null; try { securityHandler = this.scope.GetSecurityHandler(); int num = this.scope.GetSecuredIWbemServicesHandler(this.scope.GetIWbemServices()).ExecQuery_(relationshipQuery.QueryLanguage, relationshipQuery.QueryString, enumerationOption1.Flags, enumerationOption1.GetContext(), ref enumWbemClassObject); if (num < 0) { if (((long)num & (long)-4096) != (long)-2147217408) { Marshal.ThrowExceptionForHR(num); } else { ManagementException.ThrowWithExtendedInfo((ManagementStatus)num); } } } finally { if (securityHandler != null) { securityHandler.Reset(); } } return new ManagementObjectCollection(this.scope, enumerationOption1, enumWbemClassObject); } }
public void GetRelationships(ManagementOperationObserver watcher, string relationshipClass, string relationshipQualifier, string thisRole, bool classDefinitionsOnly, EnumerationOptions options) { EnumerationOptions enumerationOption; if (this.path == null || this.path.Path.Length == 0) { throw new InvalidOperationException(); } else { if (watcher != null) { this.Initialize(false); if (options != null) { enumerationOption = (EnumerationOptions)options.Clone(); } else { enumerationOption = new EnumerationOptions(); } EnumerationOptions enumerationOption1 = enumerationOption; enumerationOption1.ReturnImmediately = false; if (watcher.HaveListenersForProgress) { enumerationOption1.SendStatus = true; } WmiEventSink newSink = watcher.GetNewSink(this.scope, enumerationOption1.Context); RelationshipQuery relationshipQuery = new RelationshipQuery(this.path.Path, relationshipClass, relationshipQualifier, thisRole, classDefinitionsOnly); enumerationOption1.EnumerateDeep = true; SecurityHandler securityHandler = this.scope.GetSecurityHandler(); int num = this.scope.GetSecuredIWbemServicesHandler(this.scope.GetIWbemServices()).ExecQueryAsync_(relationshipQuery.QueryLanguage, relationshipQuery.QueryString, enumerationOption1.Flags, enumerationOption1.GetContext(), newSink.Stub); if (securityHandler != null) { securityHandler.Reset(); } if (num < 0) { watcher.RemoveSink(newSink); if (((long)num & (long)-4096) != (long)-2147217408) { Marshal.ThrowExceptionForHR(num); } else { ManagementException.ThrowWithExtendedInfo((ManagementStatus)num); return; } } return; } else { throw new ArgumentNullException("watcher"); } } }
public void GetRelationshipClasses(ManagementOperationObserver watcher, string relationshipClass, string relationshipQualifier, string thisRole, EnumerationOptions options) { if (((this.Path == null) || (this.Path.Path == null)) || (this.Path.Path.Length == 0)) { throw new InvalidOperationException(); } if (watcher == null) { throw new ArgumentNullException("watcher"); } this.Initialize(true); EnumerationOptions options2 = (options != null) ? ((EnumerationOptions) options.Clone()) : new EnumerationOptions(); options2.EnumerateDeep = true; options2.ReturnImmediately = false; if (watcher.HaveListenersForProgress) { options2.SendStatus = true; } WmiEventSink newSink = watcher.GetNewSink(base.Scope, options2.Context); RelationshipQuery query = new RelationshipQuery(true, this.Path.Path, relationshipClass, relationshipQualifier, thisRole); SecurityHandler securityHandler = null; int errorCode = 0; securityHandler = base.Scope.GetSecurityHandler(); errorCode = base.scope.GetSecuredIWbemServicesHandler(base.Scope.GetIWbemServices()).ExecQueryAsync_(query.QueryLanguage, query.QueryString, options2.Flags, options2.GetContext(), newSink.Stub); if (securityHandler != null) { securityHandler.Reset(); } if (errorCode < 0) { watcher.RemoveSink(newSink); if ((errorCode & 0xfffff000L) == 0x80041000L) { ManagementException.ThrowWithExtendedInfo((ManagementStatus) errorCode); } else { Marshal.ThrowExceptionForHR(errorCode); } } }
public ManagementObjectCollection GetRelationshipClasses(string relationshipClass, string relationshipQualifier, string thisRole, EnumerationOptions options) { if (((this.Path == null) || (this.Path.Path == null)) || (this.Path.Path.Length == 0)) { throw new InvalidOperationException(); } this.Initialize(false); IEnumWbemClassObject ppEnum = null; EnumerationOptions options2 = (options != null) ? options : new EnumerationOptions(); options2.EnumerateDeep = true; RelationshipQuery query = new RelationshipQuery(true, this.Path.Path, relationshipClass, relationshipQualifier, thisRole); SecurityHandler securityHandler = null; int errorCode = 0; try { securityHandler = base.Scope.GetSecurityHandler(); errorCode = base.scope.GetSecuredIWbemServicesHandler(base.Scope.GetIWbemServices()).ExecQuery_(query.QueryLanguage, query.QueryString, options2.Flags, options2.GetContext(), ref ppEnum); } finally { if (securityHandler != null) { securityHandler.Reset(); } } if (errorCode < 0) { if ((errorCode & 0xfffff000L) == 0x80041000L) { ManagementException.ThrowWithExtendedInfo((ManagementStatus) errorCode); } else { Marshal.ThrowExceptionForHR(errorCode); } } return new ManagementObjectCollection(base.Scope, options2, ppEnum); }
//******************************************************************* //GetRelationships //******************************************************************* /// <summary> /// <para>Gets a collection of associations to the object.</para> /// </summary> /// <param name='relationshipClass'>The type of relationship of interest. </param> /// <param name='relationshipQualifier'>The qualifier to be present on the relationship. </param> /// <param name='thisRole'>The role of this object in the relationship. </param> /// <param name='classDefinitionsOnly'>When this method returns, it contains only the class definitions for the result set. </param> /// <param name='options'>The extended options for the query execution. </param> /// <returns> /// A <see cref='System.Management.ManagementObjectCollection'/> containing the association objects. /// </returns> /// <remarks> /// <para>This operation is equivalent to a REFERENCES OF query with possibly all the extensions.</para> /// </remarks> public ManagementObjectCollection GetRelationships( string relationshipClass, string relationshipQualifier, string thisRole, bool classDefinitionsOnly, EnumerationOptions options) { if ((null == path) || (path.Path.Length==0)) throw new InvalidOperationException(); Initialize ( false ) ; IEnumWbemClassObject enumWbem = null; EnumerationOptions o = (null != options) ? options : new EnumerationOptions(); RelationshipQuery q = new RelationshipQuery(path.Path, relationshipClass, relationshipQualifier, thisRole, classDefinitionsOnly); //Make sure the EnumerateDeep flag bit is turned off because it's invalid for queries o.EnumerateDeep = true; //note this turns the FLAG to 0 !! SecurityHandler securityHandler = null; int status = (int)ManagementStatus.NoError; try { securityHandler = scope.GetSecurityHandler(); status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices()).ExecQuery_( q.QueryLanguage, q.QueryString, o.Flags, o.GetContext(), ref enumWbem ); if (status < 0) { if ((status & 0xfffff000) == 0x80041000) ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); else Marshal.ThrowExceptionForHR(status); } } finally { if (securityHandler != null) securityHandler.Reset(); } //Create collection object return new ManagementObjectCollection(scope, o, enumWbem); }