コード例 #1
0
 public static void DownloadXml(string url, DownloadSettings settings, Action <XDocument> success, Failed failure)
 {
     // download a regular document...
     Download(url, settings, new Action <string>(delegate(string xml) {
         // turn into into a proper document and return...
         XDocument doc = XDocument.Parse(xml);
         success(doc);
     }), failure);
 }
コード例 #2
0
        protected DownloadSettings GetDownloadSettings()
        {
            DownloadSettings settings = new DownloadSettings();
            settings.ExtraHeaders["x-amx-apiusername"] = ApiUsername;
            if (!(string.IsNullOrEmpty(Token)))
                settings.ExtraHeaders["x-amx-token"] = Token;

            // return...
            return settings;
        }
コード例 #3
0
        public static void DownloadXml(string url, DownloadSettings settings, Action<XDocument> success, Failed failure)
        {
            // download a regular document...
            Download(url, settings, new Action<string>(delegate(string xml) {

                // turn into into a proper document and return...
                XDocument doc = XDocument.Parse(xml);
                success(doc);
                    
            }), failure);
        }
コード例 #4
0
        protected DownloadSettings GetDownloadSettings()
        {
            DownloadSettings settings = new DownloadSettings();

            settings.ExtraHeaders["x-amx-apiusername"] = ApiUsername;
            if (!(string.IsNullOrEmpty(Token)))
            {
                settings.ExtraHeaders["x-amx-token"] = Token;
            }

            // return...
            return(settings);
        }
コード例 #5
0
        private void ExecuteODataOperation(ODataOperation opType, String url, String xml, Action callback, Failed failed)
        {
            // create the request...
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            // set the method...
            if (opType == ODataOperation.Insert)
            {
                request.Method = "POST";
            }
            else if (opType == ODataOperation.Update)
            {
                request.Method = "MERGE";
            }
            else if (opType == ODataOperation.Delete)
            {
                request.Method = "DELETE";
            }
            else
            {
                throw new NotSupportedException(string.Format("Cannot handle '{0}'.", opType));
            }

            // headers... (including our special tokens)...
            DownloadSettings settings = this.GetDownloadSettings();

            foreach (string name in settings.ExtraHeaders.Keys)
            {
                request.Headers[name] = settings.ExtraHeaders[name];
            }

            // create a state object...
            ODataRequestState state = new ODataRequestState();

            state.Request     = request;
            state.Callback    = callback;
            state.Failed      = failed;
            state.OutboundXml = xml;

            // do we have xml?
            if (!(string.IsNullOrEmpty(xml)))
            {
                byte[] bs = Encoding.UTF8.GetBytes(xml);
                request.ContentType = "application/atom+xml";
                request.BeginGetRequestStream(new AsyncCallback(HandleOutboundXmlRequest), state);
            }
            else
            {
                request.BeginGetResponse(new AsyncCallback(HandleODataOperationResponse), state);
            }
        }
コード例 #6
0
        public static void Download(string url, DownloadSettings settings, Action<string> success, Failed failure)
        {
            // create the request stub...
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            // add...
            if (settings != null)
            {
                foreach (string name in settings.ExtraHeaders.Keys)
                    request.Headers[name] = settings.ExtraHeaders[name];
            }

            // call the server... we'll get notified at some point...
            request.BeginGetResponse(new AsyncCallback(HandleDownloadResult), new object[] { request, success, failure });
        }
コード例 #7
0
        public static void Download(string url, DownloadSettings settings, Action <string> success, Failed failure)
        {
            // create the request stub...
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            // add...
            if (settings != null)
            {
                foreach (string name in settings.ExtraHeaders.Keys)
                {
                    request.Headers[name] = settings.ExtraHeaders[name];
                }
            }

            // call the server... we'll get notified at some point...
            request.BeginGetResponse(new AsyncCallback(HandleDownloadResult), new object[] { request, success, failure });
        }