當前位置: 首頁>>代碼示例>>C#>>正文


C# File.ExpandContainer方法代碼示例

本文整理匯總了C#中System.IO.File.ExpandContainer方法的典型用法代碼示例。如果您正苦於以下問題:C# File.ExpandContainer方法的具體用法?C# File.ExpandContainer怎麽用?C# File.ExpandContainer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.File的用法示例。


在下文中一共展示了File.ExpandContainer方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Test_10_ExecuteAction_SMTP_Default_Policy_And_ZIP_Policy

		public void Test_10_ExecuteAction_SMTP_Default_Policy_And_ZIP_Policy()
		{
			IPolicyCache policyCache = TestHelpers.CreatePolicyCache(new string[] { 
				Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\Projects\Hygiene\Policies\p5default.policy"),
				Path.Combine(POLICY_FOLDER, "TestActionProcessor - Zip Policy Set.policy") });

			Assert.IsNotNull(policyCache);
			Assert.AreEqual(2, policyCache.PolicySets.Count);

			PolicyEngineCache policyEngineCache = new PolicyEngineCache(policyCache, null);
			ConditionProcessor conditionProcessor = new ConditionProcessor(policyEngineCache, null);

			List<string> attachments = new List<string>();
			attachments.Add(Path.Combine(TEST_FOLDER, "TestProfanity.doc"));
			attachments.Add(Path.Combine(TEST_FOLDER, "Dirty.doc"));
			attachments.Add(Path.Combine(TEST_FOLDER, "TestDoc.ppt"));

			IUniversalRequestObject uro = TestHelpers.CreateSmtpUro(attachments);

			// PROCESS CONDITIONS
			IContainer container;
			PolicyResponseObject pro = conditionProcessor.Process(RunAt.Client, uro, out container);
			Assert.IsNotNull(pro);

			// PROCESS ROUTING
			RoutingProcessor routingProcessor = new RoutingProcessor(policyEngineCache);
			Assert.IsNotNull(routingProcessor.Process(pro));

			Assert.AreEqual(4, pro.ContentCollection.Count);
			Assert.AreEqual(FileType.Email.ToString(), pro.ContentCollection[0].Type);
			Assert.AreEqual(FileType.WordDocument.ToString(), pro.ContentCollection[1].Type);
			Assert.AreEqual(FileType.WordDocument.ToString(), pro.ContentCollection[2].Type);
			Assert.AreEqual(FileType.PowerPoint.ToString(), pro.ContentCollection[3].Type);

			Assert.AreEqual(3, pro.UniversalRequestObject.Attachments.Count);
			Assert.AreEqual("TestProfanity.doc", Path.GetFileName(pro.UniversalRequestObject.Attachments[0].Name));
			Assert.AreEqual("Dirty.doc", Path.GetFileName(pro.UniversalRequestObject.Attachments[1].Name));
			Assert.AreEqual("TestDoc.ppt", Path.GetFileName(pro.UniversalRequestObject.Attachments[2].Name));

			// PROCESS ACTIONS
			ActionProcessor actionProcessor = new ActionProcessor(policyCache, policyEngineCache);
			actionProcessor.ProcessActions(pro);
			ActionUtils.PopulateResolvedActionCollection(pro);

			// EXECUTE ACTIONS
			ActionExecuter executer = new ActionExecuter(null);
			IUniversalRequestObject outputUro = executer.ExecuteActions(pro, ref container);

			//Assert.AreEqual(4, pro.ContentCollection.Count);
			//Assert.AreEqual(FileType.Email.ToString(), pro.ContentCollection[0].Type);
			//Assert.AreEqual(FileType.WordDocument.ToString(), pro.ContentCollection[1].Type);
			//Assert.AreEqual(FileType.WordDocument.ToString(), pro.ContentCollection[2].Type);
			//Assert.AreEqual(FileType.PowerPoint.ToString(), pro.ContentCollection[3].Type);

			Assert.AreEqual(2, outputUro.Attachments.Count);
			Assert.AreEqual("TestDoc.ppt", outputUro.Attachments[0].Name);
			Assert.AreEqual("attachments.zip", outputUro.Attachments[1].Name);

			File outputFile = new File(outputUro.Attachments[1].Data, outputUro.Attachments[0].Name);
			Assert.IsNotNull(outputFile);
			outputFile.ExpandContainer(outputFile.Password);
			Assert.AreEqual(2, outputFile.Files.Count);
			Assert.AreEqual("TestProfanity.doc", outputFile.Files[0].DisplayName);
			Assert.AreEqual("Dirty.doc", outputFile.Files[1].DisplayName);
		}
開發者ID:killbug2004,項目名稱:WSProf,代碼行數:65,代碼來源:TestActionExecuter.cs


注:本文中的System.IO.File.ExpandContainer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。