コード例 #1
0
        public void TestAsyncLoad( )
        {
            AssetManager assets = new AssetManager( );
            assets.AddLoader( new XmlAssetLoader( 10 ) );

            using ( AsyncAssetLoader loader = new AsyncAssetLoader( ) )
            {
                int success = 0;

                int numLoads = 8;
                AsyncLoadResult[] results = new AsyncLoadResult[ numLoads ];

                for ( int loadCount = 0; loadCount < numLoads; ++loadCount )
                {
                    AsyncLoadResult result = loader.QueueLoad( assets, new StreamSource( XmlContent, "test.xml" ), null, LoadPriority.High );
                    result.AddLoadCompleteCallback(
                        delegate( object asset )
                            {
                                CheckDocument( ( XmlNode )asset );
                                ++success;
                            },
                        false );

                    results[ loadCount ] = result;
                }

                for ( int loadCount = 0; loadCount < numLoads; ++loadCount )
                {
                    results[ loadCount ].WaitUntilComplete( new TimeSpan( 0, 0, 2 ) );
                }

                Assert.AreEqual( success, numLoads );
            }
        }
コード例 #2
0
        public void TestLoad( )
        {
            AssetManager assets = new AssetManager( );
            assets.AddLoader( new XmlAssetLoader( 0 ) );

            XmlDocument doc = ( XmlDocument )assets.Load( new StreamSource( XmlContent, "test.xml" ) );
            CheckDocument( doc );
        }