Beispiel #1
0
        /// <summary>
        /// 初始化环境
        /// </summary>
        /// <param name="baseApi"></param>
#if !SDK
        public static void InitEnv(IBaseApi baseApi)
        {
            //加载API
            BaseApi = baseApi ?? throw new System.ArgumentNullException(nameof(baseApi));

            //初始化服务
            LibsManager = new LiYinLoader();
        }
Beispiel #2
0
        /// <summary>
        /// 初始化环境
        /// </summary>
        /// <param name="baseApi"></param>
#if !SDK
        public static void InitEnv(IBaseApi baseApi)
        {
            //加载API
            BaseApi = baseApi ?? throw new System.ArgumentNullException(nameof(baseApi));

            //初始化服务
            LibsManager = new TheWanderingEarthManager(BuildInfo.DEFAULT_EXTENSION_PATH);
        }
 public OpenFxManagerImpl(ILibsManager libsManager)
 {
     this.libsManager = libsManager;
     libsManager.ExtensionRegistryModified += (s, e) =>
     {
         ExtensionsChanged?.Invoke(this, new EventArgs());
     };
 }
Beispiel #4
0
 public static IEnumerable <IExtensionInfo> GetAllExtensions(this ILibsManager libsManager)
 {
     return(libsManager.Registry.Select((item) => item.ExtensionInfo));
     //var result = new List<IExtensionInfo>();
     //libsManager.Librarians.All((lib) =>
     //{
     //    result.AddRange(lib.Extensions);
     //    return true;
     //});
     //return result;
 }
Beispiel #5
0
        public static IEnumerable <IExtensionInfo> GetAllExtensions(this ILibsManager libsManager)
        {
            var result = new List <IExtensionInfo>();

            libsManager.Librarians.All((lib) =>
            {
                result.AddRange(lib.Extensions);
                return(true);
            });
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// 初始化环境
        /// </summary>
        /// <param name="baseApi"></param>

        public static void InitEnv(IBaseApi baseApi)
        {
            if (baseApi is null)
            {
                throw new System.ArgumentNullException(nameof(baseApi));
            }

            LakeLoader.Load(baseApi);

            //初始化服务
            LibsManager = new DreamLibManager();
        }
Beispiel #7
0
        /// <summary>
        /// 获取加载的Wrappers
        /// </summary>
        /// <param name="libsManager"></param>
        /// <returns></returns>
        public static IEnumerable <IExtensionWrapper> Wrappers(this ILibsManager libsManager)
        {
            List <IExtensionWrapper> result = new List <IExtensionWrapper>();
            IEnumerable <ILibrarian> libs   = libsManager.Librarians;

            foreach (var lib in libs)
            {
                try
                {
                    result.AddRange(lib.GetWrappers());
                }
                catch (Exception ex)
                {
                    SLogger <ILibsManager> .Warn($"获取拓展模块封装类失败({lib.Name}){ex}");
                }
            }
            return(result);
        }
        public void LoadOpenFx()
        {
            logger.Info("Initializing open framework api");
            OpenFx.Load(new AutumnBoxGuiBaseApiImpl());
            logger.Info("Open framework api system is initialized");
            logger.Info("Loading extensions");
            OpenFx.RefreshExtensionsList();
            ILibsManager libsManager = OpenFx.Lake.Get <ILibsManager>();

            logger.Info($"There are {libsManager.Librarians.Count()} librarians and {libsManager.GetAllExtensions().Count()} wrappers");
            isLoaded = true;
            while (handlers.Any())
            {
                try
                {
                    handlers.Dequeue()();
                }
                catch (Exception e)
                {
                    logger.Warn("", e);
                }
            }
        }