Пример #1
0
        private void Configure(IntPtr aioPtr)
        {
            PrivateOptions.SetSetters(
                x => __SetTimeoutDurationMilliseconds(_aioPtr, x)
                );

            // TODO: TBD: perhaps we can run direct through the C calling conventions.
            _free          = () => __Free(aioPtr);
            _wait          = () => __Wait(aioPtr);
            _stop          = () => __Stop(aioPtr);
            _cancel        = () => __Cancel(aioPtr);
            _getResult     = () => __GetResult(aioPtr);
            _getMessagePtr = () => __GetMessagePtr(aioPtr);
            _setMessagePtr = msgPtr => __SetMessagePtr(aioPtr, msgPtr);
        }
Пример #2
0
        private void Configure(uint pid)
        {
            _closer = () => __Close(pid);

            _reset = ptr => __SetPipe(ptr, pid);

            var opt = PrivateOptions;

            opt.SetGetters(
                (string name, ref int value) => __GetOptInt32(pid, name, ref value)
                , (string name, ref ulong value) => __GetOptUInt64(pid, name, ref value)
                , (string name, StringBuilder value, ref ulong length) => __GetOptStringBuilder(
                    pid, name, value, ref length)
                , (string name, ref int value) => __GetOptDurationMilliseconds(pid, name, ref value)
                );
        }
Пример #3
0
        protected internal virtual void InvokeWithDefaultErrorHandling(InvocationWithResultDelegate <int> caller
                                                                       , params ErrorCode[] notOneOf)
        {
            var errnum = caller();

            if (!notOneOf.Any())
            {
                notOneOf = new[] { None };
            }
            if (notOneOf.Any(x => errnum == (int)x))
            {
                return;
            }
            // TODO: TBD: do something with the result...
            // TODO: TBD: introduce an appropriately named exception
            throw new NanoException(errnum);
        }
Пример #4
0
 protected internal TResult InvokeWithResult <TResult>(InvocationWithResultDelegate <IntPtr, TResult> caller, IntPtr ptr)
 {
     return(caller(ptr));
 }
Пример #5
0
 protected internal virtual void InvokeWithDefaultErrorHandling(InvocationWithResultDelegate <IntPtr, int> caller
                                                                , IntPtr ptr, params ErrorCode[] notOneOf)
 {
     InvokeWithDefaultErrorHandling <IntPtr>(caller, ptr, notOneOf);
 }
Пример #6
0
 // TODO: TBD: will need to consider the "throw if one of" scenario...
 protected internal virtual void InvokeWithDefaultErrorHandling <T>(InvocationWithResultDelegate <T, int> caller
                                                                    , T ptr, params ErrorCode[] notOneOf)
 {
     InvokeWithDefaultErrorHandling(() => caller(ptr), notOneOf);
 }
Пример #7
0
        protected internal virtual TResult InvokeWithResult <T, TResult>(InvocationWithResultDelegate <T, TResult> caller, T ptr)
        {
            var result = caller(ptr);

            return(result);
        }
Пример #8
0
 internal void InvokeWithDefaultErrorHandling(InvocationWithResultDelegate <IntPtr, int> caller)
 {
     // Make sure that the Message we allocate is the same one we pass for Invocation.
     Allocate(ref _msgPtr);
     base.InvokeWithDefaultErrorHandling(caller, _msgPtr);
 }
Пример #9
0
 internal TResult InvokeWithResult <TResult>(InvocationWithResultDelegate <IntPtr, TResult> caller)
 {
     // Ditto Message ptr alignment.
     Allocate(ref _msgPtr);
     return(InvokeWithResult(caller, _msgPtr));
 }