Пример #1
0
 public Callback(DispatchDelegate <T> func, bool bGameServer = false)
 {
     this.m_pVTable     = IntPtr.Zero;
     this.m_size        = Marshal.SizeOf(typeof(T));
     this.m_bGameServer = bGameServer;
     this.BuildCCallbackBase();
     this.Register(func);
 }
Пример #2
0
        public Callback(DispatchDelegate myFunc)
            : this()
        {
            if (myFunc == null)
            {
                throw new Exception("Function must not be null.");
            }

            this.m_Func += myFunc;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of <see cref="Store{TState}"/> class.
        /// </summary>
        /// <param name="reducer">
        /// A reducing object that returns the next state tree.
        /// </param>
        /// <param name="initialState">
        /// The initial state.
        /// </param>
        /// <param name="middlewares">
        /// Functions that conform to the Redux middleware API.
        /// </param>
        public Store(IReducer <TState> reducer, TState initialState = default(TState), params MiddlewareDelegate <TState>[] middlewares)
        {
            _reducer  = reducer ?? throw new ArgumentNullException(nameof(reducer));
            _dispatch = ApplyMiddlewares(middlewares);

            if (initialState != null)
            {
                State = initialState;
            }
            else
            {
                _dispatch(new ReduxInitialAction());
            }
        }
Пример #4
0
 /// <summary>
 /// Invokes the action from the bottom of the document dependency chain up
 /// to the top, for each provider under it in the chain.
 /// </summary>
 /// <remarks>
 /// OrderByLeastDependent is implement in the ChainOfDependency
 /// (not a GoF pattern), it walks the tree of dependencies in this case the
 /// least dependent would be first.  The Chain of Responsiblity pattern is
 /// invoke by the inherited member 'Dispatch' which is called for each
 /// dependency.
 /// </remarks>
 /// <param name="action">The action to perform.</param>
 /// <param name="document">The document to perform it on.</param>
 private bool OrderByLeastDependent(DispatchDelegate action, Document document)
 {
     return(ChainOfDependencies <Document> .OrderByLeastDependent(
                document,
                delegate(Document member)
     {
         return this.Dispatch(delegate(
                                  IDocumentController controller,
                                  Document subject)
         {
             return action(controller, subject);
         },
                              member);
     }));
 }
Пример #5
0
 public void Register(DispatchDelegate <T> func)
 {
     if (func == null)
     {
         throw new Exception("Callback function must not be null.");
     }
     if ((this.m_CCallbackBase.m_nCallbackFlags & 1) == 1)
     {
         this.Unregister();
     }
     if (this.m_bGameServer)
     {
         this.SetGameserverFlag();
     }
     this.m_Func = func;
     NativeMethods.SteamAPI_RegisterCallback(this.m_pCCallbackBase.AddrOfPinnedObject(), CallbackIdentities.GetCallbackIdentity(typeof(T)));
 }
        // Manual registration of the callback
        public void Register(DispatchDelegate func)
        {
            if (func == null)
            {
                throw new Exception("Callback function must not be null.");
            }

            if ((m_CCallbackBase.m_nCallbackFlags & CCallbackBase.k_ECallbackFlagsRegistered) == CCallbackBase.k_ECallbackFlagsRegistered)
            {
                Unregister();
            }

            if (m_bGameServer)
            {
                SetGameserverFlag();
            }

            m_Func = func;

            // k_ECallbackFlagsRegistered is set by SteamAPI_RegisterCallback.
            NativeMethods.SteamAPI_RegisterCallback(m_pCCallbackBase.AddrOfPinnedObject(), CallbackIdentities.GetCallbackIdentity(typeof(T)));
        }
Пример #7
0
        public Callback(DispatchDelegate func, bool bGameServer = false, bool bKeepAlive = true)
        {
            m_bGameServer = bGameServer;
            BuildCCallbackBase();
            Register(func);

            // This is a temporary hack to preserve backwards compatability with the old CallbackDispatcher.
            // If this is still here in 5.0.0 yell at me.
            if (bKeepAlive)
            {
                if (!bWarnedOnce)
                {
                    bWarnedOnce = true;
                    const string deprecatedMsg = "Please use the new (as of 3.0.0) api for creating Callbacks. Callback<Type>.Create(func). You must now maintain a handle to the callback so that the GC does not clean it up prematurely.";
#if UNITY_BUILD
                    UnityEngine.Debug.LogWarning(deprecatedMsg);
#else
                    throw new System.InvalidOperationException(deprecatedMsg);
#endif
                }

                GCKeepAlive.Add(this);
            }
        }
Пример #8
0
 public void Register(DispatchDelegate func)
 {
 }
Пример #9
0
 public static Callback <T> CreateGameServer(DispatchDelegate func) => default;
Пример #10
0
        }                            // Dummy constructor

        public Callback(DispatchDelegate func, bool bGameServer = false /* Metadata: 0x00650B29 */)
        {
        }
