QueryServiceConfigHandle.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 / Tools / xws_reg / System / ServiceModel / Install / QueryServiceConfigHandle.cs / 1 / QueryServiceConfigHandle.cs

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

namespace System.ServiceModel.Install 
{
    using Microsoft.Win32.SafeHandles; 
    using System; 
    using System.ComponentModel;
    using System.Diagnostics; 
    using System.Runtime.ConstrainedExecution;
    using System.Runtime.InteropServices;
    using System.Security.AccessControl;
    using System.Text; 

    internal class QueryServiceConfigHandle : SafeHandleMinusOneIsInvalid 
    { 
        internal QueryServiceConfigHandle()
            : this(IntPtr.Zero) 
        {
        }

        internal QueryServiceConfigHandle(int size) 
            : this(Marshal.AllocHGlobal(size))
        { 
        } 

        internal QueryServiceConfigHandle(IntPtr queryServiceConfigPtr) 
            : base(true)
        {
            this.handle = queryServiceConfigPtr;
        } 

        internal QUERY_SERVICE_CONFIG ServiceConfig 
        { 
            get
            { 
                QUERY_SERVICE_CONFIG retVal = new QUERY_SERVICE_CONFIG();
                if (IntPtr.Zero != this.handle)
                {
                    retVal = (QUERY_SERVICE_CONFIG) Marshal.PtrToStructure(this.handle, typeof(QUERY_SERVICE_CONFIG)); 
                }
 
                return retVal; 
            }
        } 

        protected override bool ReleaseHandle()
        {
            if (!this.IsInvalid && 
                !this.IsClosed &&
                IntPtr.Zero != this.handle) 
            { 
                Marshal.FreeHGlobal(this.handle);
                this.handle = IntPtr.Zero; 
            }

            return true;
        } 
    }
} 

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