WbemException.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Administration / WbemException.cs / 1 / WbemException.cs

                            //------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------

namespace System.ServiceModel.Administration 
{
    using System; 
    using System.ComponentModel; 
    using System.Diagnostics;
 
    internal class WbemException : Win32Exception
    {
        internal WbemException(WbemNative.WbemStatus hr)
            : base((int)hr) 
        {
        } 
 
        internal WbemException(int hr)
            : base(hr) 
        {
        }

        internal WbemException(int hr, string message) 
            : base(hr, message)
        { 
        } 

        internal static void Throw(WbemNative.WbemStatus hr) 
        {
            switch (hr)
            {
                case WbemNative.WbemStatus.WBEM_E_NOT_FOUND: 
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WbemInstanceNotFoundException());
                case WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER: 
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WbemInvalidParameterException()); 
                case WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WbemNotSupportedException()); 
                case WbemNative.WbemStatus.WBEM_E_INVALID_METHOD:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WbemInvalidMethodException());
                default:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WbemException(hr)); 
            }
        } 
 
        internal static void ThrowIfFail(int hr)
        { 
            if (hr < 0)
            {
                Throw((WbemNative.WbemStatus)hr);
            } 
        }
    } 
 
    internal class WbemInstanceNotFoundException : WbemException
    { 
        internal WbemInstanceNotFoundException()
            : base(WbemNative.WbemStatus.WBEM_E_NOT_FOUND)
        {
        } 
    }
 
    internal class WbemInvalidParameterException : WbemException 
    {
        internal WbemInvalidParameterException(string name) 
            : base((int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER, name)
        {
        }
 
        internal WbemInvalidParameterException()
            : base(WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER) 
        { 
        }
    } 

    internal class WbemNotSupportedException : WbemException
    {
        internal WbemNotSupportedException() 
            : base(WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED)
        { 
        } 
    }
 
    internal class WbemInvalidMethodException : WbemException
    {
        internal WbemInvalidMethodException()
            : base(WbemNative.WbemStatus.WBEM_E_INVALID_METHOD) 
        {
        } 
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK