Example #1
0
        internal Inflater(object inflaterInstance)
        {
            Type type = inflaterInstance.GetType();

            setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
                typeof(SetInputDelegate),
                inflaterInstance,
                type.GetMethod("SetInput", new Type[] { typeof(byte[]) }));

            getIsFinishedMethod = (GetIsFinishedDelegate)Delegate.CreateDelegate(
                typeof(GetIsFinishedDelegate),
                inflaterInstance,
                type.GetMethod("get_IsFinished", Type.EmptyTypes));

            inflateMethod = (InflateDelegate)Delegate.CreateDelegate(
                typeof(InflateDelegate),
                inflaterInstance,
                type.GetMethod("Inflate", new Type[] { typeof(byte[]) }));

            resetMethod = (ResetDelegate)Delegate.CreateDelegate(
                typeof(ResetDelegate),
                inflaterInstance,
                type.GetMethod("Reset", Type.EmptyTypes));

            setInput3Method = (SetInputDelegate3)Delegate.CreateDelegate(
                typeof(SetInputDelegate3),
                inflaterInstance,
                type.GetMethod("SetInput", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));

            inflate3Method = (InflateDelegate3)Delegate.CreateDelegate(
                typeof(InflateDelegate3),
                inflaterInstance,
                type.GetMethod("Inflate", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));
        }
Example #2
0
        internal Inflater(object inflaterInstance)
        {
            Type type = inflaterInstance.GetType();

            setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
                typeof(SetInputDelegate),
                inflaterInstance,
                type.GetMethod("SetInput", new Type[] { typeof(byte[]) }));

            getIsFinishedMethod = (GetIsFinishedDelegate)Delegate.CreateDelegate(
                typeof(GetIsFinishedDelegate),
                inflaterInstance,
                type.GetMethod("get_IsFinished", Type.EmptyTypes));

            inflateMethod = (InflateDelegate)Delegate.CreateDelegate(
                typeof(InflateDelegate),
                inflaterInstance,
                type.GetMethod("Inflate", new Type[] { typeof(byte[]) }));

            resetMethod = (ResetDelegate)Delegate.CreateDelegate(
                typeof(ResetDelegate),
                inflaterInstance,
                type.GetMethod("Reset", Type.EmptyTypes));

            setInput3Method = (SetInputDelegate3)Delegate.CreateDelegate(
                typeof(SetInputDelegate3),
                inflaterInstance,
                type.GetMethod("SetInput", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));

            inflate3Method = (InflateDelegate3)Delegate.CreateDelegate(
                typeof(InflateDelegate3),
                inflaterInstance,
                type.GetMethod("Inflate", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));
        }
Example #3
0
 private void OnDisable()
 {
     if (roomResetable)
     {
         resetDelegate -= MechanicReset;
     }
 }
Example #4
0
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (_disposed)
            {
                return;
            }
            // If disposing equals true, dispose all managed
            // and unmanaged resources.
            if (disposing)
            {
                // Dispose managed resources.
                _dllhandle     = IntPtr.Zero;
                _open          = null;
                _close         = null;
                _start         = null;
                _reset         = null;
                _config        = null;
                _read          = null;
                _write         = null;
                _checkTx       = null;
                _getDeviceList = null;
            }
            // Dispose native ( unmanaged ) resources, if exits

            // Note disposing has been done.
            _disposed = true;
        }
Example #5
0
 public Pool(int capacity = 50, ResetDelegate reset = null, float expire = 0 /*0表示持久*/)
 {
     _capacity    = capacity;
     _resetEvent += reset;
     _expire      = expire;
     DelayExpire();
 }
Example #6
0
 private void OnEnable()
 {
     if (roomResetable)
     {
         initialPos     = new Vector2(transform.position.x, transform.position.y);
         resetDelegate += MechanicReset;
     }
 }
Example #7
0
        public ProgressView()
        {
            InitializeComponent();

            UpdateDelegateMethodInstance       = new UpdateDelegate(UpdateMethod);
            UpdateDetailDelegateMethodInstance = new UpdateDetailDelegate(UpdateDetailMethod);
            ResetDelegateMethodInstance        = new ResetDelegate(ResetMethod);
        }
