ILoader AddNewLoader(ELoaderType loaderType) { ILoader loader = CreateLoader(loaderType); m_WaitingLoaderList.Add(loader); return(loader); }
public static BaseLoader Load(ELoaderType type, string path, int priority = 0) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path is null or empty!"); } BaseLoader loader; //1.在正在加载的列表中; if (FindBaseLoader(path, s_LoadingAssetDict, out loader)) { return(loader); } //2.在等待加载的列表中; if (FindBaseLoader(path, s_WaitingLoaderList, out loader)) { return(loader); } //3.新加入加载的; loader = CreateLoader(type, path, priority); s_WaitingLoaderList.Add(loader); if (s_WaitingLoaderList.Count > 0) { s_WaitingLoaderList.Sort(); } return(loader); }
ILoader GetLoader(string path, int priority, ELoaderType loaderType) { for (int i = 0; i < m_AcitveLoaderList.Count; i++) { if (path == m_AcitveLoaderList[i].Url) { return(m_AcitveLoaderList[i]); } } for (int i = 0; i < m_WaitingLoaderList.Count; i++) { if (path == m_WaitingLoaderList[i].Url) { if (m_WaitingLoaderList[i].Priority < priority) { m_WaitingLoaderList[i].Priority = priority; } return(m_WaitingLoaderList[i]); } } ILoader loader = AddNewLoader(loaderType); loader.Init(path, priority); return(loader); }
//loader factory ILoader CreateLoader(ELoaderType loaderType) { ILoader loader = null; switch (loaderType) { case ELoaderType.WWW_LOADER: loader = new WWWLoader(); break; case ELoaderType.RESOURCE_LOADER: loader = new ResourceLoader(); break; } return(loader); }
protected ELoaderType GetLoaderContent(string sysrequestcontent) { ELoaderType loaderType = ELoaderType.None; if (!string.IsNullOrEmpty(sysrequestcontent)) { if (!int.TryParse(sysrequestcontent, out int enumValueInt)) { enumValueInt = int.Parse(sysrequestcontent, System.Globalization.NumberStyles.HexNumber); } else { enumValueInt = int.Parse(enumValueInt.ToString(), System.Globalization.NumberStyles.HexNumber); } Enum.TryParse <ELoaderType>(enumValueInt.ToString(), out loaderType); } return(loaderType); }
static BaseLoader CreateLoader(ELoaderType type, string path, int priority) { BaseLoader loader; switch (type) { case ELoaderType.EditorLoader: loader = new EditorLoader(path, priority); break; case ELoaderType.ResourceLoader: loader = new ResourceLoader(path, priority); break; case ELoaderType.BundleLoader: loader = new BundleLoader(path, priority); break; default: throw new ArgumentNullException("ELoaderType is not exist! Type:" + type); } return(loader); }
public override void Load(ELoaderType type) { }
private static LoaderProperties GetLoaderProperties(string key, KraftModuleConfigurationSettings kraftConfigurationSettings, ELoaderType pluginType, bool isIterator = false) { LoaderProperties loaderProperties; switch (pluginType) { case ELoaderType.ViewLoader: { loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.ViewLoader.FirstOrDefault(n => n.Name.Equals(key, StringComparison.CurrentCultureIgnoreCase)); break; } case ELoaderType.DataLoader: { if (isIterator) { loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.NodesDataIterator.NodesDataIteratorConf; } else { loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.NodesDataIterator.NodesDataLoader.FirstOrDefault(s => s.Name.Equals(key, StringComparison.CurrentCultureIgnoreCase)); } break; } case ELoaderType.LookupLoader: { loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.LookupLoader.FirstOrDefault(n => n.Name.Equals(key, StringComparison.CurrentCultureIgnoreCase)); break; } case ELoaderType.ResourceLoader: { loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.ResourceLoader.FirstOrDefault(n => n.Name.Equals(key, StringComparison.CurrentCultureIgnoreCase)); break; } case ELoaderType.CustomPlugin: { loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.CustomPlugin.FirstOrDefault(n => n.Name.Equals(key, StringComparison.CurrentCultureIgnoreCase)); break; } default: { throw new Exception("Plugintype is not known in Ccf.Ck.Processing.Execution.GetPlugin"); } } return(loaderProperties); }
public static Dictionary <string, string> GetCustomSettings(string loaderName, ELoaderType loaderType, KraftModuleConfigurationSettings moduleSettings, bool isIterator = false) { LoaderProperties loaderProperties = GetLoaderProperties(loaderName, moduleSettings, loaderType, isIterator); if (loaderProperties != null) { return(loaderProperties.CustomSettings); } else { throw new NullReferenceException($"Loader properties for loader:{loaderName} are null (internal Dictionary<string, string> GetCustomSettings(string loaderName, Enumerations.ELoaderType loaderType))"); } }
internal static T GetPlugin <T>(string key, DependencyInjectionContainer dependencyInjectionContainer, KraftModuleConfigurationSettings kraftConfigurationSettings, ELoaderType pluginType, bool isIterator = false) where T : class { LoaderProperties loaderProperties = GetLoaderProperties(key, kraftConfigurationSettings, pluginType, isIterator); return(dependencyInjectionContainer.Get(loaderProperties.InterfaceAsType, kraftConfigurationSettings.ModuleName + loaderProperties.ImplementationAsString) as T); }
public abstract void Load(ELoaderType type);
public ILoadState CreateLoadTask(string[] assetPaths, OnLoadTaskComplete onTaskComplete, int priority, ELoaderType loaderType) { ILoadTask task = GetTask(); task.AddTaskCallBack(onTaskComplete); int loaderCount = assetPaths == null ? 0 : assetPaths.Length; //set loader count first, then the task could check if completed... task.SetLoaderCount(loaderCount); if (assetPaths != null) { for (int i = 0; i < assetPaths.Length; i++) { ILoader loader = GetLoader(assetPaths[i], priority, loaderType); loader.AddTask(task); } } ILoadState state = GetState(); state.SetTask(task); return(state); }
public ILoadState CreateLoadTask(string assetPath, OnLoadTaskComplete onTaskComplete, int priority, ELoaderType loaderType) { return(CreateLoadTask(new string[] { assetPath }, onTaskComplete, priority, loaderType)); }
public ILoadState CreateLoadTask(List <string> assetPaths, OnLoadTaskComplete onTaskComplete, int priority, ELoaderType loaderType) { return(CreateLoadTask(assetPaths.ToArray(), onTaskComplete, priority, loaderType)); }
public async Task <IPluginsSynchronizeContextScoped> GetSynchronizeContextScopedAsync <T>(string contextKey, ELoaderType loaderType, KraftModuleConfigurationSettings moduleConfigSettings, T plugin) where T : IPlugin { string key = $"{moduleConfigSettings.ModuleName}-{contextKey}"; IPluginsSynchronizeContextScoped pluginsSynchronizeContextScoped = null; if (_PluginsSynchronizeContext.ContainsKey(key)) { if (_PluginsSynchronizeContext.TryGetValue(key, out pluginsSynchronizeContextScoped)) { return(pluginsSynchronizeContextScoped); } Logger.LogError("_PluginsSynchronizeContext.TryGetValue(contextKey, out pluginsSynchronizeContextScoped) returned false"); } else { pluginsSynchronizeContextScoped = await plugin.GetSynchronizeContextScopedAsync(); pluginsSynchronizeContextScoped.CustomSettings = Utilities.GetCustomSettings(contextKey, loaderType, moduleConfigSettings); if (CanCache(pluginsSynchronizeContextScoped.CustomSettings)) { if (!_PluginsSynchronizeContext.TryAdd(key, pluginsSynchronizeContextScoped)) { Logger.LogError("_PluginsSynchronizeContext.TryAdd(contextKey, pluginsSynchronizeContextScoped) returned false"); } } } return(pluginsSynchronizeContextScoped); }