Пример #1
0
        static unsafe int QueryContextAttributes(SafeDeleteContext phContext, ContextAttribute attribute, byte[] buffer, Type handleType, out SafeHandle refHandle)
        {
            refHandle = null;
            if (handleType != null)
            {
                if (handleType == typeof(SafeFreeContextBuffer))
                {
                    refHandle = SafeFreeContextBuffer.CreateEmptyHandle();
                }
                else if (handleType == typeof(SafeFreeCertContext))
                {
                    refHandle = new SafeFreeCertContext();
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("handleType", SR.GetString(SR.ValueMustBeOf2Types, typeof(SafeFreeContextBuffer).ToString(), typeof(SafeFreeCertContext).ToString())));
                }
            }

            fixed(byte *bufferPtr = buffer)
            {
                return(SafeFreeContextBuffer.QueryContextAttributes(phContext, attribute, bufferPtr, refHandle));
            }
        }
        private static unsafe int QueryContextAttributes(SafeDeleteContext phContext, ContextAttribute attribute, byte[] buffer, Type handleType, out SafeHandle refHandle)
        {
            refHandle = null;
            if (handleType != null)
            {
                if (handleType != typeof(SafeFreeContextBuffer))
                {
                    if (handleType != typeof(SafeFreeCertContext))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("handleType", System.IdentityModel.SR.GetString("ValueMustBeOf2Types", new object[] { typeof(SafeFreeContextBuffer).ToString(), typeof(SafeFreeCertContext).ToString() })));
                    }
                    refHandle = new SafeFreeCertContext();
                }
                else
                {
                    refHandle = SafeFreeContextBuffer.CreateEmptyHandle();
                }
            }

            fixed(byte *numRef = buffer)
            {
                return(SafeFreeContextBuffer.QueryContextAttributes(phContext, attribute, numRef, refHandle));
            }
        }