// Token: 0x0600003B RID: 59 RVA: 0x00003A2C File Offset: 0x00001C2C
        private static bool LoadSatelliteByPath(AssemblyName resolve, string fullPath, bool isLog, bool first, out Assembly resolvedAssembly)
        {
            AssemblyName assemblyName = AssemblyName.GetAssemblyName(fullPath);

            if (!AssemblySatelliteResolver.SatelliteMatchesDefinition(resolve, assemblyName))
            {
                if (isLog)
                {
                    AssemblySatelliteResolver.log.DebugFormat("Resolving \"{0}\" does not match \"{1}\"", resolve, assemblyName);
                }
                resolvedAssembly = null;
                return(false);
            }
            Exception ex       = null;
            Assembly  assembly = null;

            if (first)
            {
                try
                {
                    assembly = Assembly.Load(assemblyName);
                }
                catch (FileNotFoundException)
                {
                }
                catch (FileLoadException)
                {
                }
                catch (Exception ex)
                {
                }
            }
            if (assembly == null)
            {
                if (ex != null)
                {
                    AssemblySatelliteResolver.log.DebugFormat("Cannot load \"{0}\", falling back to load-from. {1}", assemblyName, ex);
                }
                assembly = Assembly.LoadFrom(fullPath);
            }
            try
            {
                if (AssemblySatelliteResolver.ResolveCnt.GetOrAdd(assembly.FullName, (string _) => new AssemblySatelliteResolver.IntRef(0)).Increment() == 1 || isLog)
                {
                    Uri    assemblyLocation = AssemblySatelliteResolver.GetAssemblyLocation(assembly);
                    string text             = (assemblyLocation != null && assemblyLocation.IsAbsoluteUri) ? AssemblySatelliteResolver.NormalizePath(assemblyLocation.LocalPath) : string.Empty;
                    if (!AssemblyName.ReferenceMatchesDefinition(resolve, assembly.GetName()) || !fullPath.Equals(text, StringComparison.Ordinal))
                    {
                        AssemblySatelliteResolver.log.ErrorFormat("Resolved \"{0}\" as \"{1}\" at \"{2}\"", resolve, assembly, text);
                    }
                }
            }
            catch (Exception ex2)
            {
                AssemblySatelliteResolver.log.ErrorFormat("Error reporting assembly-resolved. {0}", ex2);
            }
            resolvedAssembly = assembly;
            return(true);
        }
 // Token: 0x06000030 RID: 48 RVA: 0x00002FD4 File Offset: 0x000011D4
 internal static Assembly AssemblyResolve(object sender, ResolveEventArgs args)
 {
     try
     {
         AssemblyName assemblyName = new AssemblyName(args.Name);
         if (!assemblyName.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase))
         {
             return(null);
         }
         AssemblySatelliteResolver.IntRef intRef;
         bool flag = AssemblySatelliteResolver.EntryCount.GetOrAdd(assemblyName.FullName, (string _) => new AssemblySatelliteResolver.IntRef(0)).Increment() > 2 && !AssemblySatelliteResolver.ResolveCnt.TryGetValue(assemblyName.FullName, out intRef);
         if (flag)
         {
             AssemblySatelliteResolver.log.DebugFormat("Resolving satellite assembly \"{0}\"", assemblyName);
         }
         string[] array = assemblyName.Name.Split(new char[]
         {
             '.'
         });
         string          sourceName         = string.Join(".", array.Take(array.Length - 1));
         string          resolveFileName    = assemblyName.Name + ".dll";
         List <Assembly> list               = new List <Assembly>(AppDomain.CurrentDomain.GetAssemblies());
         Assembly        requestingAssembly = args.RequestingAssembly;
         if (requestingAssembly != null)
         {
             list.Remove(requestingAssembly);
             list.Insert(0, requestingAssembly);
         }
         foreach (Assembly assembly in list)
         {
             AssemblyName name = assembly.GetName();
             if (AssemblySatelliteResolver.SatelliteMatchesDefinition(assemblyName, name))
             {
                 bool flag2 = AssemblySatelliteResolver.ResolveCnt.GetOrAdd(assembly.FullName, (string _) => new AssemblySatelliteResolver.IntRef(0)).Increment() == 1;
                 if (flag || flag2)
                 {
                     AssemblySatelliteResolver.log.InfoFormat("Resolved \"{0}\" as \"{1}\" at \"{2}\"", assemblyName, name, AssemblySatelliteResolver.GetSymbolicLocation(assembly));
                 }
                 return(assembly);
             }
         }
         Assembly result;
         if (AssemblySatelliteResolver.ProbeViaLoadedAssemblies(list, assemblyName, resolveFileName, requestingAssembly, sourceName, flag, out result))
         {
             return(result);
         }
     }
     catch (Exception ex)
     {
         Trace.TraceError("AssemblyResove failed. {0}", new object[]
         {
             ex
         });
         AssemblySatelliteResolver.log.FatalFormat("AssemblyResove failed. {0}", ex);
         GC.KeepAlive(ex);
     }
     return(null);
 }
 internal static Assembly AssemblyResolve(object sender, ResolveEventArgs args)
 {
     try
     {
         AssemblyName assemblyName = new AssemblyName(args.Name);
         if (!assemblyName.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase))
         {
             return((Assembly)null);
         }
         bool isLog = AssemblySatelliteResolver.EntryCount.GetOrAdd(assemblyName.FullName, (Func <string, AssemblySatelliteResolver.IntRef>)(_ => new AssemblySatelliteResolver.IntRef(0))).Increment() > 2 && !AssemblySatelliteResolver.ResolveCnt.TryGetValue(assemblyName.FullName, out AssemblySatelliteResolver.IntRef _);
         if (isLog)
         {
             AssemblySatelliteResolver.log.DebugFormat("Resolving satellite assembly \"{0}\"", (object)assemblyName);
         }
         string[]        strArray           = assemblyName.Name.Split('.');
         string          sourceName         = string.Join(".", ((IEnumerable <string>)strArray).Take <string>(strArray.Length - 1));
         string          resolveFileName    = assemblyName.Name + ".dll";
         List <Assembly> assemblyList       = new List <Assembly>((IEnumerable <Assembly>)AppDomain.CurrentDomain.GetAssemblies());
         Assembly        requestingAssembly = args.RequestingAssembly;
         if (requestingAssembly != (Assembly)null)
         {
             assemblyList.Remove(requestingAssembly);
             assemblyList.Insert(0, requestingAssembly);
         }
         foreach (Assembly assembly in assemblyList)
         {
             AssemblyName name = assembly.GetName();
             if (AssemblySatelliteResolver.SatelliteMatchesDefinition(assemblyName, name))
             {
                 bool flag = AssemblySatelliteResolver.ResolveCnt.GetOrAdd(assembly.FullName, (Func <string, AssemblySatelliteResolver.IntRef>)(_ => new AssemblySatelliteResolver.IntRef(0))).Increment() == 1;
                 if (isLog | flag)
                 {
                     AssemblySatelliteResolver.log.InfoFormat("Resolved \"{0}\" as \"{1}\" at \"{2}\"", (object)assemblyName, (object)name, (object)AssemblySatelliteResolver.GetSymbolicLocation(assembly));
                 }
                 return(assembly);
             }
         }
         Assembly resolvedAssembly;
         if (AssemblySatelliteResolver.ProbeViaLoadedAssemblies((ICollection <Assembly>)assemblyList, assemblyName, resolveFileName, requestingAssembly, sourceName, isLog, out resolvedAssembly))
         {
             return(resolvedAssembly);
         }
     }
     catch (Exception ex)
     {
         Trace.TraceError("AssemblyResove failed. {0}", (object)ex);
         AssemblySatelliteResolver.log.FatalFormat("AssemblyResove failed. {0}", (object)ex);
         GC.KeepAlive((object)ex);
     }
     return((Assembly)null);
 }
        private static bool LoadSatelliteByPath(
            AssemblyName resolve,
            string fullPath,
            bool isLog,
            bool first,
            out Assembly resolvedAssembly)
        {
            AssemblyName assemblyName = AssemblyName.GetAssemblyName(fullPath);

            if (!AssemblySatelliteResolver.SatelliteMatchesDefinition(resolve, assemblyName))
            {
                if (isLog)
                {
                    AssemblySatelliteResolver.log.DebugFormat("Resolving \"{0}\" does not match \"{1}\"", (object)resolve, (object)assemblyName);
                }
                resolvedAssembly = (Assembly)null;
                return(false);
            }
            Exception exception = (Exception)null;
            Assembly  assembly  = (Assembly)null;

            if (first)
            {
                try
                {
                    assembly = Assembly.Load(assemblyName);
                }
                catch (FileNotFoundException ex)
                {
                }
                catch (FileLoadException ex)
                {
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            }
            if (assembly == (Assembly)null)
            {
                if (exception != null)
                {
                    AssemblySatelliteResolver.log.DebugFormat("Cannot load \"{0}\", falling back to load-from. {1}", (object)assemblyName, (object)exception);
                }
                assembly = Assembly.LoadFrom(fullPath);
            }
            try
            {
                if (AssemblySatelliteResolver.ResolveCnt.GetOrAdd(assembly.FullName, (Func <string, AssemblySatelliteResolver.IntRef>)(_ => new AssemblySatelliteResolver.IntRef(0))).Increment() == 1 | isLog)
                {
                    Uri    assemblyLocation = AssemblySatelliteResolver.GetAssemblyLocation(assembly);
                    string str = !(assemblyLocation != (Uri)null) || !assemblyLocation.IsAbsoluteUri ? string.Empty : AssemblySatelliteResolver.NormalizePath(assemblyLocation.LocalPath);
                    if (AssemblyName.ReferenceMatchesDefinition(resolve, assembly.GetName()))
                    {
                        if (fullPath.Equals(str, StringComparison.Ordinal))
                        {
                            goto label_19;
                        }
                    }
                    AssemblySatelliteResolver.log.ErrorFormat("Resolved \"{0}\" as \"{1}\" at \"{2}\"", (object)resolve, (object)assembly, (object)str);
                }
            }
            catch (Exception ex)
            {
                AssemblySatelliteResolver.log.ErrorFormat("Error reporting assembly-resolved. {0}", (object)ex);
            }
label_19:
            resolvedAssembly = assembly;
            return(true);
        }