Exemple #1
0
        private void CreateDefaultLoader()
        {
            var loaderscript = Path.Combine(LibraryRoot, PREDEFINED_LOADER_FILE);

            TraceLoadLibrary(
                Locale.NStr($"ru = 'Путь поиска package-loader - {loaderscript}';" +
                            $"en = 'Package-loader path search - {loaderscript}'")
                );

            if (File.Exists(loaderscript))
            {
                TraceLoadLibrary(
                    Locale.NStr($"ru = 'Загружен package-loader по адресу {loaderscript}';" +
                                $"en = 'Load package-loader from {loaderscript}'")
                    );
                _defaultLoader = LibraryLoader.Create(_engine, _env, loaderscript);
            }
            else
            {
                TraceLoadLibrary(
                    Locale.NStr($"ru = 'Загружен package-loader по умолчанию';" +
                                $"en = 'Default package-loader is used'")
                    );
                _defaultLoader = LibraryLoader.Create(_engine, _env);
            }
        }
Exemple #2
0
        private bool LoadLibraryInternal(string libraryPath)
        {
            var id         = GetLibraryId(libraryPath);
            var existedLib = _libs.FirstOrDefault(x => x.id == id);

            if (existedLib != null)
            {
                if (existedLib.state == ProcessingState.Discovered)
                {
                    string libStack = listToStringStack(_libs, id);
                    throw new RuntimeException($"Ошибка загрузки библиотеки {id}. Обнаружены циклические зависимости.\n" +
                                               $"{libStack}");
                }
                TraceLoadLibrary(
                    Locale.NStr($"ru = 'Использую уже загруженную библиотеку {existedLib.id}';" +
                                $"en = 'Use allready loaded library {existedLib.id}'")
                    );
                return(true);
            }

            var newLib = new Library()
            {
                id = id, state = ProcessingState.Discovered
            };
            bool hasFiles;
            int  newLibIndex = _libs.Count;

            var customLoaderFile = Path.Combine(libraryPath, PREDEFINED_LOADER_FILE);

            if (File.Exists(customLoaderFile))
            {
                newLib.customLoader = LibraryLoader.Create(_engine, _env, customLoaderFile);
            }

            try
            {
                _libs.Add(newLib);
                TraceLoadLibrary(
                    Locale.NStr($"ru = 'Начинаю процессинг {newLib.id}';" +
                                $"en = 'Start processing {newLib.id}'")
                    );

                hasFiles     = ProcessLibrary(newLib);
                newLib.state = ProcessingState.Processed;
            }
            catch (Exception)
            {
                _libs.RemoveAt(newLibIndex);
                throw;
            }

            TraceLoadLibrary(
                Locale.NStr($"ru = 'Библиотека {newLib.id} будет загружена - {hasFiles}';" +
                            $"en = 'Library {newLib.id} will be loaded - {hasFiles}'")
                );

            return(hasFiles);
        }
Exemple #3
0
        private void CreateDefaultLoader()
        {
            var loaderscript = Path.Combine(LibraryRoot, PREDEFINED_LOADER_FILE);

            if (File.Exists(loaderscript))
            {
                _defaultLoader = LibraryLoader.Create(_engine, _env, loaderscript);
            }
            else
            {
                _defaultLoader = LibraryLoader.Create(_engine, _env);
            }
        }
Exemple #4
0
        private bool LoadLibraryInternal(string libraryPath)
        {
            var id         = GetLibraryId(libraryPath);
            var existedLib = _libs.FirstOrDefault(x => x.id == id);

            if (existedLib != null)
            {
                if (existedLib.state == ProcessingState.Discovered)
                {
                    throw new RuntimeException(String.Format("Ошибка загрузки библиотеки {0}. Обнаружены циклические зависимости", id));
                }
                else
                {
                    return(true);
                }
            }

            var newLib = new Library()
            {
                id = id, state = ProcessingState.Discovered
            };
            bool hasFiles;
            int  newLibIndex = _libs.Count;

            var customLoaderFile = Path.Combine(libraryPath, PREDEFINED_LOADER_FILE);

            if (File.Exists(customLoaderFile))
            {
                newLib.customLoader = LibraryLoader.Create(_engine, _env, customLoaderFile);
            }

            try
            {
                _libs.Add(newLib);
                hasFiles     = ProcessLibrary(newLib);
                newLib.state = ProcessingState.Processed;
            }
            catch (Exception)
            {
                _libs.RemoveAt(newLibIndex);
                throw;
            }

            return(hasFiles);
        }
Exemple #5
0
 private void CreateDefaultLoader()
 {
     var loaderscript = Path.Combine(LibraryRoot, PREDEFINED_LOADER_FILE);
     if (File.Exists(loaderscript))
     {
         _defaultLoader = LibraryLoader.Create(_engine, _env, loaderscript);
     }
     else
     {
         _defaultLoader = LibraryLoader.Create(_engine, _env);
     }
 }