示例#1
0
 private static void WriteAssemblyTable()
 {
     if (!WriteAssemblyTable(MiscHelpers.GetLocalDataRootPath(out var usingAppPath)) && !usingAppPath)
     {
         WriteAssemblyTable(MiscHelpers.GetLocalDataRootPath(AppDomain.CurrentDomain.BaseDirectory));
     }
 }
示例#2
0
            private static bool ReadAssemblyTable()
            {
                if (ReadAssemblyTable(MiscHelpers.GetLocalDataRootPath(out var usingAppPath)))
                {
                    return(true);
                }

                return(!usingAppPath && ReadAssemblyTable(MiscHelpers.GetLocalDataRootPath(AppDomain.CurrentDomain.BaseDirectory)));
            }
示例#3
0
            private static void LoadAssemblyTable()
            {
                // ReSharper disable EmptyGeneralCatchClause

                string filePath = null;

                try
                {
                    var dirPath = Path.Combine(MiscHelpers.GetLocalDataRootPath(), GetRuntimeVersionDirectoryName());
                    Directory.CreateDirectory(dirPath);

                    filePath = Path.Combine(dirPath, "AssemblyTable.bin");
                    if (File.Exists(filePath))
                    {
                        try
                        {
                            using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                            {
                                var formatter = new BinaryFormatter();
                                table = (ConcurrentDictionary <string, string>)formatter.Deserialize(stream);
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                catch (Exception)
                {
                }

                if (table == null)
                {
                    BuildAssemblyTable();
                    if ((table != null) && (filePath != null))
                    {
                        try
                        {
                            using (var stream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None))
                            {
                                var formatter = new BinaryFormatter();
                                formatter.Serialize(stream, table);
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }

                // ReSharper restore EmptyGeneralCatchClause
            }