Exemple #1
0
        private static bool TryLoadDependency(AssetCollection collection, IEnumerable <string> directories, string originalName, string loadName)
        {
            foreach (string dirPath in directories)
            {
                string path = Path.Combine(dirPath, loadName);
#if !DEBUG_PROGRAM
                try
#endif
                {
                    if (FileMultiStream.Exists(path))
                    {
                        using (Stream stream = FileMultiStream.OpenRead(path))
                        {
                            collection.Read(stream, path, originalName);
                        }

                        Logger.Instance.Log(LogType.Info, LogCategory.Import, $"Dependency '{path}' was loaded");
                        return(true);
                    }
                }
#if !DEBUG_PROGRAM
                catch (Exception ex)
                {
                    Logger.Instance.Log(LogType.Error, LogCategory.Import, $"Can't parse dependency file {path}");
                    Logger.Instance.Log(LogType.Error, LogCategory.Debug, ex.ToString());
                }
#endif
            }
            return(false);
        }
Exemple #2
0
        private static void LoadFiles(AssetCollection collection, IEnumerable <string> filePathes)
        {
            List <string> processed = new List <string>();

            foreach (string path in filePathes)
            {
                string filePath = FileMultiStream.GetFilePath(path);
                if (processed.Contains(filePath))
                {
                    continue;
                }

                string fileName = FileMultiStream.GetFileName(path);
                using (Stream stream = FileMultiStream.OpenRead(path))
                {
                    collection.Read(stream, filePath, fileName);
                }
                processed.Add(filePath);
            }
        }