本文整理汇总了C#中Options.Find方法的典型用法代码示例。如果您正苦于以下问题:C# Options.Find方法的具体用法?C# Options.Find怎么用?C# Options.Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options.Find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestAllowOverride
public void TestAllowOverride()
{
PolicyTemplate template = new PolicyTemplate();
template.Load(policyFile);
Options options = new Options(pdfInternalExternal);
IAction internalAction = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.Internal].Values[0];
IAction externalAction = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.External].Values[0];
IPolicyObjectCollection<IDataElement> dataElements = internalAction.DataElements;
int allowOverride = 0;
int total = dataElements.Count;
foreach (IDataElement dataElement in dataElements)
{
if (string.Compare(dataElement["allowoverride"].Value, "true", true) == 0)
{
allowOverride++;
}
}
Option allowPdfOverride = options.Find(Sections.GeneralPolicy, "{b22927e1-afce-4081-8ebf-3187ee1bfc15}");
allowPdfOverride.Value = "0";
PdfPolicy pdfPolicy = new PdfPolicy(template, options);
pdfPolicy.Apply();
string runtimePolicy = System.IO.Path.GetTempFileName();
string myPolicy = System.IO.Path.GetTempFileName();
template.Save(myPolicy, runtimePolicy);
PolicyTemplate modifedTemplate = new PolicyTemplate();
modifedTemplate.Load(myPolicy);
internalAction = modifedTemplate[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.Internal].Values[0];
dataElements = internalAction.DataElements;
int modifedAllowOverride = 0;
int modifiedTotal = dataElements.Count;
foreach (IDataElement dataElement in dataElements)
{
if (string.Compare(dataElement["allowoverride"].Value, "true", false) == 0)
{
modifedAllowOverride++;
}
}
modifedTemplate.Close();
System.IO.File.Delete(myPolicy);
System.IO.File.Delete(runtimePolicy);
Assert.AreEqual(total, modifiedTotal, "The number of DataElements are not the same");
Assert.AreEqual(0, modifedAllowOverride, "All the DataElement's allowoverride attributes should have been set to false");
}