Ejemplo n.º 1
0
 protected T ReadAsset <T>(string assetName)
 {
     try
     {
         using (FileStream fs = new FileStream(System.IO.Path.Combine(RootDirectory, assetName + ".ego"), FileMode.Open, FileAccess.Read))
         {
             ContentFile res = formatter.Deserialize(fs) as ContentFile;
             if (res == null)
             {
                 throw new Exception("Could not load non content file");
             }
             return((T)res.Load(this, fs, typeof(T)));
         }
     }
     catch (IOException ex)
     {
         throw ex;
     }
     //return default(T);
 }
Ejemplo n.º 2
0
        public IEnumerable <string> ListContent <T>(string path, bool recursive = false)//rather slow(needs to load part of files)
        {
            var tp = GetReaderByOutput(typeof(T).FullName);

            foreach (var file in ListContent(path, false))
            {
                using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
                {
                    ContentFile res = formatter.Deserialize(fs) as ContentFile;
                    if (res == null)
                    {
                        continue;
                    }
                    Console.WriteLine(res.FileType);
                    if (res.FileType == tp.GetType().FullName)//TODO inheritance
                    {
                        yield return(file);
                    }
                }
            }
            yield break;
        }