コード例 #1
0
        public void Logon(String username, String password, Action <LogonResponse> callback, Failed failed)
        {
            // create the request...
            RestRequestArgs args = new RestRequestArgs("logon");

            // add the username and password...
            args["username"] = username;
            args["password"] = password;

            // send the request...
            SendRequest(args, delegate(XElement element)
            {
                // create a result from that...
                LogonResponse response = LogonResponse.FromXmlElement(element);
                if (response == null)
                {
                    throw new InvalidOperationException("'response' is null.");
                }

                // callback...
                callback(response);
            }, failed);
        }
コード例 #2
0
        internal void SendRequest(RestRequestArgs args, Action <XElement> success, Failed failed)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            if (success == null)
            {
                throw new ArgumentNullException("success");
            }
            if (failed == null)
            {
                throw new ArgumentNullException("failed");
            }

            // create a request state...
            RequestState state = new RequestState()
            {
                Owner   = this,
                Args    = args,
                Success = success,
                Failed  = failed
            };

            // are we authenticated?  if we're not, we need to call that first...
            if (!(IsAuthenticated))
            {
                // call the authenticate routine, and ask it to call the state we just setup
                // if authentication works...
                ApiService.Authenticate(new Action(state.DoRequest), failed);
            }
            else
            {
                // call the method directly...
                state.DoRequest();
            }
        }