Exemplo n.º 1
0
            private int NativeGetInt(IntPtr thisPtr, IntPtr dataPtr, int dataSize, out int actualSize)
            {
                actualSize = ValueSize;
                try
                {
                    if (dataPtr == IntPtr.Zero)
                    {
                        // TODO: Should we throw an exception
                        return(Result.Ok.Code);
                    }

                    // TODO: Check dataSize against <T>?
                    var shadow   = CustomEffectShadow.ToShadow <CustomEffectShadow>(thisPtr);
                    var callback = (CustomEffect)shadow.Callback;
                    T   value;
                    actualSize = ValueSize;
                    getter(callback, out value);
                    GetValue(dataPtr, ref value);
                }
                catch (Exception exception)
                {
                    return((int)SharpDX.Result.GetResultFromException(exception));
                }
                return(Result.Ok.Code);
            }
Exemplo n.º 2
0
 private int NativeSetInt(IntPtr thisPtr, IntPtr dataPtr, int dataSize)
 {
     try
     {
         // TODO: Check dataSize against <T>?
         var shadow   = CustomEffectShadow.ToShadow <CustomEffectShadow>(thisPtr);
         var callback = (CustomEffect)shadow.Callback;
         T   value;
         SetValue(dataPtr, out value);
         setter(callback, ref value);
     }
     catch (Exception exception)
     {
         return((int)SharpDX.Result.GetResultFromException(exception));
     }
     return(Result.Ok.Code);
 }
 private int CreateCustomEffectImpl(out IntPtr nativeCustomEffectPtr)
 {
     nativeCustomEffectPtr = IntPtr.Zero;
     try
     {
         var customEffect = Factory();
         nativeCustomEffectPtr = CustomEffectShadow.ToIntPtr(customEffect);
     }
     catch (SharpDXException exception)
     {
         return(exception.ResultCode.Code);
     }
     catch (Exception)
     {
         return(Result.Fail.Code);
     }
     return(Result.Ok.Code);
 }