Exemplo n.º 1
0
        /// <summary>
        /// Retrieves information about a remote access projection operation.
        /// </summary>
        /// <param name="projectionType">The protocol of interest.</param>
        /// <returns>The resulting projection information; otherwise, a null reference (<b>Nothing</b> in Visual Basic) if the protocol was not found.</returns>
        /// <remarks>
        /// The type of projection operation performed determines the type of object that is returned.
        /// </remarks>
        public object GetProjectionInfo(RasProjectionType projectionType)
        {
#if (WIN7 || WIN8)
            if (projectionType == RasProjectionType.Ppp || projectionType == RasProjectionType.IkeV2)
            {
                // The projection type requested is for the new projection types, pull it from the new extended method.
                object retval = RasHelper.Instance.GetProjectionInfoEx(this.Handle);
                if (retval != null && ((projectionType == RasProjectionType.Ppp && (!(retval is RasPppInfo))) || (projectionType == RasProjectionType.IkeV2 && (!(retval is RasIkeV2Info)))))
                {
                    retval = null;
                }

                return(retval);
            }
#endif

            // Use the standard projection method to retrieve the data.
            NativeMethods.RASPROJECTION projection = NativeMethods.RASPROJECTION.Amb;
            switch (projectionType)
            {
            case RasProjectionType.Amb:
                projection = NativeMethods.RASPROJECTION.Amb;
                break;

            case RasProjectionType.Nbf:
                projection = NativeMethods.RASPROJECTION.Nbf;
                break;

            case RasProjectionType.Ipx:
                projection = NativeMethods.RASPROJECTION.Ipx;
                break;

            case RasProjectionType.IP:
                projection = NativeMethods.RASPROJECTION.IP;
                break;

            case RasProjectionType.Ccp:
                projection = NativeMethods.RASPROJECTION.Ccp;
                break;

            case RasProjectionType.Lcp:
                projection = NativeMethods.RASPROJECTION.Lcp;
                break;

            case RasProjectionType.Slip:
                projection = NativeMethods.RASPROJECTION.Slip;
                break;

#if (WIN2K8 || WIN7 || WIN8)
            case RasProjectionType.IPv6:
                projection = NativeMethods.RASPROJECTION.IPv6;
                break;
#endif
            }

            return(RasHelper.Instance.GetProjectionInfo(this.Handle, projection));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves information about a remote access projection operation.
        /// </summary>
        /// <param name="projectionType">The protocol of interest.</param>
        /// <returns>The resulting projection information; otherwise, a null reference (<b>Nothing</b> in Visual Basic) if the protocol was not found.</returns>
        /// <remarks>
        /// The type of projection operation performed determines the type of object that is returned.
        /// </remarks>
        public object GetProjectionInfo(RasProjectionType projectionType)
        {
#if (WIN7 || WIN8)

            if (projectionType == RasProjectionType.Ppp || projectionType == RasProjectionType.IkeV2)
            {
                // The projection type requested is for the new projection types, pull it from the new extended method.
                object retval = RasHelper.Instance.GetProjectionInfoEx(this.Handle);
                if (retval != null && ((projectionType == RasProjectionType.Ppp && (!(retval is RasPppInfo))) || (projectionType == RasProjectionType.IkeV2 && (!(retval is RasIkeV2Info)))))
                {
                    retval = null;
                }

                return retval;
            }

#endif

            // Use the standard projection method to retrieve the data.
            NativeMethods.RASPROJECTION projection = NativeMethods.RASPROJECTION.Amb;
            switch (projectionType)
            {
                case RasProjectionType.Amb:
                    projection = NativeMethods.RASPROJECTION.Amb;
                    break;

                case RasProjectionType.Nbf:
                    projection = NativeMethods.RASPROJECTION.Nbf;
                    break;

                case RasProjectionType.Ipx:
                    projection = NativeMethods.RASPROJECTION.Ipx;
                    break;

                case RasProjectionType.IP:
                    projection = NativeMethods.RASPROJECTION.IP;
                    break;

                case RasProjectionType.Ccp:
                    projection = NativeMethods.RASPROJECTION.Ccp;
                    break;

                case RasProjectionType.Lcp:
                    projection = NativeMethods.RASPROJECTION.Lcp;
                    break;

                case RasProjectionType.Slip:
                    projection = NativeMethods.RASPROJECTION.Slip;
                    break;

#if (WIN2K8 || WIN7 || WIN8)

                case RasProjectionType.IPv6:
                    projection = NativeMethods.RASPROJECTION.IPv6;
                    break;

#endif
            }

            return RasHelper.Instance.GetProjectionInfo(this.Handle, projection);
        }