BuildImporters() public static method

public static BuildImporters ( ) : AlphaTab.Importer.ScoreImporter[]
return AlphaTab.Importer.ScoreImporter[]
        public static Score LoadScoreFromBytes(byte[] data)
        {
            var importers = ScoreImporter.BuildImporters();

            Score      score = null;
            ByteBuffer bb    = ByteBuffer.FromBuffer(data);

            foreach (var importer in importers)
            {
                bb.Reset();
                try
                {
                    importer.Init(bb);
                    score = importer.ReadScore();
                    break;
                }
                catch (Exception e)
                {
                    if (!Std.IsException <UnsupportedFormatException>(e))
                    {
                        throw e;
                    }
                }
            }

            if (score != null)
            {
                return(score);
            }
            throw new NoCompatibleReaderFoundException();
        }
Example #2
0
        public static Score LoadScoreFromBytes(byte[] data)
        {
            var importers = ScoreImporter.BuildImporters();

            Logger.Info("ScoreLoader", "Loading score from " + data.Length + " bytes using " + importers.Length + " importers");

            Score      score = null;
            ByteBuffer bb    = ByteBuffer.FromBuffer(data);

            foreach (var importer in importers)
            {
                bb.Reset();
                try
                {
                    Logger.Info("ScoreLoader", "Importing using importer " + importer.Name);
                    importer.Init(bb);
                    score = importer.ReadScore();
                    Logger.Info("ScoreLoader", "Score imported using " + importer.Name);
                    break;
                }
                catch (Exception e)
                {
                    if (!Std.IsException <UnsupportedFormatException>(e))
                    {
                        Logger.Info("ScoreLoader", "Score import failed due to unexpected error: " + e);
                        throw e;
                    }
                    else
                    {
                        Logger.Info("ScoreLoader", importer.Name + " does not support the file");
                    }
                }
            }

            if (score != null)
            {
                return(score);
            }

            Logger.Error("ScoreLoader", "No compatible importer found for file");
            throw new NoCompatibleReaderFoundException();
        }