Example #8
0
 internal static void Bind()
 {
     _beginDelegate    = Library.GetProcAddress <BeginDelegate>("mdbx_txn_begin") as BeginDelegate;
     _commitDelegate   = Library.GetProcAddress <CommitDelegate>("mdbx_txn_commit") as CommitDelegate;
     _abortDelegate    = Library.GetProcAddress <AbortDelegate>("mdbx_txn_abort") as AbortDelegate;
     _resetDelegate    = Library.GetProcAddress <ResetDelegate>("mdbx_txn_reset") as ResetDelegate;
     _renewDelegate    = Library.GetProcAddress <RenewDelegate>("mdbx_txn_renew") as RenewDelegate;
     _getTxnIdDelegate = Library.GetProcAddress <GetTxnIdDelegate>("mdbx_txn_id") as GetTxnIdDelegate;
 }
    public void Clear()
    {
        Reset();

        OptionEvaluators.Clear();

        _finalizationMethod = null;
        _resetMethod        = null;
    }
Example #10
0
 /// <summary>
 /// Creates a <see cref="CollectionChangedEventHandler{T}"/> from the specified delegates.
 /// </summary>
 /// <param name="add"> If null is specified, nothing is performed on addition of an element. </param>
 /// <param name="move"> If null is specified, nothing is performed on removal of an element. </param>
 /// <param name="remove"> If null is specified, nothing is performed on removal of an element. </param>
 /// <param name="replace"> If null is specified, the default action is performed, which is to first remove and then add the changes. </param>
 /// <param name="reset"> If null is specified, the default action is performed, which is to remove all elements. </param>
 public static CollectionChangedEventHandler <T> Create <TCollection>(
     AddDelegate <TCollection> add         = null,
     RemoveDelegate <TCollection> remove   = null,
     ReplaceDelegate <TCollection> replace = null,
     MoveDelegate <TCollection> move       = null,
     ResetDelegate <TCollection> reset     = null
     ) where TCollection : INotifyCollectionChanged
 {
     return(new DelegatedCollectionChangedEventHandler <TCollection>(move, add, reset, replace, remove));
 }
Example #11
0
        public bool Register(EnumCacheType cacheType, ResetDelegate resetDelegate)
        {
            var iType = (int)cacheType;

            if (!_cacheDic.ContainsKey(iType))
            {
                _cacheDic.Add(iType, resetDelegate);
                LogHelper.Insert(cacheType.ToString() + " register success.", LogType.Info);
                return(true);
            }
            return(true);
        }
Example #12
0
    private void Awake()
    {
        if (Instance == this)
        {
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }

        _playerRef = KyleplayerMove.Instance;
        Reset      = _playerRef.ResetPlayer;
    }
Example #13
0
 public DelegatedCollectionChangedEventHandler(
     MoveDelegate <TCollection> move,
     AddDelegate <TCollection> add,
     ResetDelegate <TCollection> reset,
     ReplaceDelegate <TCollection> replace,
     RemoveDelegate <TCollection> remove
     )
 {
     this.move    = move;
     this.add     = add;
     this.reset   = reset;
     this.replace = replace;
     this.remove  = remove;
 }
Example #14
0
        internal Deflater(object deflaterInstance)
        {
            Type type = deflaterInstance.GetType();

            setLevelMethod = (SetLevelDelegate)Delegate.CreateDelegate(
                typeof(SetLevelDelegate),
                deflaterInstance,
                type.GetMethod("SetLevel", new Type[] { typeof(int) }));

            setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
                typeof(SetInputDelegate),
                deflaterInstance,
                type.GetMethod("SetInput", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));

            finishMethod = (FinishDelegate)Delegate.CreateDelegate(
                typeof(FinishDelegate),
                deflaterInstance,
                type.GetMethod("Finish", Type.EmptyTypes));

            getIsFinishedMethod = (GetIsFinishedDelegate)Delegate.CreateDelegate(
                typeof(GetIsFinishedDelegate),
                deflaterInstance,
                type.GetMethod("get_IsFinished", Type.EmptyTypes));

            deflateMethod = (DeflateDelegate)Delegate.CreateDelegate(
                typeof(DeflateDelegate),
                deflaterInstance,
                type.GetMethod("Deflate", new Type[] { typeof(byte[]) }));

            resetMethod = (ResetDelegate)Delegate.CreateDelegate(
                typeof(ResetDelegate),
                deflaterInstance,
                type.GetMethod("Reset", Type.EmptyTypes));

            getIsNeedingInputMethod = (GetIsNeedingInputDelegate)Delegate.CreateDelegate(
                typeof(GetIsNeedingInputDelegate),
                deflaterInstance,
                type.GetMethod("get_IsNeedingInput", Type.EmptyTypes));

            deflate3Method = (DeflateDelegate3)Delegate.CreateDelegate(
                typeof(DeflateDelegate3),
                deflaterInstance,
                type.GetMethod("Deflate", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));
        }
