コード例 #1
0
        private void _Request(string url, SLRequestMethod method, Dictionary <object, object> parameters, Action <object, NSHTTPURLResponse, NSError> callback)
        {
            _service.RequestAccessToAccounts(_accountType, _options, delegate(bool granted, NSError error) {
                CoreXT.RunOnMainThread(delegate() {
                    if (granted)
                    {
                        var account = _service.FindAccounts(_accountType)[0] as ACAccount;
                        var request = SLRequest.Request(
                            _serviceType,
                            method,
                            new NSURL(url),
                            parameters);
                        request.account = account;
//						Debug.Log("prepared url: " + request.PreparedURLRequest().URL().AbsoluteString() + "\n" + Json.Serialize(request.PreparedURLRequest().AllHTTPHeaderFields())
//						          + "\n" + request.PreparedURLRequest().HTTPBody().ToByteArray().ToStraightString());

                        request.PerformRequest(delegate(NSData responseData, NSHTTPURLResponse urlResponse, NSError error2) {
                            object obj   = null;
                            var response = Encoding.UTF8.GetString(responseData.ToByteArray());
                            try {
                                obj = Json.Deserialize(response);
                            } catch (Exception) {
                                obj = response;
                            }
                            callback(obj, urlResponse, error2);
                            callback = null;
                        });

                        parameters = null;
                        account    = null;
                        request    = null;
                    }
                    else
                    {
                        callback(null, null, error);
                        parameters = null;
                        callback   = null;
                    }
                });
            });
        }
コード例 #2
0
ファイル: SLRequest.cs プロジェクト: zippo227/xamarin-macios
 public static SLRequest Create(SLServiceKind serviceKind, SLRequestMethod method, NSUrl url, NSDictionary parameters)
 {
     return(Create(KindToType(serviceKind), method, url, parameters));
 }
コード例 #3
0
 public static SLRequest Create(SLServiceKind serviceKind, SLRequestMethod method, NSUrl url, NSDictionary parameters)
 {
     return Create (KindToType (serviceKind), method, url, parameters);
 }
コード例 #4
0
        private void _Request(string url, SLRequestMethod method, Dictionary<object, object> parameters, Action<object, NSHTTPURLResponse, NSError> callback)
        {
            _service.RequestAccessToAccounts(_accountType, _options, delegate(bool granted, NSError error) {
                if (granted) {
                    var account = _service.FindAccounts(_accountType)[0] as ACAccount;
                    var request = SLRequest.Request(
                        _serviceType,
                        method,
                        new NSURL(url),
                        parameters);
                    request.account = account;

                    request.PerformRequest(delegate(NSData responseData, NSHTTPURLResponse urlResponse, NSError error2) {
                        object obj = null;
                        var response = Encoding.UTF8.GetString(responseData.ToByteArray());
                        try {
                            obj = Json.Deserialize(response);
                        } catch (Exception) {
                            obj = response;
                        }
                        callback(obj, urlResponse, error2);
                        callback = null;
                    });

                    parameters = null;
                    account = null;
                    request = null;
                } else {
                    callback(null, null, error);
                    parameters = null;
                    callback = null;
                }
            });
        }