예제 #1
0
 static IEnumerable <Asset> LoadAsset(AssetType type, Resource resource, IFilePath pathBase,
                                      string @namespace, IFilePath currentPath = null)
 {
     currentPath ??= pathBase;
     if (!currentPath.Exists)
     {
         yield break;
     }
     if (currentPath.IsDirectory)
     {
         foreach (var subPath in currentPath)
         {
             foreach (var asset in LoadAsset(type, resource, pathBase, @namespace, subPath))
             {
                 yield return(asset);
             }
         }
     }
     else if (currentPath.IsFile)
     {
         yield return(new AssetFile(
                          string.Join(
                              '/',
                              currentPath.GetUpDirectories()
                              .Where(path => !Equals(path, pathBase))
                              .Where(path => !pathBase.GetUpDirectories().Contains(path))
                              .Append(currentPath)
                              .OrderBy(path => path.PathName.Length)
                              .Select(path => path.GetFileName())),
                          type,
                          resource,
                          currentPath,
                          @namespace));
     }
 }