当前位置: 首页>>代码示例>>C#>>正文


C# File.ForceDelete方法代码示例

本文整理汇总了C#中File.ForceDelete方法的典型用法代码示例。如果您正苦于以下问题:C# File.ForceDelete方法的具体用法?C# File.ForceDelete怎么用?C# File.ForceDelete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在File的用法示例。


在下文中一共展示了File.ForceDelete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Cache_NodeData_File

        public void Cache_NodeData_File()
        {
            using (new CacheContentAfterSaveModeHacker(RepositoryConfiguration.CacheContentAfterSaveOption.Containers))
            {
                var newFile = new File(TestRoot);
                newFile.Name = Guid.NewGuid().ToString();
                newFile.Save();
                var id = newFile.Id;
                var versionId = newFile.VersionId;
                var idKey = DataBackingStore.GenerateNodeDataVersionIdCacheKey(versionId);

                Assert.IsNull((NodeData)DistributedApplication.Cache.Get(idKey), "A file's NodeData is cached after creation");

                var file = Node.LoadNode(id);

                Assert.IsNotNull((NodeData)DistributedApplication.Cache.Get(idKey), "A file's NodeData is not cached after loading");

                file.Index++;
                file.Save();

                Assert.IsNull((NodeData)DistributedApplication.Cache.Get(idKey), "A file's NodeData is cached after updating");

                newFile.ForceDelete();
            }

            /////////////////////////////////////////////////////////////
            // test none
            using (new CacheContentAfterSaveModeHacker(RepositoryConfiguration.CacheContentAfterSaveOption.None))
            {
                var newFile = new File(TestRoot);
                newFile.Name = Guid.NewGuid().ToString();
                newFile.Save();
                var id = newFile.Id;
                var versionId = newFile.VersionId;
                var idKey = DataBackingStore.GenerateNodeDataVersionIdCacheKey(versionId);

                Assert.IsNull((NodeData)DistributedApplication.Cache.Get(idKey), "A file's NodeData is cached after creation");

                var file = Node.LoadNode(id);

                Assert.IsNotNull((NodeData)DistributedApplication.Cache.Get(idKey), "A file's NodeData is not cached after loading");

                file.Index++;
                file.Save();

                Assert.IsNull((NodeData)DistributedApplication.Cache.Get(idKey), "A file's NodeData is cached after updating");

                newFile.ForceDelete();
            }

            /////////////////////////////////////////////////////////////
            // test all
            using (new CacheContentAfterSaveModeHacker(RepositoryConfiguration.CacheContentAfterSaveOption.All))
            {
                var newFile = new File(TestRoot);
                newFile.Name = Guid.NewGuid().ToString();
                newFile.Save();
                var id = newFile.Id;
                var versionId = newFile.VersionId;
                var idKey = DataBackingStore.GenerateNodeDataVersionIdCacheKey(versionId);

                Assert.IsNotNull((NodeData)DistributedApplication.Cache.Get(idKey), "A file's NodeData is not cached after creation");

                var file = Node.LoadNode(id);

                Assert.IsNotNull((NodeData)DistributedApplication.Cache.Get(idKey), "A file's NodeData is not cached after loading");

                file.Index++;
                file.Save();

                Assert.IsNotNull((NodeData)DistributedApplication.Cache.Get(idKey), "A file's NodeData is not cached after updating");

                newFile.ForceDelete();
            }
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:75,代码来源:NodeTest.cs

示例2: NodeData_NewAndLoadedSharedData

        public void NodeData_NewAndLoadedSharedData()
        {
            var newFile = new File(TestRoot);
            var newFileData = newFile.Data;
            var newFileInnerData = newFile.Data.SharedData;
            Assert.IsFalse(newFileData.IsShared, "New file data is shared");
            Assert.IsNull(newFileInnerData, "New file inner data is not null");

            //----

            newFile.Name = Guid.NewGuid().ToString();
            newFile.Save();
            var id = newFile.Id;

            var savedFileData = newFile.Data;
            var savedFileInnerData = newFile.Data.SharedData;
            Assert.IsTrue(savedFileData.IsShared, "Saved file data is not shared");
            Assert.IsNull(savedFileInnerData, "Saved file inner data is not null");

            //----

            var loadedFile = Node.Load<File>(newFile.Id);

            var loadedFileData = loadedFile.Data;
            var loadedFileInnerData = loadedFile.Data.SharedData;
            Assert.IsTrue(loadedFileData.IsShared, "Loaded file data is not shared");
            Assert.IsNull(loadedFileInnerData, "Loaded file inner data is not null");
            //Assert.IsTrue(Object.ReferenceEquals(loadedFileData, savedFileData), "Saved shared and loaded shared are not the same");

            //----

            var reloadedFile = Node.Load<File>(newFile.Id);

            var reloadedFileData = reloadedFile.Data;
            var reloadedFileInnerData = reloadedFile.Data.SharedData;
            Assert.IsTrue(reloadedFileData.IsShared, "Loaded file data is not shared");
            Assert.IsNull(reloadedFileInnerData, "Loaded file inner data is not null");
            Assert.IsTrue(Object.ReferenceEquals(reloadedFileData, loadedFileData), "Reloaded shared and loaded shared are not the same");
            //Assert.IsTrue(Object.ReferenceEquals(reloadedFileData, savedFileData), "Reloaded shared and saved shared are not the same");

            //----

            reloadedFile.Description = Guid.NewGuid().ToString();

            var editedFileData = reloadedFile.Data;
            var editedFileInnerData = reloadedFile.Data.SharedData;
            Assert.IsFalse(editedFileData.IsShared, "Edited file data is shared");
            Assert.IsNotNull(editedFileInnerData, "Edited file inner data is null");
            Assert.IsTrue(editedFileInnerData.IsShared, "Edited file inner data is not shared");

            Assert.IsTrue(Object.ReferenceEquals(editedFileInnerData, loadedFileData), "Edited shared and loaded shared are not the same");
            //Assert.IsTrue(Object.ReferenceEquals(editedFileInnerData, savedFileData), "Edited shared and saved shared are not the same");

            //----

            reloadedFile.Save();
            var resavedFileData = reloadedFile.Data;
            var resavedFileInnerData = reloadedFile.Data.SharedData;
            Assert.IsTrue(resavedFileData.IsShared, "Resaved file data is not shared");
            Assert.IsNull(resavedFileInnerData, "Resaved file inner data is not null");
            Assert.IsFalse(Object.ReferenceEquals(resavedFileData, loadedFileData), "Resaved shared and loaded shared are the same");

            newFile.ForceDelete();
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:64,代码来源:NodeTest.cs

示例3: Cache_NodeHead_File

        public void Cache_NodeHead_File()
        {
            using (new CacheContentAfterSaveModeHacker(RepositoryConfiguration.CacheContentAfterSaveOption.Containers))
            {
                var newFile = new File(TestRoot);
                newFile.Name = Guid.NewGuid().ToString();
                newFile.Save();
                var id = newFile.Id;
                var path = newFile.Path;
                var idKey = DataBackingStore.CreateNodeHeadIdCacheKey(id);
                var pathKey = DataBackingStore.CreateNodeHeadPathCacheKey(path);

                Assert.IsNull((NodeHead)DistributedApplication.Cache.Get(idKey), "A file's NodeHead is cached by id after creation");
                Assert.IsNull((NodeHead)DistributedApplication.Cache.Get(pathKey), "A file's NodeHead is cached by path after creation");

                var head = NodeHead.Get(id);

                Assert.IsNotNull((NodeHead)DistributedApplication.Cache.Get(idKey), "A file's NodeHead is not cached by id after load");
                Assert.IsNotNull((NodeHead)DistributedApplication.Cache.Get(pathKey), "A file's NodeHead is not cached by path after load");

                var file = Node.LoadNode(id);
                file.Index++;
                file.Save();

                Assert.IsNull((NodeHead)DistributedApplication.Cache.Get(idKey), "A file's NodeHead is cached by id after updating");
                Assert.IsNull((NodeHead)DistributedApplication.Cache.Get(pathKey), "A file's NodeHead is cached by path after updating");

                newFile.ForceDelete();
            }
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:30,代码来源:NodeTest.cs

示例4: NodeIsModified_Reference

        public void NodeIsModified_Reference()
        {
            if (ContentType.GetByName("File2") == null)
                ContentTypeInstaller.InstallContentType(@"<?xml version=""1.0"" encoding=""utf-8""?>
					<ContentType name=""File2"" parentType=""File"" handler=""SenseNet.ContentRepository.File"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition"">
						<DisplayName>Folder</DisplayName>
						<Description>Use folders to group information to one place</Description>
						<Icon>Folder</Icon>
						<Fields>
							<Field name=""References"" type=""Reference"" />
						</Fields>
					</ContentType>");

            //int rootId = TestRoot.Id;
            //int file2ctId = ContentType.GetByName("File2").Id;
            var REFS = "References";
            var node1 = Node.LoadNode(1);
            var node2 = Node.LoadNode(2);
            var node3 = Node.LoadNode(3);
            var node4 = Node.LoadNode(4);
            var node5 = Node.LoadNode(5);
            var node6 = Node.LoadNode(6);

            var node = new File(TestRoot, "File2");
            node.SetReferences(REFS, new Node[] { node1, node2 }); // 1, 2
            node.Save();
            node = Node.Load<File>(node.Id);
            bool changed0 = node.IsModified;                       // false

            node.AddReference(REFS, node3);                        // 1, 2, 3
            bool changed1 = node.IsModified;                       // true
            node.RemoveReference(REFS, node3);                     // 1, 2
            bool changed2 = node.IsModified;                       // false
            node.RemoveReference(REFS, node1);                     // 2
            bool changed3 = node.IsModified;                       // true
            node.AddReference(REFS, node1);                        // 2, 1
            bool changed4 = node.IsModified;                       // true
            node.RemoveReference(REFS, node2);                     // 1
            bool changed5 = node.IsModified;                       // true
            node.AddReference(REFS, node2);                        // 1, 2
            bool changed6 = node.IsModified;                       // false
            node.SetReferences(REFS, new Node[] { node1, node2 }); // 1, 2
            bool changed7 = node.IsModified;                       // false

            node.ForceDelete();

            Assert.IsFalse(changed0, "#0");
            Assert.IsTrue(changed1, "#1");
            Assert.IsFalse(changed2, "#2");
            Assert.IsTrue(changed3, "#3");
            Assert.IsTrue(changed4, "#4");
            Assert.IsTrue(changed5, "#5");
            Assert.IsFalse(changed6, "#6");
            Assert.IsFalse(changed7, "#7");
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:55,代码来源:NodeTest.cs


注:本文中的File.ForceDelete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。