当前位置: 首页>>代码示例>>C#>>正文


C# EnumerationOptions.Clone方法代码示例

本文整理汇总了C#中System.Management.EnumerationOptions.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# EnumerationOptions.Clone方法的具体用法?C# EnumerationOptions.Clone怎么用?C# EnumerationOptions.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Management.EnumerationOptions的用法示例。


在下文中一共展示了EnumerationOptions.Clone方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ManagementObjectCollection

        //internal IWbemServices GetIWbemServices () {
        //  return scope.GetIWbemServices ();
        //}

        //internal ConnectionOptions Connection {
        //  get { return scope.Connection; }
        //}

        //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;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:26,代码来源:ManagementObjectCollection.cs

示例2: ManagementObjectSearcher

 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();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:20,代码来源:ManagementObjectSearcher.cs

示例3: ManagementObjectCollection

 internal ManagementObjectCollection(ManagementScope scope, EnumerationOptions options, IEnumWbemClassObject enumWbem)
 {
     if (options != null)
     {
         this.options = (EnumerationOptions) options.Clone();
     }
     else
     {
         this.options = new EnumerationOptions();
     }
     if (scope != null)
     {
         this.scope = scope.Clone();
     }
     else
     {
         this.scope = ManagementScope._Clone(null);
     }
     this.enumWbem = enumWbem;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:20,代码来源:ManagementObjectCollection.cs

示例4: GetSubclasses

		/// <summary>
		///    <para>Retrieves all classes derived from this class, asynchronously, using the specified 
		///       options.</para>
		/// </summary>
		/// <param name='watcher'>The object to handle the asynchronous operation's progress. </param>
		/// <param name='options'>The specified additional options to use in the derived class retrieval.</param>
		public void GetSubclasses(ManagementOperationObserver watcher,
										EnumerationOptions options) 
		{ 				
			if (null == watcher)
				throw new ArgumentNullException("watcher");
			
			if (null == Path)
				throw new InvalidOperationException();

			Initialize ( false ) ;

			EnumerationOptions o = (null == options) ? new EnumerationOptions() : 
									  (EnumerationOptions)options.Clone();

			//Need to make sure that we're not passing invalid flags to enumeration APIs.
			//The only flags in EnumerationOptions not valid for enumerations are EnsureLocatable & PrototypeOnly.
			o.EnsureLocatable = false; o.PrototypeOnly = false;

			// 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);

			SecurityHandler securityHandler = null;
			int status						= (int)ManagementStatus.NoError;

			securityHandler = Scope.GetSecurityHandler();

                    status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices() ).CreateClassEnumAsync_(ClassName,
				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);
			}
		}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:56,代码来源:ManagementClass.cs

示例5: GetRelationshipClasses

		/// <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);
				}
			}
		}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:72,代码来源:ManagementClass.cs

示例6: GetRelatedClasses

		/// <summary>
		///    <para> Retrieves classes related to the WMI class based on the specified 
		///       options.</para>
		/// </summary>
		/// <param name=' relatedClass'><para>The class from which resulting classes have to be derived.</para></param>
		/// <param name=' relationshipClass'> The relationship type which resulting classes must have with the source class.</param>
		/// <param name=' relationshipQualifier'>This qualifier must be present on the relationship.</param>
		/// <param name=' relatedQualifier'>This qualifier must be present on the resulting classes.</param>
		/// <param name=' relatedRole'>The resulting classes must have this role in the relationship.</param>
		/// <param name=' thisRole'>The source class must have this role in the relationship.</param>
		/// <param name=' options'>The options for retrieving the resulting classes.</param>
		/// <returns>
		///    <para>A collection of classes related to
		///       this class.</para>
		/// </returns>
		public ManagementObjectCollection GetRelatedClasses(
											string relatedClass,
											string relationshipClass,
											string relationshipQualifier,
											string relatedQualifier,
											string relatedRole,
											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) ? (EnumerationOptions)options.Clone() : new EnumerationOptions();
			//Ensure EnumerateDeep flag bit is turned off as it's invalid for queries
			o.EnumerateDeep = true;

			RelatedObjectQuery q = new RelatedObjectQuery(true,	Path.Path, 
															relatedClass,
															relationshipClass, 
															relatedQualifier,
															relationshipQualifier, 
															relatedRole, thisRole);

			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);

			}
			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);
		}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:73,代码来源:ManagementClass.cs

