当前位置: 首页>>代码示例>>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;未经允许,请勿转载。