示例#1
0
        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
        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));
        }
        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));
        }
        private static void SaveSimpleAssets(AssetManager assetManager)
        {
            var simpleAsset = new SimpleAsset("Grandpa", new SimpleAsset("Pa", new SimpleAsset("Son", null)));

            assetManager.Save(simpleAsset);
        }
示例#5
0
 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
 public SimpleAsset(string str, SimpleAsset child)
 {
     Str = str;
     Dble = 5.0;
     Child = child;
     Url = "SimpleAssets/" + str;
 }
示例#7
0
        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
        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
 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
 private static void SaveSimpleAssets(AssetManager assetManager)
 {
     var simpleAsset = new SimpleAsset("Grandpa", new SimpleAsset("Pa", new SimpleAsset("Son", null)));
     assetManager.Save(simpleAsset);
 }