예제 #1
0
        public void Add(IMemoryCallback callback)
        {
            if (!AvailableScopes.Contains(callback.Scope))
            {
                throw new InvalidOperationException($"{callback.Scope} is not currently supported for callbacks");
            }

            if (!callback.Address.HasValue)
            {
                throw new NotImplementedException("Wildcard callbacks (no address specified) not currently implemented.");
            }

            var container = new CallbackContainer(callback);

            if (container.Callback.Type == MemoryCallbackType.Execute)
            {
                _executeCallback = RunExecCallback;
                _execPcs[callback.Address.Value] = callback;
                MGBAHawk.ZZHacky.BizSetExecCallback(_mgba.Core, _executeCallback);
            }
            else
            {
                MGBAHawk.ZZHacky.BizSetMemCallback(_mgba.Core, container.CallDelegate);
                container.ID = MGBAHawk.ZZHacky.BizSetWatchpoint(_mgba.Core, callback.Address.Value, container.WatchPointType);
            }

            _callbacks.Add(container);
        }
예제 #2
0
        public OAuth2ResourceProvider AddRequestScope <TRequest>()
            where TRequest : OAuthRequest, new()
        {
            var request = new TRequest();

            foreach (var scope in request.RequiredScopes)
            {
                if (!AvailableScopes.Contains(scope))
                {
                    throw new InvalidScopeException(string.Format(
                                                        StringResources.ScopeException,
                                                        scope,
                                                        this.GetType().Name));
                }
                if (!Scopes.Contains(scope))
                {
                    Scopes.Add(scope);
                }
            }

            return(this);
        }