Пример #11
0
 public static Callback <T> Create(DispatchDelegate func)
 {
     return(new Callback <T>(func, false));
 }
 /// <summary>
 /// Creates a new GameServer Callback. You must be calling GameServer.RunCallbacks() to retrieve the callbacks.
 /// <para>Returns a handle to the Callback. This must be assigned to a member variable to prevent the GC from cleaning it up.</para>
 /// </summary>
 public static Callback <T> CreateGameServer(DispatchDelegate func)
 {
     return(new Callback <T>(func, bGameServer: true));
 }
Пример #13
0
 public DummyMiddleware(IStore <TState> store, DispatchDelegate next)
 {
     _store = store;
     _next  = next;
 }
Пример #14
0
 public static Callback <T> Create(DispatchDelegate <T> func) =>
 new Callback <T>(func, false);
Пример #15
0
 /// <summary>
 /// Creates a new Callback. You must be calling SteamAPI.RunCallbacks() to retrieve the callbacks.
 /// <para>Returns a handle to the Callback. This must be assigned to a member variable to prevent the GC from cleaning it up.</para>
 /// </summary>
 public static Callback <T> Create(DispatchDelegate func) => new Callback <T>(func);
Пример #16
0
 public static extern void AsyncFunction(IntPtr queue, IntPtr context, DispatchDelegate work);
Пример #17
0
 public static Callback <T> Create(DispatchDelegate func)
 {
     return(new Callback <T>(func, bGameServer: false, bKeepAlive: false));
 }
Пример #18
0
 public Callback(DispatchDelegate myFunc) : this()
 {
 }
Пример #19
0
 public LoggerMiddleware(IStore <TState> store, DispatchDelegate next, LoggerOptions options)
 {
     _store   = store;
     _next    = next;
     _options = options;
 }
Пример #20
0
 public Callback(DispatchDelegate myFunc, int iCallback)
     : this( iCallback )
 {
     this.OnRun += myFunc;
 }
Пример #21
0
 public static Callback <T> CreateGameServer(DispatchDelegate <T> func) =>
 new Callback <T>(func, true);
Пример #22
0
 public Callback(DispatchDelegate myFunc)
     : this()
 {
     this.OnRun += myFunc;
 }
Пример #23
0
 /// <summary>
 /// 将一个方法延迟到主线程中运行
 /// </summary>
 /// <param name="function"></param>
 /// <param name="param"></param>
 public void Dispatch(DispatchDelegate function, object param = null)
 {
     dispathMessageQueue.Enqueue(new DispatchMessage(function, param));
 }
Пример #24
0
 public DispatchMessage(DispatchDelegate f, object p)
 {
     function = f;
     param    = p;
 }
 public Callback(DispatchDelegate func, bool bGameServer = false)
 {
     m_bGameServer = bGameServer;
     BuildCCallbackBase();
     Register(func);
 }
Пример #26
0
 protected override Task <DataWithStateCode> ProcessHandler(TRequest header, RequestContext <TRequest> context, CancellationToken token)
 {
     _cacheDispatcher = _cacheDispatcher ?? GenerateMethod(ExecutionSide);
     return(_cacheDispatcher(this, header, context, token));
 }