public void CompleteDeposit(string endpoint, UploadDataCompletedEventHandler completed, UploadProgressChangedEventHandler changed) { this.Headers["In-Progress"] = "false"; this.UploadDataCompleted += completed; this.UploadProgressChanged += changed; UploadDataAsync(new Uri(endpoint), "POST", new byte[0]); }
/// <summary>Uploads data to the specified resource, asynchronously.</summary> /// <param name="webClient">The WebClient.</param> /// <param name="address">The URI to which the data should be uploaded.</param> /// <param name="method">The HTTP method that should be used to upload the data.</param> /// <param name="data">The data to upload.</param> /// <returns>A Task containing the data in the response from the upload.</returns> public static Task <byte[]> UploadDataTask(this WebClient webClient, Uri address, string method, byte [] data) { // Create the task to be returned var tcs = new TaskCompletionSource <byte[]>(address); // Setup the callback event handler UploadDataCompletedEventHandler handler = null; handler = (sender, e) => EAPCommon.HandleCompletion(tcs, e, () => e.Result, () => webClient.UploadDataCompleted -= handler); webClient.UploadDataCompleted += handler; // Start the async work try { webClient.UploadDataAsync(address, method, data, tcs); } catch (Exception exc) { // If something goes wrong kicking off the async work, // unregister the callback and cancel the created task webClient.UploadDataCompleted -= handler; tcs.TrySetException(exc); } // Return the task that represents the async operation return(tcs.Task); }
/// <summary> /// Http同步Post异步请求 /// </summary> /// <param name="url">Url地址</param> /// <param name="postStr">请求Url数据</param> /// <param name="callBackUploadDataCompleted">回调事件</param> /// <param name="encode"></param> public void HttpPostAsync(string url, string postStr = "", UploadDataCompletedEventHandler callBackUploadDataCompleted = null, Encoding encode = null) { try { var webClient = new WebClient { Encoding = Encoding.UTF8 }; if (encode != null) { webClient.Encoding = encode; } var sendData = Encoding.GetEncoding("GB2312").GetBytes(postStr); webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); webClient.Headers.Add("ContentLength", sendData.Length.ToString(CultureInfo.InvariantCulture)); if (callBackUploadDataCompleted != null) { webClient.UploadDataCompleted += callBackUploadDataCompleted; } webClient.UploadDataAsync(new Uri(url), "POST", sendData); } catch (Exception e) { } }
/// <summary> /// <paramref name="address"/>에 <paramref name="data"/>를 비동기적으로 전송합니다. /// </summary> /// <param name="webClient"></param> /// <param name="address">데이타를 전송할 주소</param> /// <param name="method">데이타 전송 방법 (HTTP는 POST, FTP는 STOR)</param> /// <param name="data">전송할 데이타</param> /// <returns></returns> public static Task <byte[]> UploadDataTask(this WebClient webClient, Uri address, string method, byte[] data) { webClient.ShouldNotBeNull("webClient"); address.ShouldNotBeNull("address"); data.ShouldNotBeNull("data"); if (IsDebugEnabled) { log.Debug("지정된 주소에 데이타를 비동기 방식으로 전송합니다... address=[{0}], method=[{1}]", address.AbsoluteUri, method); } var tcs = new TaskCompletionSource <byte[]>(address); UploadDataCompletedEventHandler handler = null; handler = (s, e) => EventAsyncPattern.HandleCompletion(tcs, e, () => e.Result, () => webClient.UploadDataCompleted -= handler); webClient.UploadDataCompleted += handler; try { webClient.UploadDataAsync(address, method ?? "POST", data, tcs); } catch (Exception ex) { if (log.IsWarnEnabled) { log.Warn("WebClient를 이용하여 데이타를 비동기 전송에 실패했습니다. address=[{0}]" + address.AbsoluteUri); log.Warn(ex); } webClient.UploadDataCompleted -= handler; tcs.TrySetException(ex); } return(tcs.Task); }
public static void CallApi(EnumApi api, UploadDataCompletedEventHandler strHandler, object obj) { using (WebClient client = new WebClient()) { #region 消息头 client.Headers["Type"] = "Post"; client.Headers.Add("Content-Type", ConfigurationManager.AppSettings["Content-Type"]); client.Encoding = Encoding.UTF8; #endregion #region PostData string postData = JsonConvert.SerializeObject(obj); byte[] bytes = Encoding.UTF8.GetBytes(postData); client.Headers.Add("ContentLength", postData.Length.ToString()); #endregion #region 回调处理 client.UploadDataCompleted += strHandler; #endregion string uriString = GetConfigValue(api); if (!string.IsNullOrEmpty(uriString)) { client.UploadDataAsync(new Uri(GetConfigValue(api)), bytes); } } }
/// <summary> /// Post异步请求 /// </summary> /// <param name="url">Url地址</param> /// <param name="postStr">请求Url数据</param> /// <param name="callBackUploadDataCompleted">回调事件</param> /// <param name="encode"></param> public static void HttpPostAsync(string url, string postStr = "", UploadDataCompletedEventHandler callBackUploadDataCompleted = null, Encoding encode = null, Dictionary <string, string> heards = null) { var webClient = new WebClient { Encoding = Encoding.UTF8 }; if (encode != null) { webClient.Encoding = encode; } var sendData = Encoding.GetEncoding("UTF-8").GetBytes(postStr); webClient.Headers.Add("Content-Type", "application/json"); webClient.Headers.Add("ContentLength", sendData.Length.ToString(CultureInfo.InvariantCulture)); if (heards != null) { foreach (var item in heards) { webClient.Headers.Add(item.Key, item.Value); } } if (callBackUploadDataCompleted != null) { webClient.UploadDataCompleted += callBackUploadDataCompleted; } webClient.UploadDataAsync(new Uri(url), "POST", sendData); }
/// <summary> /// 以用户名或邮箱查询用户 /// </summary> /// <param name="users"></param> /// <returns></returns> public Dictionary <string, string> IsAdmitted(AspNetUser users, UploadDataCompletedEventHandler callback) { try { WebClient client = new WebClient { Encoding = Encoding.UTF8 }; StringBuilder postData = new StringBuilder(); postData.Append($"Id={users.UserName} "); postData.Append($"&pass={users.PasswordHash}"); byte[] sendData = Encoding.UTF8.GetBytes(postData.ToString()); client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); client.Headers.Add("ContentLength", sendData.Length.ToString()); //var recData = client.UploadData(ConfigurationManager.AppSettings["loginVerification"], "POST",sendData); client.UploadDataAsync(new Uri(ConfigurationManager.AppSettings["loginVerification"]), "POST", sendData); client.UploadDataCompleted += callback; // string aaaa = Encoding.UTF8.GetString(aa); //client.Dispose(); return(null); } catch (Exception ex) { return(new Dictionary <string, string> { { "Errors", ex.Message } }); } }
/// <summary> /// Method to access WebGrid Sms Service. Internal use only.. /// </summary> /// <param name="sender">Sender address, must be alfanumeric string with no more then 11 characters and no special characters.</param> /// <param name="receiver">The receivers cellphone number, can be Separated by ";" and all numbers must be written with international number. See documentation for further information.</param> /// <param name="message">The message you want to send. All messages with more then 160 characters will be split.</param> /// <param name="eventhandler">The eventhandler.</param> /// <param name="userToken">The user token.</param> /// <remarks> /// Using the receiver parameter you must include country number, area number, and local number. Example could be "4712345678", where /// "47" is the norwegian country code and 12345678 is area and local number. /// Any errors are logged at Windows EventLog (Application category). /// </remarks> private void internalSendSms(string sender, string receiver, string message, UploadDataCompletedEventHandler eventhandler, object userToken) { const string webgridSMSService = "http://traffic.webgrid.com/send.aspx"; string urlRequestform = string.Format("customerID={0}", HttpUtility.UrlEncode(customerId, Encoding.Default)); if (string.IsNullOrEmpty(password) == false) { urlRequestform += string.Format("&password={0}", HttpUtility.UrlEncode(password, Encoding.Default)); } if (string.IsNullOrEmpty(sender) == false) { urlRequestform += string.Format("&sender={0}", HttpUtility.UrlEncode(sender, Encoding.Default)); } if (string.IsNullOrEmpty(receiver) == false) { urlRequestform += string.Format("&receiver={0}", HttpUtility.UrlEncode(receiver, Encoding.Default)); } if (string.IsNullOrEmpty(message) == false) { urlRequestform += string.Format("&message={0}", HttpUtility.UrlEncode(message, Encoding.Default)); } urlRequestform += "&messagetypeID=1&__Active=true"; webgridurl.OpenUrl(webgridSMSService, urlRequestform, eventhandler, userToken); }
public void CompleteDeposit(string endpoint, UploadDataCompletedEventHandler completed, UploadProgressChangedEventHandler changed) { this.Headers["In-Progress"] = "false"; this.UploadDataCompleted += completed; this.UploadProgressChanged += changed; UploadDataAsync(new Uri(endpoint), "POST", new byte[0]); }
/// <summary> /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed. /// <example> /// uploaddatacompletedeventhandler.BeginInvoke(sender, e, callback); /// </example> /// </summary> public static IAsyncResult BeginInvoke(this UploadDataCompletedEventHandler uploaddatacompletedeventhandler, Object sender, UploadDataCompletedEventArgs e, AsyncCallback callback) { if (uploaddatacompletedeventhandler == null) { throw new ArgumentNullException("uploaddatacompletedeventhandler"); } return(uploaddatacompletedeventhandler.BeginInvoke(sender, e, callback, null)); }
/// <summary> /// This event is raised each time an asynchronous data upload operation completes /// </summary> private void Gett_UploadDataCompleted(object sender, UploadDataCompletedEventArgs e) { UploadDataCompletedEventHandler copyUploadDataCompleted = UploadDataCompleted; if (copyUploadDataCompleted != null) { copyUploadDataCompleted(this, e); } }
/// <summary> /// Opens the URL sync. /// </summary> /// <param name="url">url to open</param> /// <param name="data">The data to be posted.</param> /// <param name="eventhandler">The event handler.</param> /// <param name="userToken">The user token.</param> public void OpenUrl(string url, string data, UploadDataCompletedEventHandler eventhandler, object userToken) { if (url.StartsWith("http", StringComparison.OrdinalIgnoreCase) == false) { url = string.Format("http://{0}", url); } UrlDelegate dc = OpenUrl; Asynchronous.FireAndForget(dc, url, data, eventhandler, userToken, false); }
internal static IObservable <byte[]> UploadDataAsObservable(this WebClient client, Uri address, string contentType, string method, byte[] data, string username = "", string password = "", object userToken = null) { return(Observable.Create <byte[]>(observer => { UploadDataCompletedEventHandler handler = (sender, args) => { if (args.UserState != userToken) { return; } if (args.Cancelled) { observer.OnCompleted(); } else if (args.Error != null) { observer.OnError(args.Error); } else { try { observer.OnNext(args.Result); observer.OnCompleted(); } catch (Exception ex) { observer.OnError(ex); } } }; client.UploadDataCompleted += handler; try { if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password)) { client.SetAuthenticationHeaders(username, password); } client.Headers.Add(HttpRequestHeader.ContentType, contentType); client.UploadDataAsync(address, method, data, userToken); } catch (Exception ex) { observer.OnError(ex); } return () => client.UploadDataCompleted -= handler; })); }
static LevelSerializer() { LevelSerializer.Deserialized = delegate { }; LevelSerializer.GameSaved = delegate { }; LevelSerializer.SuspendingSerialization = delegate { }; LevelSerializer.ResumingSerialization = delegate { }; LevelSerializer.StoreComponent = delegate { }; LevelSerializer._collectionCount = 0; LevelSerializer.Progress = delegate { }; WebClient webClient = LevelSerializer.webClient; if (LevelSerializer.< > f__mg$cache0 == null) { LevelSerializer.< > f__mg$cache0 = new UploadDataCompletedEventHandler(LevelSerializer.HandleWebClientUploadDataCompleted); } webClient.UploadDataCompleted += LevelSerializer.< > f__mg$cache0; WebClient webClient2 = LevelSerializer.webClient; if (LevelSerializer.< > f__mg$cache1 == null) { LevelSerializer.< > f__mg$cache1 = new UploadStringCompletedEventHandler(LevelSerializer.HandleWebClientUploadStringCompleted); } webClient2.UploadStringCompleted += LevelSerializer.< > f__mg$cache1; LevelSerializer._stopCases.Add(typeof(PrefabIdentifier)); UnitySerializer.AddPrivateType(typeof(AnimationClip)); foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { UnitySerializer.ScanAllTypesForAttribute(delegate(Type tp, Attribute attr) { LevelSerializer.createdPlugins.Add(Activator.CreateInstance(tp)); }, assembly, typeof(SerializerPlugIn)); UnitySerializer.ScanAllTypesForAttribute(delegate(Type tp, Attribute attr) { LevelSerializer.CustomSerializers[((ComponentSerializerFor)attr).SerializesType] = (Activator.CreateInstance(tp) as IComponentSerializer); }, assembly, typeof(ComponentSerializerFor)); } LevelSerializer.SavedGames = new Index <string, List <LevelSerializer.SaveEntry> >(); }
/// <summary> /// Method to access WebGrid Sms Service and sending out sms asynchronously (threadpool), to access this service you must provide /// a customerId and password. For further information please read documentation at /// <see cref="WebGrid.Util.Sms"/>. /// This method support also Web.Config to access customerId and password information for WebGrid Sms /// the web.config keys are "WGSMSCUSTOMERID" and "WGSMSPASSWORD". /// </summary> /// <param name="sender">Sender address, must be alfanumeric string with no more then 11 characters and no special characters.</param> /// <param name="receiver">The receivers cellphone number, can be Separated by ";" and all numbers must be written with international number. See documentation for further information.</param> /// <param name="message">The message you want to send. All messages with more then 160 characters will be split.</param> /// <param name="eventhandler">The event handler</param> /// <param name="userToken">The user token for this message</param> /// <remarks> /// Using the receiver parameter you must include country number, area number, and local number. Example could be "4712345678", where /// "47" is the norwegian country code and 12345678 is area and local number. /// </remarks> public void SendSms(string sender, string receiver, string message, UploadDataCompletedEventHandler eventhandler, object userToken) { if (string.IsNullOrEmpty(customerId)) { customerId = GridConfig.Get("WGSMSCUSTOMERID", "0"); } if (string.IsNullOrEmpty(password)) { password = GridConfig.Get("WGSMSPASSWORD", null as string); } if (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(customerId)) { throw (new ApplicationException( "customerID or password is missing for WebGrid.Util.Sms (Could not find web.config keys WGSMSCUSTOMERID and WGSMSPASSWORD")); } internalSendSms(sender, receiver, message, eventhandler, userToken); }
/// <summary>Uploads data to the specified resource, asynchronously.</summary> /// <param name="webClient">The WebClient.</param> /// <param name="address">The URI to which the data should be uploaded.</param> /// <param name="method">The HTTP method that should be used to upload the data.</param> /// <param name="data">The data to upload.</param> /// <returns>A Task containing the data in the response from the upload.</returns> public static Task <byte[]> UploadDataTaskAsync(this WebClient webClient, Uri address, string method, byte[] data) { // Create the task to be returned var tcs = new TaskCompletionSource <byte[]>(address); // Setup the callback event handler UploadDataCompletedEventHandler handler = null; handler = (sender, e) => TaskServices.HandleEapCompletion(tcs, true, e, () => e.Result, () => webClient.UploadDataCompleted -= handler); webClient.UploadDataCompleted += handler; // Start the async operation. try { webClient.UploadDataAsync(address, method, data, tcs); } catch { webClient.UploadDataCompleted -= handler; throw; } // Return the task that represents the async operation return(tcs.Task); }
/// <summary>Uploads data to the specified resource, asynchronously.</summary> /// <param name="webClient">The WebClient.</param> /// <param name="address">The URI to which the data should be uploaded.</param> /// <param name="method">The HTTP method that should be used to upload the data.</param> /// <param name="data">The data to upload.</param> /// <returns>A Task containing the data in the response from the upload.</returns> public static Task <byte[]> UploadDataTask(this WebClient webClient, Uri address, string method, byte[] data) { TaskCompletionSource <byte[]> tcs = new TaskCompletionSource <byte[]>(address); UploadDataCompletedEventHandler handler = null; handler = delegate(object sender, UploadDataCompletedEventArgs e) { EAPCommon.HandleCompletion <byte[]>(tcs, e, () => e.Result, delegate { webClient.UploadDataCompleted -= handler; }); }; webClient.UploadDataCompleted += handler; try { webClient.UploadDataAsync(address, method, data, tcs); } catch (Exception exception) { webClient.UploadDataCompleted -= handler; tcs.TrySetException(exception); } return(tcs.Task); }
public static Task <byte[]> UploadDataTaskAsync(this WebClient webClient, Uri address, string method, byte[] data) { TaskCompletionSource <byte[]> tcs = new TaskCompletionSource <byte[]>(address); UploadDataCompletedEventHandler handler = null; handler = delegate(object sender, UploadDataCompletedEventArgs e) { AsyncCompatLibExtensions.HandleEapCompletion <byte[]>(tcs, true, e, () => e.Result, delegate { webClient.UploadDataCompleted -= handler; }); }; webClient.UploadDataCompleted += handler; try { webClient.UploadDataAsync(address, method, data, tcs); } catch { webClient.UploadDataCompleted -= handler; throw; } return(tcs.Task); }
private void OpenUrl(string url, string data, UploadDataCompletedEventHandler eventhandler, object userToken, bool nop) { wc = new WebClient(); wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); if (eventhandler != null) { wc.UploadDataCompleted += eventhandler; } byte[] postByteArray = Encoding.ASCII.GetBytes(data); try { wc.UploadData(new Uri(url), "POST", postByteArray); wc.UploadDataCompleted += wc_UploadDataCompleted; } catch (Exception e) { EventLog logger = new EventLog(); logger.Source = "WebGrid"; logger.WriteEntry(e.ToString(), EventLogEntryType.Error); logger.Dispose(); } }
private void OpenUrl(string url, string data, UploadDataCompletedEventHandler eventhandler, object userToken, bool nop) { wc = new WebClient(); wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); if (eventhandler != null) wc.UploadDataCompleted += eventhandler; byte[] postByteArray = Encoding.ASCII.GetBytes(data); try { wc.UploadData(new Uri(url), "POST", postByteArray); wc.UploadDataCompleted += wc_UploadDataCompleted; } catch (Exception e) { EventLog logger = new EventLog(); logger.Source = "WebGrid"; logger.WriteEntry(e.ToString(), EventLogEntryType.Error); logger.Dispose(); } }
/// <summary> /// 异步抓取页面HTML代码 /// </summary> private dataCrawler() { onDownloadHandle = onDownload; onPostFormHandle = onPostForm; onUploadHandle = onUpload; }
/// <summary> /// Method to access WebGrid Sms Service. Internal use only.. /// </summary> /// <param name="sender">Sender address, must be alfanumeric string with no more then 11 characters and no special characters.</param> /// <param name="receiver">The receivers cellphone number, can be Separated by ";" and all numbers must be written with international number. See documentation for further information.</param> /// <param name="message">The message you want to send. All messages with more then 160 characters will be split.</param> /// <param name="eventhandler">The eventhandler.</param> /// <param name="userToken">The user token.</param> /// <remarks> /// Using the receiver parameter you must include country number, area number, and local number. Example could be "4712345678", where /// "47" is the norwegian country code and 12345678 is area and local number. /// Any errors are logged at Windows EventLog (Application category). /// </remarks> private void internalSendSms(string sender, string receiver, string message, UploadDataCompletedEventHandler eventhandler, object userToken) { const string webgridSMSService = "http://traffic.webgrid.com/send.aspx"; string urlRequestform = string.Format("customerID={0}", HttpUtility.UrlEncode(customerId, Encoding.Default)); if (string.IsNullOrEmpty(password) == false) urlRequestform += string.Format("&password={0}", HttpUtility.UrlEncode(password, Encoding.Default)); if (string.IsNullOrEmpty(sender) == false) urlRequestform += string.Format("&sender={0}", HttpUtility.UrlEncode(sender, Encoding.Default)); if (string.IsNullOrEmpty(receiver) == false) urlRequestform += string.Format("&receiver={0}", HttpUtility.UrlEncode(receiver, Encoding.Default)); if (string.IsNullOrEmpty(message) == false) urlRequestform += string.Format("&message={0}", HttpUtility.UrlEncode(message, Encoding.Default)); urlRequestform += "&messagetypeID=1&__Active=true"; webgridurl.OpenUrl(webgridSMSService, urlRequestform, eventhandler, userToken); }
/// <summary> /// Method to access WebGrid Sms Service and sending out sms asynchronously (threadpool), to access this service you must provide /// a customerId and password. For further information please read documentation at /// <see cref="WebGrid.Util.Sms"/>. /// This method support also Web.Config to access customerId and password information for WebGrid Sms /// the web.config keys are "WGSMSCUSTOMERID" and "WGSMSPASSWORD". /// </summary> /// <param name="sender">Sender address, must be alfanumeric string with no more then 11 characters and no special characters.</param> /// <param name="receiver">The receivers cellphone number, can be Separated by ";" and all numbers must be written with international number. See documentation for further information.</param> /// <param name="message">The message you want to send. All messages with more then 160 characters will be split.</param> /// <param name="eventhandler">The event handler</param> /// <param name="userToken">The user token for this message</param> /// <remarks> /// Using the receiver parameter you must include country number, area number, and local number. Example could be "4712345678", where /// "47" is the norwegian country code and 12345678 is area and local number. /// </remarks> public void SendSms(string sender, string receiver, string message, UploadDataCompletedEventHandler eventhandler, object userToken) { if (string.IsNullOrEmpty(customerId)) customerId = GridConfig.Get("WGSMSCUSTOMERID", "0"); if (string.IsNullOrEmpty(password)) password = GridConfig.Get("WGSMSPASSWORD", null as string); if (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(customerId)) throw (new ApplicationException( "customerID or password is missing for WebGrid.Util.Sms (Could not find web.config keys WGSMSCUSTOMERID and WGSMSPASSWORD")); internalSendSms(sender, receiver, message, eventhandler, userToken); }
public void SetComleteEvent(UploadDataCompletedEventHandler upload) { this.UploadDataCompleted -= Finish; this.UploadDataCompleted += upload; this.UploadDataCompleted += Finish; }
static JSONLevelSerializer() { JSONLevelSerializer.Deserialized = delegate { }; JSONLevelSerializer.GameSaved = delegate { }; JSONLevelSerializer.SuspendingSerialization = delegate { }; JSONLevelSerializer.ResumingSerialization = delegate { }; JSONLevelSerializer.StoreComponent = delegate { }; JSONLevelSerializer._collectionCount = 0; JSONLevelSerializer.Progress = delegate { }; WebClient webClient = JSONLevelSerializer.webClient; if (JSONLevelSerializer.< > f__mg$cache0 == null) { JSONLevelSerializer.< > f__mg$cache0 = new UploadDataCompletedEventHandler(JSONLevelSerializer.HandleWebClientUploadDataCompleted); } webClient.UploadDataCompleted += JSONLevelSerializer.< > f__mg$cache0; WebClient webClient2 = JSONLevelSerializer.webClient; if (JSONLevelSerializer.< > f__mg$cache1 == null) { JSONLevelSerializer.< > f__mg$cache1 = new UploadStringCompletedEventHandler(JSONLevelSerializer.HandleWebClientUploadStringCompleted); } webClient2.UploadStringCompleted += JSONLevelSerializer.< > f__mg$cache1; JSONLevelSerializer._stopCases.Add(typeof(PrefabIdentifier)); UnitySerializer.AddPrivateType(typeof(AnimationClip)); foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { UnitySerializer.ScanAllTypesForAttribute(delegate(Type tp, Attribute attr) { JSONLevelSerializer.createdPlugins.Add(Activator.CreateInstance(tp)); }, assembly, typeof(SerializerPlugIn)); UnitySerializer.ScanAllTypesForAttribute(delegate(Type tp, Attribute attr) { JSONLevelSerializer.CustomSerializers[((ComponentSerializerFor)attr).SerializesType] = (Activator.CreateInstance(tp) as IComponentSerializer); }, assembly, typeof(ComponentSerializerFor)); } JSONLevelSerializer.AllPrefabs = Resources.FindObjectsOfTypeAll(typeof(GameObject)).Cast <GameObject>().Where(delegate(GameObject go) { PrefabIdentifier component = go.GetComponent <PrefabIdentifier>(); return(component != null && !component.IsInScene()); }).Distinct(JSONLevelSerializer.CompareGameObjects.Instance).ToDictionary((GameObject go) => go.GetComponent <PrefabIdentifier>().ClassId, (GameObject go) => go); try { string @string = PlayerPrefs.GetString("JSON_Save_Game_Data_"); if (!string.IsNullOrEmpty(@string)) { JSONLevelSerializer.SavedGames = UnitySerializer.JSONDeserialize <global::Lookup <string, List <JSONLevelSerializer.SaveEntry> > >(@string); } if (JSONLevelSerializer.SavedGames == null) { JSONLevelSerializer.SavedGames = new Index <string, List <JSONLevelSerializer.SaveEntry> >(); } } catch { JSONLevelSerializer.SavedGames = new Index <string, List <JSONLevelSerializer.SaveEntry> >(); } }
public void DeleteResource(string endpoint, UploadDataCompletedEventHandler completed, UploadProgressChangedEventHandler changed) { this.UploadDataCompleted += completed; this.UploadProgressChanged += changed; UploadDataAsync(new Uri(endpoint), "DELETE", new byte[0]); }
/// <summary> /// Opens the URL sync. /// </summary> /// <param name="url">url to open</param> /// <param name="data">The data to be posted.</param> /// <param name="eventhandler">The event handler.</param> /// <param name="userToken">The user token.</param> public void OpenUrl(string url, string data, UploadDataCompletedEventHandler eventhandler, object userToken) { if (url.StartsWith("http", StringComparison.OrdinalIgnoreCase) == false) url = string.Format("http://{0}", url); UrlDelegate dc = OpenUrl; Asynchronous.FireAndForget(dc, url, data, eventhandler, userToken, false); }
public void DeleteResource(string endpoint, UploadDataCompletedEventHandler completed, UploadProgressChangedEventHandler changed) { this.UploadDataCompleted += completed; this.UploadProgressChanged += changed; UploadDataAsync(new Uri(endpoint), "DELETE", new byte[0]); }