Example #15
0
        public InGameMenu(ResetDelegate resetDelegate)
        {
            this.resetDelegate = resetDelegate;
            this.buttons       = new ColouredButton[2];
            int startX = 1000 - 25;
            ColouredButtonParams buttonParams = new ColouredButtonParams();

            buttonParams.Font            = ResourceManager.getInstance().Font;
            buttonParams.LinesTexture    = ResourceManager.getInstance().ButtonsLineTexture;
            buttonParams.Height          = ResourceManager.BUTTONS_HEIGHT;
            buttonParams.Width           = ResourceManager.BUTTONS_WIDTH + 75;  // These buttons are a little wider
            buttonParams.MouseOverColour = ResourceManager.getInstance().ButtonsMouseOverColour;
            buttonParams.RegularColour   = ResourceManager.getInstance().TextColour;

            buttonParams.ID            = BUTTON_ID_RETURN_TO_GAME;
            buttonParams.StartX        = startX;
            buttonParams.StartY        = 500;
            buttonParams.Text          = "Return to Game";
            buttonParams.TextsPosition = new Vector2(startX + 35f, buttonParams.StartY + ResourceManager.BUTTONS_TEXT_Y_DIFFERENCE);
            this.buttons[0]            = new ColouredButton(buttonParams);

            buttonParams.ID            = BUTTON_ID_EXIT_TO_MAIN_MENU;
            buttonParams.StartX        = startX;
            buttonParams.StartY        = 575;
            buttonParams.Text          = "Exit to Main Menu";
            buttonParams.TextsPosition = new Vector2(startX + 20f, buttonParams.StartY + ResourceManager.BUTTONS_TEXT_Y_DIFFERENCE);
            this.buttons[1]            = new ColouredButton(buttonParams);
#if WINDOWS
#if DEBUG
            if (this.buttons != null)
            {
                for (int i = 0; i < this.buttons.Length; i++)
                {
                    ScriptManager.getInstance().registerObject(this.buttons[i], "igmButton" + i);
                }
            }
#endif
#endif
        }
Example #16
0
        /// <summary>
        /// Starts resetting session. Messages marked for deletion will be unmarked.
        /// </summary>
        /// <param name="callback">Callback to call when the asynchronous operation is complete.</param>
        /// <param name="state">User data.</param>
        /// <returns>An IAsyncResult that references the asynchronous operation.</returns>
        /// <exception cref="ObjectDisposedException">Is raised when this object is disposed and this method is accessed.</exception>
        /// <exception cref="InvalidOperationException">Is raised when POP3 client is not connected and authenticated.</exception>
        public IAsyncResult BeginReset(AsyncCallback callback, object state)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }
            if (!IsConnected)
            {
                throw new InvalidOperationException("You must connect first.");
            }
            if (!IsAuthenticated)
            {
                throw new InvalidOperationException("The RSET command is only valid in authenticated state.");
            }

            ResetDelegate    asyncMethod = Reset;
            AsyncResultState asyncState  = new AsyncResultState(this, asyncMethod, callback, state);

            asyncState.SetAsyncResult(asyncMethod.BeginInvoke(asyncState.CompletedCallback, null));

            return(asyncState);
        }
Example #17
0
 public Resettable(T value, ResetDelegate resetDelegate)
 {
     _resetDelegate = resetDelegate;
     Value          = value;
 }
