コード例 #1
0
ファイル: TestSerializer.cs プロジェクト: vol16bit/xenko
        private void SaveChangeResaveAssets(AssetManager assetManager)
        {
            var simpleAsset = new SimpleAsset("Grandpa", new SimpleAsset("Pa", new SimpleAsset("Son", null)));

            assetManager.Save(simpleAsset);
            simpleAsset.Dble       = 22.0;
            simpleAsset.Child.Dble = 42.0;
            assetManager.SaveSingle(simpleAsset);
        }
コード例 #2
0
ファイル: TestSerializer.cs プロジェクト: cg123/xenko
        private void SaveAssetsAndDeleteAChild(AssetManager assetManager)
        {
            var simpleAsset = new SimpleAsset("Pa", new SimpleAsset("Son", null));
            assetManager.Save(simpleAsset);
            var databaseFileProvider = (DatabaseFileProvider)VirtualFileSystem.ResolveProvider("/db", true).Provider;
            databaseFileProvider.AssetIndexMap.WaitPendingOperations();

            ObjectId childId;
            databaseFileProvider.AssetIndexMap.TryGetValue("SimpleAssets/Son", out childId);

            VirtualFileSystem.FileDelete(FileOdbBackend.BuildUrl(VirtualFileSystem.ApplicationDatabasePath, childId));
        }
コード例 #3
0
        private void SaveAssetsAndDeleteAChild(AssetManager assetManager)
        {
            var simpleAsset = new SimpleAsset("Pa", new SimpleAsset("Son", null));

            assetManager.Save(simpleAsset);
            var databaseFileProvider = (DatabaseFileProvider)VirtualFileSystem.ResolveProvider("/db", true).Provider;

            databaseFileProvider.AssetIndexMap.WaitPendingOperations();

            ObjectId childId;

            databaseFileProvider.AssetIndexMap.TryGetValue("SimpleAssets/Son", out childId);

            VirtualFileSystem.FileDelete(FileOdbBackend.BuildUrl(VirtualFileSystem.ApplicationDatabasePath, childId));
        }
コード例 #4
0
        private static void SaveSimpleAssets(AssetManager assetManager)
        {
            var simpleAsset = new SimpleAsset("Grandpa", new SimpleAsset("Pa", new SimpleAsset("Son", null)));

            assetManager.Save(simpleAsset);
        }
コード例 #5
0
ファイル: TestSerializer.cs プロジェクト: cg123/xenko
 private static void SaveCyclicallyReferencedAssets(AssetManager assetManager)
 {
     var simpleAsset = new SimpleAsset("First", new SimpleAsset("Second", new SimpleAsset("Third", null)));
     simpleAsset.Child.Child.Child = simpleAsset;
     assetManager.Save(simpleAsset);
 }
コード例 #6
0
ファイル: TestSerializer.cs プロジェクト: cg123/xenko
 public SimpleAsset(string str, SimpleAsset child)
 {
     Str = str;
     Dble = 5.0;
     Child = child;
     Url = "SimpleAssets/" + str;
 }
コード例 #7
0
ファイル: TestSerializer.cs プロジェクト: cg123/xenko
        public unsafe void TestSaveAndLoadAssetAndIndexFileManyTimes()
        {
            var assetManager = new AssetManager();
            var simpleAsset = new SimpleAsset("Grandpa", null) { Dble = 0.0 };
            assetManager.SaveSingle(simpleAsset);
            assetManager.Unload(simpleAsset);
            var databaseFileProvider = (DatabaseFileProvider)VirtualFileSystem.ResolveProvider("/db", true).Provider;
            databaseFileProvider.AssetIndexMap.WaitPendingOperations();
            simpleAsset = null;

            GC.Collect();

            for (double d = 0; d < 10.0; ++d)
            {
                var anotherAssetManager = new AssetManager();
                simpleAsset = anotherAssetManager.Load<SimpleAsset>("SimpleAssets/Grandpa");
                Assert.That(simpleAsset.Dble, Is.EqualTo(d));
                simpleAsset.Dble += 1.0;
                anotherAssetManager.SaveSingle(simpleAsset);
                anotherAssetManager.Unload(simpleAsset);
                databaseFileProvider.AssetIndexMap.WaitPendingOperations();
                simpleAsset = null;
                GC.Collect();
            }
        }
コード例 #8
0
ファイル: TestSerializer.cs プロジェクト: cg123/xenko
        public unsafe void TestSaveAndLoadAssetManyTimes()
        {
            var assetManager = new AssetManager();
            var simpleAsset = new SimpleAsset("Grandpa", null) { Dble = 0.0 };
            assetManager.SaveSingle(simpleAsset);
            assetManager.Unload(simpleAsset);
            simpleAsset = null;

            GC.Collect();

            for (double d = 0; d < 10.0; ++d)
            {
                simpleAsset = assetManager.Load<SimpleAsset>("SimpleAssets/Grandpa");
                Assert.That(simpleAsset.Dble, Is.EqualTo(d));
                simpleAsset.Dble += 1.0;
                assetManager.SaveSingle(simpleAsset);
                assetManager.Unload(simpleAsset);
                simpleAsset = null;
                GC.Collect();
            }
        }
コード例 #9
0
ファイル: TestSerializer.cs プロジェクト: cg123/xenko
 private void SaveChangeResaveAssets(AssetManager assetManager)
 {
     var simpleAsset = new SimpleAsset("Grandpa", new SimpleAsset("Pa", new SimpleAsset("Son", null)));
     assetManager.Save(simpleAsset);
     simpleAsset.Dble = 22.0;
     simpleAsset.Child.Dble = 42.0;
     assetManager.SaveSingle(simpleAsset);
 }
コード例 #10
0
ファイル: TestSerializer.cs プロジェクト: cg123/xenko
 private static void SaveSimpleAssets(AssetManager assetManager)
 {
     var simpleAsset = new SimpleAsset("Grandpa", new SimpleAsset("Pa", new SimpleAsset("Son", null)));
     assetManager.Save(simpleAsset);
 }