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


C# Folder.ForceDelete方法代码示例

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


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

示例1: QueryResult_SortOrder_ModifyContent

        public void QueryResult_SortOrder_ModifyContent()
        {
            //create parent
            var parent = new Folder(TestRoot)
                             {
                                 Name = Guid.NewGuid().ToString(),
                                 InheritableVersioningMode = InheritableVersioningType.MajorAndMinor
                             };
            parent.Save();

            //create sample content
            Content car = null;
            var expIdList = new List<int>();
            var centerId = 0;

            for (var i = 0; i < 9; i++)
            {
                car = Content.CreateNew("Car", parent, "car-" + i.ToString().PadLeft(3, '0'));
                car.Save();

                expIdList.Add(car.Id);

                if (i == 4)
                    centerId = car.Id;
            }

            var query = ContentQuery.CreateQuery(string.Format("+InTree:\"{0}\" +TypeIs:Car .AUTOFILTERS:OFF", parent.Path),
                                            new QuerySettings { Sort = new[] {new SortInfo { FieldName = "Path" }}});

            var result = query.Execute();

            var actualIdList1 = result.Identifiers.ToList();
            var actualIdList2 = result.Nodes.Select(n => n.Id).ToList();

            var expString = string.Join(",", expIdList);
            var actualString1 = string.Join(",", actualIdList1);
            var actualString2 = string.Join(",", actualIdList2);

            Assert.AreEqual(expString, actualString1, "Result.Identifiers list is different than expected #1");
            Assert.AreEqual(expString, actualString2, "Result.Nodes list is different than expected #1");

            //change version of one of the cars
            car = Content.Load(centerId);
            car.CheckOut();

            //execute the query again
            result = query.Execute();

            actualIdList1 = result.Identifiers.ToList();
            actualIdList2 = result.Nodes.Select(n => n.Id).ToList();

            expString = string.Join(",", expIdList);
            actualString1 = string.Join(",", actualIdList1);
            actualString2 = string.Join(",", actualIdList2);

            Assert.AreEqual(expString, actualString1, "Result.Identifiers list is different than expected #2");
            Assert.AreEqual(expString, actualString2, "Result.Nodes list is different than expected #2");

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

示例2: Cache_NodeData_Folder

        public void Cache_NodeData_Folder()
        {
            /////////////////////////////////////////////////////////////
            // test Containers
            using (new CacheContentAfterSaveModeHacker(RepositoryConfiguration.CacheContentAfterSaveOption.Containers))
            {
                var newFolder = new Folder(TestRoot);
                newFolder.Name = Guid.NewGuid().ToString();
                newFolder.Save();
                var id = newFolder.Id;
                var versionId = newFolder.VersionId;
                var idKey = DataBackingStore.GenerateNodeDataVersionIdCacheKey(versionId);

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

                var folder = Node.LoadNode(id);

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

                folder.Index++;
                folder.Save();

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

                newFolder.ForceDelete();
            }

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

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

                var folder = Node.LoadNode(id);

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

                folder.Index++;
                folder.Save();

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

                newFolder.ForceDelete();
            }

            /////////////////////////////////////////////////////////////
            // test none
            using (new CacheContentAfterSaveModeHacker(RepositoryConfiguration.CacheContentAfterSaveOption.None))
            {

                var newFolder = new Folder(TestRoot);
                newFolder.Name = Guid.NewGuid().ToString();
                newFolder.Save();
                var id = newFolder.Id;
                var versionId = newFolder.VersionId;
                var idKey = DataBackingStore.GenerateNodeDataVersionIdCacheKey(versionId);

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

                var folder = Node.LoadNode(id);

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

                folder.Index++;
                folder.Save();

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

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

示例3: NodeIsModified_NotModifiedAfterRestoreValue

        public void NodeIsModified_NotModifiedAfterRestoreValue()
        {
            var folder = new Folder(TestRoot);
            folder.DisplayName = "OriginalDisplayName";
            folder.Save();
            var id = folder.Id;

            folder = Node.Load<Folder>(id);
            folder.Index += 1;
            var changes0 = folder.Data.GetChangedValues().Count();
            folder.Index -= 1;
            var changes1 = folder.Data.GetChangedValues().Count();
            folder.Save();
            var changes2 = folder.Data.GetChangedValues().Count();

            var origDisplayName = folder.DisplayName;
            folder.DisplayName += "_suffix";
            var changes3 = folder.Data.GetChangedValues().Count();
            folder.DisplayName = origDisplayName;
            var changes4 = folder.Data.GetChangedValues().Count();
            folder.Save();
            var changes5 = folder.Data.GetChangedValues().Count();

            folder.ForceDelete();

            Assert.IsTrue(changes0 > 0, "#0");
            Assert.IsTrue(changes1 == 0, "#1");
            Assert.IsTrue(changes2 == 0, "#2");
            Assert.IsTrue(changes3 > 0, "#3");
            Assert.IsTrue(changes4 == 0, "#4");
            Assert.IsTrue(changes5 == 0, "#5");
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:32,代码来源:NodeTest.cs

示例4: Cache_NodeHead_Folder

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

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

                var head = NodeHead.Get(id);

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

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

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

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

示例5: BinaryData_RenameNodeWithBinaryData

        public void BinaryData_RenameNodeWithBinaryData()
        {
			string rootName = "BinaryTestFolder";
			string rootPath = RepositoryPath.Combine(this.TestRoot.Path, rootName);

			if (Node.Exists(rootPath))
                Node.ForceDelete(rootPath);

			Folder binaryTestFolder = new Folder(this.TestRoot);
			binaryTestFolder.Name = rootName;
            binaryTestFolder.Save();

            TestNodeWithBinaryProperty tn1 = new TestNodeWithBinaryProperty(binaryTestFolder);

            tn1.Name = "OriginalName";
            tn1.Note = "This is the first test node. Nice, isn't it?";

            BinaryData firstBinary = new BinaryData();
            firstBinary.SetStream(new MemoryStream(new byte[] { 65, 66, 67, 68, 69 }));
            tn1.FirstBinary = firstBinary;

            BinaryData secondBinary = new BinaryData();
            secondBinary.SetStream(new MemoryStream(new byte[] { 97, 98, 99 }));
            tn1.SecondBinary = secondBinary;

            tn1.Save();

			// Drop the in-memory node and load from the Repository
            int testNodeId = tn1.Id;
            tn1 = null;
            TestNodeWithBinaryProperty loadedNode = (TestNodeWithBinaryProperty)Node.LoadNode(testNodeId);

            Stream firstStream = loadedNode.FirstBinary.GetStream();
            Stream secondStream = loadedNode.SecondBinary.GetStream();

            byte[] firstBuffer = new byte[firstStream.Length];
            byte[] secondBuffer = new byte[secondStream.Length];

            firstStream.Read(firstBuffer, 0, (int)firstStream.Length);
            secondStream.Read(secondBuffer, 0, (int)secondStream.Length);

            Assert.IsTrue(System.Text.Encoding.ASCII.GetString(firstBuffer) == "ABCDE", "The first binary had became corrupt after save.");
            Assert.IsTrue(System.Text.Encoding.ASCII.GetString(secondBuffer) == "abc", "The second binary had became corrupt after save.");
            
            // Close and dispost streams
            firstStream.Close();
            firstStream.Dispose();
            firstStream = null;
            secondStream.Close();
            secondStream.Dispose();
            secondStream = null;

            // The buffers should still hold  the data
            Assert.IsTrue(System.Text.Encoding.ASCII.GetString(firstBuffer) == "ABCDE", "The first binary had became corrupt after save.");
            Assert.IsTrue(System.Text.Encoding.ASCII.GetString(secondBuffer) == "abc", "The second binary had became corrupt after save.");

            firstBuffer = null;
            secondBuffer = null;

            // Get the stream again
            firstStream = loadedNode.FirstBinary.GetStream();
            secondStream = loadedNode.SecondBinary.GetStream();

            firstBuffer = new byte[firstStream.Length];
            secondBuffer = new byte[secondStream.Length];

            firstStream.Read(firstBuffer, 0, (int)firstStream.Length);
            secondStream.Read(secondBuffer, 0, (int)secondStream.Length);

            Assert.IsTrue(System.Text.Encoding.ASCII.GetString(firstBuffer) == "ABCDE", "The first binary had became corrupt after save.");
            Assert.IsTrue(System.Text.Encoding.ASCII.GetString(secondBuffer) == "abc", "The second binary had became corrupt after save.");

            // Close and dispost streams
            firstStream.Close();
            firstStream.Dispose();
            firstStream = null;
            secondStream.Close();
            secondStream.Dispose();
            secondStream = null;

            // The buffers should still hold  the data
            Assert.IsTrue(System.Text.Encoding.ASCII.GetString(firstBuffer) == "ABCDE", "The first binary had became corrupt after save.");
            Assert.IsTrue(System.Text.Encoding.ASCII.GetString(secondBuffer) == "abc", "The second binary had became corrupt after save.");

            // Change the name
            loadedNode.Name = "ModifiedName";
            loadedNode.Save();
            loadedNode = null;

            // Load the node again
            loadedNode = (TestNodeWithBinaryProperty)Node.LoadNode(testNodeId);

            Assert.IsTrue(loadedNode.Name == "ModifiedName");

            // Get the stream again
            firstStream = loadedNode.FirstBinary.GetStream();
            secondStream = loadedNode.SecondBinary.GetStream();

            firstBuffer = new byte[firstStream.Length];
            secondBuffer = new byte[secondStream.Length];
//.........这里部分代码省略.........
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:101,代码来源:BinaryDataTest.cs


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