Example #18
0
        /// <summary>
        /// Подпрограмма открытия платы
        /// </summary>
        /// <param name="serialNumber"></param>
        public int Open(ushort serialNumber)
        {
            // Выделение памяти в неуправляемой памяти процесса
            // var pnt = Marshal.AllocHGlobal( Marshal.SizeOf( zzz ) );
            // Копирование структуры zzz в неуправляемую память
            // Marshal.StructureToPtr( zzz, pnt, false );
            // Возврат структуры из неупраяляемой памяти
            // var zzz1 = ( pci429_4_tag) Marshal.PtrToStructure( pnt, typeof( pci429_4_tag ) );
            // Освобождение неуправляемой памяти
            // Marshal.FreeHGlobal( pnt );

            var error = 0;

            // Synchronously wait to enter the Semaphore.
            SemaphoreSlim.Wait();
            // Get handle to .dll file
            _dllhandle = NativeMethods.LoadLibrary(NameDll);
            if (_dllhandle == IntPtr.Zero)
            {
                // Handle error loading
                error = 1;
            }
            else
            {
                // Get handle to Open method in .dll file
                var open_handle = NativeMethods.GetProcAddress(_dllhandle, "pci429_4_open");
                if (open_handle == IntPtr.Zero)
                {
                    error = 2;
                }
                else
                {
                    _open = ( OpenDelegate )Marshal.GetDelegateForFunctionPointer(
                        open_handle, typeof(OpenDelegate));
                    if (_open == null)
                    {
                        error = 3;
                    }
                }
                // Get handle to Close method in .dll file
                var close_handle = NativeMethods.GetProcAddress(_dllhandle, "pci429_4_close");
                if (close_handle == IntPtr.Zero)
                {
                    error = 4;
                }
                else
                {
                    _close = ( CloseDelegate )Marshal.GetDelegateForFunctionPointer(close_handle,
                                                                                    typeof(CloseDelegate));
                    if (_close == null)
                    {
                        error = 5;
                    }
                }
                // Get handle to Start method in .dll file
                var start_handle = NativeMethods.GetProcAddress(_dllhandle, "pci429_4_start");
                if (start_handle == IntPtr.Zero)
                {
                    error = 6;
                }
                else
                {
                    _start = ( StartDelegate )Marshal.GetDelegateForFunctionPointer(start_handle,
                                                                                    typeof(StartDelegate));
                    if (_start == null)
                    {
                        error = 7;
                    }
                }
                // Get handle to Reset method in .dll file
                var reset_handle = NativeMethods.GetProcAddress(_dllhandle, "pci429_4_reset");
                if (reset_handle == IntPtr.Zero)
                {
                    error = 8;
                }
                else
                {
                    _reset = ( ResetDelegate )Marshal.GetDelegateForFunctionPointer(reset_handle,
                                                                                    typeof(ResetDelegate));
                    if (_reset == null)
                    {
                        error = 9;
                    }
                }
                // Get handle to Config method in .dll file
                var config_handle = NativeMethods.GetProcAddress(_dllhandle, "pci429_4_set_freq");
                if (config_handle == IntPtr.Zero)
                {
                    error = 10;
                }
                else
                {
                    _config = ( ConfigDelegate )Marshal.GetDelegateForFunctionPointer(config_handle,
                                                                                      typeof(ConfigDelegate));
                    if (_config == null)
                    {
                        error = 11;
                    }
                }
                // Get handle to Read method in .dll file
                var read_handle = NativeMethods.GetProcAddress(_dllhandle, "pci429_4_read_rx");
                if (read_handle == IntPtr.Zero)
                {
                    error = 12;
                }
                else
                {
                    _read = ( ReadDelegate )Marshal.GetDelegateForFunctionPointer(read_handle,
                                                                                  typeof(ReadDelegate));
                    if (_read == null)
                    {
                        error = 13;
                    }
                }
                // Get handle to Write method in .dll file
                var write_handle = NativeMethods.GetProcAddress(_dllhandle, "pci429_4_write_tx");
                if (write_handle == IntPtr.Zero)
                {
                    error = 14;
                }
                else
                {
                    _write = ( WriteDelegate )Marshal.GetDelegateForFunctionPointer(write_handle,
                                                                                    typeof(WriteDelegate));
                    if (_write == null)
                    {
                        error = 15;
                    }
                }
                // Get handle to CheckTx method in .dll file
                var check_tx_handle = NativeMethods.GetProcAddress(_dllhandle, "pci429_4_check_tx");
                if (check_tx_handle == IntPtr.Zero)
                {
                    error = 16;
                }
                else
                {
                    _checkTx = ( CheckTxDelegate )Marshal.GetDelegateForFunctionPointer(check_tx_handle,
                                                                                        typeof(CheckTxDelegate));
                    if (_checkTx == null)
                    {
                        error = 17;
                    }
                }
                // Get handle to GetDevice method in .dll file
                var get_device_handle = NativeMethods.GetProcAddress(_dllhandle, "pci429_4_get_dev_list");
                if (get_device_handle == IntPtr.Zero)
                {
                    error = 18;
                }
                else
                {
                    _getDeviceList = ( GetDeviceDelegate )Marshal.GetDelegateForFunctionPointer(get_device_handle,
                                                                                                typeof(GetDeviceDelegate));
                    if (_getDeviceList == null)
                    {
                        error = 19;
                    }
                }
                // Открытие устройства
                error += _open?.Invoke(serialNumber, out _device) ?? int.MaxValue;
                if (_device.handle == ( IntPtr )0)
                {
                    error = 18;
                }
            }
            // Release the Semaphore.
            SemaphoreSlim.Release();
            return(error);
        }
