Example #1
0
        /// <summary>
        ///     Set options for this object.
        /// </summary>
        /// <param name="option">
        ///     One of the values in the <see cref="CurlShareOption" />
        ///     enumeration.
        /// </param>
        /// <param name="parameter">
        ///     An appropriate object based on the value passed in the
        ///     <c>option</c> argument. See <see cref="CurlShareOption" />
        ///     for more information about the appropriate parameter type.
        /// </param>
        /// <returns>
        ///     A <see cref="CurlShareCode" />, hopefully
        ///     <c>CurlShareCode.Ok</c>.
        /// </returns>
        /// <exception cref="System.NullReferenceException">
        ///     This is thrown if
        ///     the native <c>share</c> handle wasn't created successfully.
        /// </exception>
        public CurlShareCode SetOpt(CurlShareOption option, Object parameter)
        {
            EnsureHandle();
            var retCode = CurlShareCode.Ok;

            switch (option)
            {
            case CurlShareOption.LockFunction:
                var lf = parameter as CurlShareLockCallback;
                if (lf == null)
                {
                    return(CurlShareCode.BadOption);
                }
                _pfLock = lf;
                break;

            case CurlShareOption.UnlockFunction:
                var ulf = parameter as CurlShareUnlockCallback;
                if (ulf == null)
                {
                    return(CurlShareCode.BadOption);
                }
                _pfUnlock = ulf;
                break;

            case CurlShareOption.Share:
            case CurlShareOption.Unshare:
            {
                var opt = (CurlLockData)Convert.ToInt32(parameter);
                retCode = setShareOption(option, opt);
                break;
            }

            case CurlShareOption.UserData:
                _userData = parameter;
                break;

            default:
                retCode = CurlShareCode.BadOption;
                break;
            }
            return(retCode);
        }
Example #2
0
        /// <summary>
        ///     Set options for this object.
        /// </summary>
        /// <param name="option">
        ///     One of the values in the <see cref="CurlShareOption" />
        ///     enumeration.
        /// </param>
        /// <param name="parameter">
        ///     An appropriate object based on the value passed in the
        ///     <c>option</c> argument. See <see cref="CurlShareOption" />
        ///     for more information about the appropriate parameter type.
        /// </param>
        /// <returns>
        ///     A <see cref="CurlShareCode" />, hopefully
        ///     <c>CurlShareCode.Ok</c>.
        /// </returns>
        /// <exception cref="System.NullReferenceException">
        ///     This is thrown if
        ///     the native <c>share</c> handle wasn't created successfully.
        /// </exception>
        public CurlShareCode SetOpt(CurlShareOption option, Object parameter)
        {
            EnsureHandle();
            var retCode = CurlShareCode.Ok;

            switch (option)
            {
                case CurlShareOption.LockFunction:
                    var lf = parameter as CurlShareLockCallback;
                    if (lf == null)
                        return CurlShareCode.BadOption;
                    _pfLock = lf;
                    break;

                case CurlShareOption.UnlockFunction:
                    var ulf = parameter as CurlShareUnlockCallback;
                    if (ulf == null)
                        return CurlShareCode.BadOption;
                    _pfUnlock = ulf;
                    break;

                case CurlShareOption.Share:
                case CurlShareOption.Unshare:
                {
                    var opt = (CurlLockData) Convert.ToInt32(parameter);
                    retCode = setShareOption(option, opt);
                    break;
                }

                case CurlShareOption.UserData:
                    _userData = parameter;
                    break;

                default:
                    retCode = CurlShareCode.BadOption;
                    break;
            }
            return retCode;
        }