コード例 #1
0
        private void RemoveReference()
        {
            FirebaseApp.ThrowIfCheckDependenciesRunning();
            object obj = FirebaseApp.nameToProxy;

            lock (obj)
            {
                IntPtr handle = this.swigCPtr.Handle;
                if (handle != IntPtr.Zero)
                {
                    GC.SuppressFinalize(this);
                    if (this.swigCMemOwn)
                    {
                        int count = FirebaseApp.nameToProxy.Count;
                        FirebaseApp.cPtrToProxy.Remove(handle);
                        FirebaseApp.nameToProxy.Remove(this.Name);
                        AppUtilPINVOKE.delete_FirebaseApp(this.swigCPtr);
                        if (count > 0 && FirebaseApp.nameToProxy.Count == 0)
                        {
                            FirebaseApp.OnAllAppsDestroyed();
                        }
                    }
                }
                this.swigCMemOwn = false;
                this.swigCPtr    = new HandleRef(null, IntPtr.Zero);
            }
        }
コード例 #2
0
        private void AddReference()
        {
            FirebaseApp.ThrowIfCheckDependenciesRunning();
            object obj = FirebaseApp.nameToProxy;

            lock (obj)
            {
                WeakReference value = new WeakReference(this, false);
                this.swigCMemOwn = true;
                FirebaseApp.nameToProxy[this.Name]            = value;
                FirebaseApp.cPtrToProxy[this.swigCPtr.Handle] = value;
            }
        }
コード例 #3
0
        private static void ResetDefaultAppCPtr()
        {
            FirebaseApp.ThrowIfCheckDependenciesRunning();
            object obj = FirebaseApp.nameToProxy;

            lock (obj)
            {
                AppUtil.InitializePlayServicesInternal();
                FirebaseApp.PreventOnAllAppsDestroyed = true;
                FirebaseApp defaultInstance = FirebaseApp.DefaultInstance;
                defaultInstance.RemoveReference();
                defaultInstance.swigCPtr = new HandleRef(defaultInstance, AppUtilPINVOKE.FirebaseApp_CreateInternal__SWIG_0());
                defaultInstance.AddReference();
                FirebaseApp.PreventOnAllAppsDestroyed = false;
                AppUtil.TerminatePlayServicesInternal();
            }
        }
コード例 #4
0
        public static FirebaseApp GetInstance(string name)
        {
            FirebaseApp.ThrowIfCheckDependenciesRunning();
            FirebaseApp firebaseApp = null;
            object      obj         = FirebaseApp.nameToProxy;
            FirebaseApp result;

            lock (obj)
            {
                WeakReference weakReference;
                if (FirebaseApp.nameToProxy.TryGetValue(name, out weakReference))
                {
                    firebaseApp = (FirebaseApp.WeakReferenceGetTarget(weakReference) as FirebaseApp);
                    if (firebaseApp == null)
                    {
                        FirebaseApp.nameToProxy.Remove(name);
                    }
                }
                result = firebaseApp;
            }
            return(result);
        }
コード例 #5
0
        private static FirebaseApp CreateAndTrack(FirebaseApp.CreateDelegate createDelegate, FirebaseApp existingProxy)
        {
            FirebaseApp.ThrowIfCheckDependenciesRunning();
            FirebaseHandler.Create(FirebaseAppUtils.Instance);
            object      obj = FirebaseApp.nameToProxy;
            FirebaseApp result2;

            lock (obj)
            {
                FirebaseApp.InitializeAppUtilCallbacks();
                HandleRef   cPtr = new HandleRef(null, IntPtr.Zero);
                FirebaseApp firebaseApp;
                try
                {
                    FirebaseApp.AppSetDefaultConfigPath(PlatformInformation.DefaultConfigLocation);
                    firebaseApp = createDelegate();
                    if (AppUtilPINVOKE.SWIGPendingException.Pending)
                    {
                        throw AppUtilPINVOKE.SWIGPendingException.Retrieve();
                    }
                    if (firebaseApp == null)
                    {
                        throw new InitializationException(InitResult.FailedMissingDependency, "App creation failed with an unknown error.");
                    }
                    cPtr = FirebaseApp.getCPtr(firebaseApp);
                }
                catch (ApplicationException ex)
                {
                    FirebaseApp.OnAllAppsDestroyed();
                    string     text   = ex.Message;
                    InitResult result = InitResult.FailedMissingDependency;
                    int        num    = text.IndexOf(":");
                    if (num >= 0)
                    {
                        result = (InitResult)int.Parse(text.Substring(0, num));
                        text   = text.Substring(num + 1);
                    }
                    if (text.IndexOf("Please verify the AAR") >= 0)
                    {
                        text = text + "\n" + ErrorMessages.DependencyNotFoundErrorMessage;
                    }
                    throw new InitializationException(result, text);
                }
                catch (Exception ex2)
                {
                    FirebaseApp.OnAllAppsDestroyed();
                    throw ex2;
                }
                if (cPtr.Handle == IntPtr.Zero)
                {
                    result2 = null;
                }
                else
                {
                    WeakReference weakReference;
                    if (FirebaseApp.cPtrToProxy.TryGetValue(cPtr.Handle, out weakReference))
                    {
                        FirebaseApp firebaseApp2 = FirebaseApp.WeakReferenceGetTarget(weakReference) as FirebaseApp;
                        if (firebaseApp2 != null)
                        {
                            if (existingProxy != firebaseApp2)
                            {
                                FirebaseApp.LogMessage(LogLevel.Warning, string.Format("Detected multiple FirebaseApp proxies for {0}", existingProxy.Name));
                                existingProxy.Dispose();
                            }
                            result2 = firebaseApp2;
                            return(result2);
                        }
                    }
                    if (FirebaseApp.cPtrToProxy.Count == 0)
                    {
                        string text2 = "fire-" + PlatformInformation.RuntimeName;
                        FirebaseApp.RegisterLibraryInternal(text2, VersionInfo.SdkVersion);
                        FirebaseApp.RegisterLibraryInternal(text2 + "-ver", PlatformInformation.RuntimeVersion);
                    }
                    firebaseApp.name = firebaseApp.NameInternal;
                    firebaseApp.AddReference();
                    if (!FirebaseApp.installedCerts)
                    {
                        FirebaseApp.installedCerts = true;
                        Services.RootCerts.Install(firebaseApp.AppPlatform);
                    }
                    if (!FirebaseApp.crashlyticsInitializationAttempted)
                    {
                        FirebaseApp.crashlyticsInitializationAttempted = true;
                        FirebaseHandler.RunOnMainThread <bool>(() => FirebaseApp.InitializeCrashlyticsIfPresent());
                    }
                    result2 = firebaseApp;
                }
            }
            return(result2);
        }