public IBasicAsset LoadBasic(string path) { try { //App.Log( "Loading {0}", path ); var assetType = Assets.GetType(AssetPath.GetExtension(path)); var constructor = assetType.GetConstructor(new Type[] { typeof(string), typeof(IFileStore) }); try { return((IBasicAsset)constructor.Invoke(new object[] { path, m_fileStore })); } catch (TargetInvocationException e) { throw e.InnerException; } } catch (Exception e) { throw new AssetLoadException(path, e); } }
private IEnumerable <string> EnumeratePaths(string root = "") { if (m_fileStore.FileExists(root)) { if (Assets.GetType(AssetPath.GetExtension(root)) != null) { yield return(root); } } else if (m_fileStore.DirectoryExists(root)) { foreach (var dirName in m_fileStore.ListDirectories(root)) { var dirPath = AssetPath.Combine(root, dirName); foreach (var filePath in EnumeratePaths(dirPath)) { yield return(filePath); } } foreach (var fileName in m_fileStore.ListFiles(root)) { var filePath = AssetPath.Combine(root, fileName); if (Assets.GetType(AssetPath.GetExtension(filePath)) != null) { yield return(filePath); } } } }
private static ICompoundAsset ConstructCompoundAsset(string path) { var assetType = Assets.GetType(AssetPath.GetExtension(path)); var constructor = assetType.GetConstructor(new Type[] { typeof(string) }); try { return((ICompoundAsset)constructor.Invoke(new object[] { path })); } catch (TargetInvocationException e) { throw e.InnerException; } }
public bool CanLoad(string path) { return (Assets.GetType(AssetPath.GetExtension(path)) != null && m_fileStore.FileExists(path)); }