示例7: GetRelated

		public void GetRelated(ManagementOperationObserver watcher, string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, string thisRole, bool classDefinitionsOnly, EnumerationOptions options)
		{
			EnumerationOptions enumerationOption;
			if (this.path == null || this.path.Path.Length == 0)
			{
				throw new InvalidOperationException();
			}
			else
			{
				this.Initialize(true);
				if (watcher != null)
				{
					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);
					RelatedObjectQuery relatedObjectQuery = new RelatedObjectQuery(this.path.Path, relatedClass, relationshipClass, relationshipQualifier, relatedQualifier, relatedRole, thisRole, classDefinitionsOnly);
					enumerationOption1.EnumerateDeep = true;
					SecurityHandler securityHandler = this.scope.GetSecurityHandler();
					int num = this.scope.GetSecuredIWbemServicesHandler(this.scope.GetIWbemServices()).ExecQueryAsync_(relatedObjectQuery.QueryLanguage, relatedObjectQuery.QueryString, enumerationOption1.Flags, enumerationOption1.GetContext(), newSink.Stub);
					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");
				}
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:53,代码来源:ManagementObject.cs

示例8: GetSubclasses

 public void GetSubclasses(ManagementOperationObserver watcher, EnumerationOptions options)
 {
     if (watcher == null)
     {
         throw new ArgumentNullException("watcher");
     }
     if (this.Path == null)
     {
         throw new InvalidOperationException();
     }
     this.Initialize(false);
     EnumerationOptions options2 = (options == null) ? new EnumerationOptions() : ((EnumerationOptions) options.Clone());
     options2.EnsureLocatable = false;
     options2.PrototypeOnly = false;
     options2.ReturnImmediately = false;
     if (watcher.HaveListenersForProgress)
     {
         options2.SendStatus = true;
     }
     WmiEventSink newSink = watcher.GetNewSink(base.Scope, options2.Context);
     SecurityHandler securityHandler = null;
     int errorCode = 0;
     securityHandler = base.Scope.GetSecurityHandler();
     errorCode = base.scope.GetSecuredIWbemServicesHandler(base.Scope.GetIWbemServices()).CreateClassEnumAsync_(base.ClassName, 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);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:41,代码来源:ManagementClass.cs

示例9: GetRelationshipClasses

 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);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:41,代码来源:ManagementClass.cs

示例10: GetRelatedClasses

 public ManagementObjectCollection GetRelatedClasses(string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, 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) ? ((EnumerationOptions) options.Clone()) : new EnumerationOptions();
     options2.EnumerateDeep = true;
     RelatedObjectQuery query = new RelatedObjectQuery(true, this.Path.Path, relatedClass, relationshipClass, relatedQualifier, relationshipQualifier, relatedRole, 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);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:38,代码来源:ManagementClass.cs

示例11: GetSubclasses

		public void GetSubclasses(ManagementOperationObserver watcher, EnumerationOptions options)
		{
			EnumerationOptions enumerationOption;
			if (watcher != null)
			{
				if (this.Path != null)
				{
					this.Initialize(false);
					if (options == null)
					{
						enumerationOption = new EnumerationOptions();
					}
					else
					{
						enumerationOption = (EnumerationOptions)options.Clone();
					}
					EnumerationOptions enumerationOption1 = enumerationOption;
					enumerationOption1.EnsureLocatable = false;
					enumerationOption1.PrototypeOnly = false;
					enumerationOption1.ReturnImmediately = false;
					if (watcher.HaveListenersForProgress)
					{
						enumerationOption1.SendStatus = true;
					}
					WmiEventSink newSink = watcher.GetNewSink(base.Scope, enumerationOption1.Context);
					SecurityHandler securityHandler = base.Scope.GetSecurityHandler();
					int num = this.scope.GetSecuredIWbemServicesHandler(base.Scope.GetIWbemServices()).CreateClassEnumAsync_(base.ClassName, 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 InvalidOperationException();
				}
			}
			else
			{
				throw new ArgumentNullException("watcher");
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:56,代码来源:ManagementClass.cs

示例12: GetRelatedClasses

		public ManagementObjectCollection GetRelatedClasses(string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, 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 = (EnumerationOptions)options.Clone();
				}
				else
				{
					enumerationOption = new EnumerationOptions();
				}
				EnumerationOptions enumerationOption1 = enumerationOption;
				enumerationOption1.EnumerateDeep = true;
				RelatedObjectQuery relatedObjectQuery = new RelatedObjectQuery(true, this.Path.Path, relatedClass, relationshipClass, relatedQualifier, relationshipQualifier, relatedRole, thisRole);
				SecurityHandler securityHandler = null;
				int num = 0;
				try
				{
					securityHandler = base.Scope.GetSecurityHandler();
					num = this.scope.GetSecuredIWbemServicesHandler(base.Scope.GetIWbemServices()).ExecQuery_(relatedObjectQuery.QueryLanguage, relatedObjectQuery.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);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:50,代码来源:ManagementClass.cs


注:本文中的System.Management.EnumerationOptions.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。