Example #19
0
        internal Deflater(object deflaterInstance)
        {
            Type type = deflaterInstance.GetType();

            setLevelMethod = (SetLevelDelegate)Delegate.CreateDelegate(
                typeof(SetLevelDelegate),
                deflaterInstance,
                type.GetMethod("SetLevel", new Type[] { typeof(int) }));

            setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
                typeof(SetInputDelegate),
                deflaterInstance,
                type.GetMethod("SetInput", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));

            finishMethod = (FinishDelegate)Delegate.CreateDelegate(
                typeof(FinishDelegate),
                deflaterInstance,
                type.GetMethod("Finish", Type.EmptyTypes));

            getIsFinishedMethod = (GetIsFinishedDelegate)Delegate.CreateDelegate(
                typeof(GetIsFinishedDelegate),
                deflaterInstance,
                type.GetMethod("get_IsFinished", Type.EmptyTypes));

            deflateMethod = (DeflateDelegate)Delegate.CreateDelegate(
                typeof(DeflateDelegate),
                deflaterInstance,
                type.GetMethod("Deflate", new Type[] { typeof(byte[]) }));

            resetMethod = (ResetDelegate)Delegate.CreateDelegate(
                typeof(ResetDelegate),
                deflaterInstance,
                type.GetMethod("Reset", Type.EmptyTypes));

            getIsNeedingInputMethod = (GetIsNeedingInputDelegate)Delegate.CreateDelegate(
                typeof(GetIsNeedingInputDelegate),
                deflaterInstance,
                type.GetMethod("get_IsNeedingInput", Type.EmptyTypes));

            deflate3Method = (DeflateDelegate3)Delegate.CreateDelegate(
                typeof(DeflateDelegate3),
                deflaterInstance,
                type.GetMethod("Deflate", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));
        }
 static RuntimeFunctions()
 {
     _reset                = MarshalEx.CreateDelegate <ResetDelegate>((byte *)RuntimeEnvironment.ClrModuleHandle + METHODDESC_RESET_RVA);
     _doPrestub            = MarshalEx.CreateDelegate <DoPrestubDelegate>((byte *)RuntimeEnvironment.ClrModuleHandle + METHODDESC_DOPRESTUB_RVA);
     _getWrappedMethodDesc = MarshalEx.CreateDelegate <GetWrappedMethodDescDelegate>((byte *)RuntimeEnvironment.ClrModuleHandle + METHODDESC_GETWRAPPEDMETHODDESC_RVA);
 }
Example #21
0
 /// <summary>
 ///     Creates an empty pool with the specified object creation and reset delegates.
 /// </summary>
 public Pool(CreateDelegate <T> create, ResetDelegate <T> reset)
 {
     this.create = create;
     this.reset  = reset;
 }
Example #22
0
        public IAsyncResult BeginReset(AsyncCallback callback,object state)
        {
            if(this.IsDisposed){
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if(!this.IsConnected){
				throw new InvalidOperationException("You must connect first.");
			}

            ResetDelegate asyncMethod = new ResetDelegate(this.Reset);
            AsyncResultState asyncState = new AsyncResultState(this,asyncMethod,callback,state);
            asyncState.SetAsyncResult(asyncMethod.BeginInvoke(new AsyncCallback(asyncState.CompletedCallback),null));

            return asyncState;
        }
 public void SetResetMethod(ResetDelegate method)
 {
     _resetMethod = method;
 }