コード例 #1
0
 public virtual void Remove(string propertyName)
 {
     if (this.parent.GetType() != typeof(ManagementObject))
     {
         int num = this.parent.wbemObject.Delete_(propertyName);
         if (num < 0)
         {
             if (((long)num & (long)-4096) != (long)-2147217408)
             {
                 Marshal.ThrowExceptionForHR(num);
             }
             else
             {
                 ManagementException.ThrowWithExtendedInfo((ManagementStatus)num);
                 return;
             }
         }
         return;
     }
     else
     {
         ManagementClass managementClass = new ManagementClass(this.parent.ClassPath);
         this.parent.SetPropertyValue(propertyName, managementClass.GetPropertyValue(propertyName));
         return;
     }
 }
コード例 #2
0
ファイル: PropertySet.cs プロジェクト: mikem8361/runtime
        /// <summary>
        /// <para>Removes a <see cref='System.Management.PropertyData'/> from the <see cref='System.Management.PropertyDataCollection'/>.</para>
        /// </summary>
        /// <param name='propertyName'>The name of the property to be removed.</param>
        /// <remarks>
        ///    <para> Properties can only be removed from class definitions,
        ///       not from instances. This method is only valid when invoked on a property
        ///       collection in a <see cref='System.Management.ManagementClass'/>.</para>
        /// </remarks>
        /// <example>
        ///    <code lang='C#'>ManagementClass c = new ManagementClass("MyClass");
        /// c.Properties.Remove("PropThatIDontWantOnThisClass");
        ///    </code>
        ///    <code lang='VB'>Dim c As New ManagementClass("MyClass")
        /// c.Properties.Remove("PropThatIDontWantOnThisClass")
        ///    </code>
        /// </example>
        public virtual void Remove(string propertyName)
        {
            // On instances, reset the property to the default value for the class.
            if (parent.GetType() == typeof(ManagementObject))
            {
                ManagementClass cls = new ManagementClass(parent.ClassPath);
                parent.SetPropertyValue(propertyName, cls.GetPropertyValue(propertyName));
            }
            else
            {
                int status = parent.wbemObject.Delete_(propertyName);

                if (status < 0)
                {
                    if ((status & 0xfffff000) == 0x80041000)
                    {
                        ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                    }
                    else
                    {
                        Marshal.ThrowExceptionForHR(status, WmiNetUtilsHelper.GetErrorInfo_f());
                    }
                }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: samihaq/CustomMonitoring
 static bool testValueExists(System.Management.ManagementClass instance, String value)
 {
     try
     {
         instance.GetPropertyValue(value);
     }
     catch (System.Management.ManagementException me)
     {
         if (me.ErrorCode.Equals(System.Management.ManagementStatus.NotFound))
         {
             return(false);
         }
         throw me;
     }
     return(true);
 }
コード例 #4
0
 public virtual void Remove(string propertyName)
 {
     if (this.parent.GetType() == typeof(ManagementObject))
     {
         ManagementClass class2 = new ManagementClass(this.parent.ClassPath);
         this.parent.SetPropertyValue(propertyName, class2.GetPropertyValue(propertyName));
     }
     else
     {
         int errorCode = this.parent.wbemObject.Delete_(propertyName);
         if (errorCode < 0)
         {
             if ((errorCode & 0xfffff000L) == 0x80041000L)
             {
                 ManagementException.ThrowWithExtendedInfo((ManagementStatus)errorCode);
             }
             else
             {
                 Marshal.ThrowExceptionForHR(errorCode);
             }
         }
     }
 }
コード例 #5
0
		/// <summary>
		/// <para>Removes a <see cref='System.Management.PropertyData'/> from the <see cref='System.Management.PropertyDataCollection'/>.</para>
		/// </summary>
		/// <param name='propertyName'>The name of the property to be removed.</param>
		/// <remarks>
		///    <para> Properties can only be removed from class definitions, 
		///       not from instances. This method is only valid when invoked on a property
		///       collection in a <see cref='System.Management.ManagementClass'/>.</para>
		/// </remarks>
		/// <example>
		///    <code lang='C#'>ManagementClass c = new ManagementClass("MyClass");
		/// c.Properties.Remove("PropThatIDontWantOnThisClass");
		///    </code>
		///    <code lang='VB'>Dim c As New ManagementClass("MyClass")
		/// c.Properties.Remove("PropThatIDontWantOnThisClass")
		///    </code>
		/// </example>
		public virtual void Remove(string propertyName)
		{
			// On instances, reset the property to the default value for the class.
			if (parent.GetType() == typeof(ManagementObject))
			{
				ManagementClass cls = new ManagementClass(parent.ClassPath);
				parent.SetPropertyValue(propertyName, cls.GetPropertyValue(propertyName));
			}
			else
			{
				int status = parent.wbemObject.Delete_(propertyName);

				if (status < 0)
				{
					if ((status & 0xfffff000) == 0x80041000)
						ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
					else
						Marshal.ThrowExceptionForHR(status);
				}
			}
		}
 public virtual void Remove(string propertyName)
 {
     if (this.parent.GetType() == typeof(ManagementObject))
     {
         ManagementClass class2 = new ManagementClass(this.parent.ClassPath);
         this.parent.SetPropertyValue(propertyName, class2.GetPropertyValue(propertyName));
     }
     else
     {
         int errorCode = this.parent.wbemObject.Delete_(propertyName);
         if (errorCode < 0)
         {
             if ((errorCode & 0xfffff000L) == 0x80041000L)
             {
                 ManagementException.ThrowWithExtendedInfo((ManagementStatus) errorCode);
             }
             else
             {
                 Marshal.ThrowExceptionForHR(errorCode);
             }
         }
     }
 }
コード例 #7
0
		public virtual void Remove(string propertyName)
		{
			if (this.parent.GetType() != typeof(ManagementObject))
			{
				int num = this.parent.wbemObject.Delete_(propertyName);
				if (num < 0)
				{
					if (((long)num & (long)-4096) != (long)-2147217408)
					{
						Marshal.ThrowExceptionForHR(num);
					}
					else
					{
						ManagementException.ThrowWithExtendedInfo((ManagementStatus)num);
						return;
					}
				}
				return;
			}
			else
			{
				ManagementClass managementClass = new ManagementClass(this.parent.ClassPath);
				this.parent.SetPropertyValue(propertyName, managementClass.GetPropertyValue(propertyName));
				return;
			}
		}