private void OnConnectionAppear() { if (IDisposableObject.IsValid(coroutineAsync)) { coroutineAsync.Dispose(); // not valid any more! // Internet was Lost, now it is restored var signInID = GetSocialUserId(); if (loginStatus != LoginStatus.Complete) { // reinitialize auth and database! Init(); // Sign In Again SignIn(signInID); } else { // just get the user data! GetUserData(signInID); } } onInternetConnection?.Invoke(true); // there was no internet problems }
private void ViewModelOnDisposed(IDisposableObject sender, EventArgs args) { if (CachePolicy != null && CachePolicy.Invalidate((IViewModel)sender, DataContext.Empty)) { Tracer.Warn("The disposed view model " + sender.GetType().Name + " was in the navigation cache"); } }
public static void NotBeDisposed(this IDisposableObject disposableObject) { NotBeNull(disposableObject, "disposableObject"); if (disposableObject.IsDisposed) { throw ExceptionManager.ObjectDisposed(disposableObject.GetType()); } }
private async void WaiterForinternetRestore(IDisposableObject refToCheck) { // wait for 3 seconds? while (IDisposableObject.IsValid(refToCheck) && !IsInternetConnected) { #if UNITY_EDITOR Debug.LogWarning(" now is Enabled Waiter For internet!"); #endif await System.Threading.Tasks.Task.Delay(5000); // wait every 5 seconds } }
private void OnConnectionLose() { if (!IDisposableObject.IsValid(coroutineAsync)) { // only now we need to start on waiting coroutineAsync = new IDisposableObject(); WaiterForinternetRestore(coroutineAsync); onInternetConnection?.Invoke(false); } // else already in a bad state }
protected static void ClearCacheOnDisposeViewModel(IDisposableObject sender, EventArgs args) { sender.Disposed -= ClearCacheOnDisposeDelegate; lock (ContextCache) { var pairs = ContextCache.Where(pair => ReferenceEquals(pair.Value, sender)).ToList(); foreach (var pair in pairs) { ContextCache.Remove(pair.Key); } } }
public static void NotDisposed(IDisposableObject disposedValue, string message = null) { Requires.NotNull(disposedValue, nameof(disposedValue)); if (disposedValue.IsDisposed) { string objectName = disposedValue != null?disposedValue.GetType().FullName : string.Empty; if (message != null) { throw new ObjectDisposedException(objectName, message); } else { throw new ObjectDisposedException(objectName); } } }
public async Task GetAllUrls(IDisposableObject disposable, string Url) { string platform = null; #if UNITY_ANDROID || UNITY_EDITOR platform = AndroidPlatform; #endif #if UNITY_IOS platform = IosPlatform; #endif var urlWithJsonExtension = Url + ".json"; var master = await App.Services.WebLoader .LoadData <MasterSlaveUrl>(disposable, OnError, urlWithJsonExtension); if (!IDisposableObject.IsValid(disposable)) { return; } actualDataBase = master; }
/// <summary> /// Load all games data /// </summary> /// <param name="callback">success callback</param> /// <param name="error">error callback</param> public async Task <T> LoadData <T>( IDisposableObject refToCheck, Action <string> error, string url) { using (var req = UnityWebRequest.Get(url)) { #pragma warning disable req.SendWebRequest(); #pragma warning restore while (!req.isDone && !req.isHttpError && !req.isNetworkError && IDisposableObject.IsValid(refToCheck)) { await Task.Yield(); // 0.005s } if (!IDisposableObject.IsValid(refToCheck) || req.isHttpError || req.isNetworkError) { error.Invoke(req.error); return(default);
private async void runAsync() { if (Application.internetReachability == NetworkReachability.NotReachable) { Debug.LogWarning(" No Internet"); return; } var DisposableObject = new IDisposableObject(); var yieldFor = await App.Services.WebLoader.LoadData(DisposableObject, (msg) => { Debug.LogError(" Error " + msg); }, App.Services.WebLoader.MainUrl //+ "/pub?output=txt" ); // Debug.LogWarning(yieldFor); var texture = LoaderTextures.ParseToTexture(yieldFor); if (imageTOPassIn != null) { imageTOPassIn.texture = texture; } }
private void ContainerOnDisposed(IDisposableObject sender, EventArgs args) { sender.Disposed -= ContainerOnDisposed; Dispose(); }
private void InjectorOnDisposed(IDisposableObject disposableObject) { disposableObject.Disposed -= InjectorOnDisposed; OnDisposed(); }
public static bool IsValid(IDisposableObject refToCheck) { return(refToCheck != null && refToCheck._valid); }
private void InjectorOnDisposed(IDisposableObject disposableObject) { disposableObject.Disposed -= InjectorOnDisposed; Disposed?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Initializes a new instance of the <see cref="DataStoreReaderBase"/> class. /// </summary> protected DataStoreReaderBase() { this.asDisposableObject = this as IDisposableObject; }
private void ViewModelOnDisposed(IDisposableObject sender, EventArgs args) { if (CachePolicy != null && CachePolicy.Invalidate((IViewModel)sender, DataContext.Empty)) Tracer.Warn("The disposed view model " + sender.GetType().Name + " was in the navigation cache"); }
public async Task <bool> LoadingAllContent() { if (startedTask != null) { var result = await startedTask; startedTask = null; return(result); } else { disposableObject = new IDisposableObject(); var listOfItems = await App.Services.WebLoader.LoadData(disposableObject, (msg) => { Debug.LogError(msg); }, App.Services.WebLoader.MainUrl ); if (string.IsNullOrEmpty(listOfItems)) { Debug.LogWarning("string is null"); return(false); } if (!IDisposableObject.IsValid(disposableObject)) { return(false); } var master = App.Services.JsonConverter.FromJson <MasterSlaveUrl>(listOfItems); if (allManaged == null) { allManaged = new Dictionary <string, T>(); } else { if (IsUnityObject) { foreach (var key in allManaged.Keys) { if (allManaged[key] != null) { Object.Destroy(allManaged[key] as UnityEngine.Object); } } } } allManaged.Clear(); if (dataType == DataType.NotInitialized) { var typeT = typeof(T); dataType = DataType.Custom; bool isAssetBundle = typeT == typeof(AssetBundle); if (isAssetBundle) { dataType = DataType.AssetBundle; } } bool shouldBeParsed = dataType == DataType.Custom; for (int i = 0; i < master.Urls.Count; i++) { URLLoader.WrapperDownload downloadHandler = null; switch (dataType) { case DataType.Custom: downloadHandler = await App.Services.WebLoader.LoadAndGetDownloadHandler(disposableObject, (msg) => { Debug.LogError(msg); }, master.Urls[i].Url); break; case DataType.AssetBundle: downloadHandler = await App.Services.WebLoader.LoadAndGetAssetBundle(disposableObject, (msg) => { Debug.LogError(msg); }, master.Urls[i].Url); break; } if (!IDisposableObject.IsValid(disposableObject)) { return(false); } if (downloadHandler.assetbundle == null) { var parser = ParseFromHandler(downloadHandler.handler); if (parser == null) { Debug.LogWarning($" could not parse {master.Urls[i].Name}"); continue; } allManaged.Add(master.Urls[i].Name, parser); } else { allManaged.Add(master.Urls[i].Name, downloadHandler.assetbundle as T); } } return(true); } }