本文整理汇总了C#中HashSet2.Add方法的典型用法代码示例。如果您正苦于以下问题:C# HashSet2.Add方法的具体用法?C# HashSet2.Add怎么用?C# HashSet2.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashSet2
的用法示例。
在下文中一共展示了HashSet2.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveLayers
/// <summary>
/// Removes layers from a PDF document </summary>
/// <param name="reader"> a PdfReader containing a PDF document </param>
/// <param name="layers"> a sequence of names of OCG layers </param>
/// <exception cref="IOException"> </exception>
public virtual void RemoveLayers(PdfReader reader, params string[] layers) {
int n = reader.NumberOfPages;
for (int i = 1; i <= n; i++)
reader.SetPageContent(i, reader.GetPageContent(i));
ICollection<string> ocgs = new HashSet2<string>();
for (int i = 0; i < layers.Length; i++) {
ocgs.Add(layers[i]);
}
OCGParser parser = new OCGParser(ocgs);
for (int i = 1; i <= n; i++) {
PdfDictionary page = reader.GetPageN(i);
Parse(parser, page);
page.Remove(PdfName.PIECEINFO);
RemoveAnnots(page, ocgs);
RemoveProperties(page, ocgs);
}
PdfDictionary root = reader.Catalog;
PdfDictionary ocproperties = root.GetAsDict(PdfName.OCPROPERTIES);
if (ocproperties != null) {
RemoveOCGsFromArray(ocproperties, PdfName.OCGS, ocgs);
PdfDictionary d = ocproperties.GetAsDict(PdfName.D);
if (d != null) {
RemoveOCGsFromArray(d, PdfName.ON, ocgs);
RemoveOCGsFromArray(d, PdfName.OFF, ocgs);
RemoveOCGsFromArray(d, PdfName.LOCKED, ocgs);
RemoveOCGsFromArray(d, PdfName.RBGROUPS, ocgs);
RemoveOCGsFromArray(d, PdfName.ORDER, ocgs);
RemoveOCGsFromArray(d, PdfName.AS, ocgs);
}
PdfArray ocgsArray = ocproperties.GetAsArray(PdfName.OCGS);
if (ocgsArray != null && ocgsArray.IsEmpty()) {
root.Remove(PdfName.OCPROPERTIES);
if (PdfName.USEOC.Equals(root.GetAsName(PdfName.PAGEMODE))) {
root.Remove(PdfName.PAGEMODE);
}
}
}
reader.RemoveUnusedObjects();
}
示例2: MergeTextDecorationRules
private String MergeTextDecorationRules(String oldRule, String newRule) {
if (CSS.Value.NONE.Equals(newRule))
return newRule;
HashSet2<String> attrSet = new HashSet2<String>();
if (oldRule != null)
foreach (String attr in new Regex(@"\s+").Split(oldRule))
attrSet.Add(attr);
if (newRule != null)
foreach (String attr in new Regex(@"\s+").Split(newRule))
attrSet.Add(attr);
StringBuilder resultantStr = new StringBuilder();
foreach (String attr in attrSet) {
if (attr.Equals(CSS.Value.NONE) || attr.Equals(CSS.Value.INHERIT))
continue;
if (resultantStr.Length > 0)
resultantStr.Append(' ');
resultantStr.Append(attr);
}
return resultantStr.Length == 0 ? null : resultantStr.ToString();
}
示例3: FillOrderRecursively
private void FillOrderRecursively(PdfArray orderArray, HashSet2<PdfObject> order) {
for (int i = 0; i < orderArray.Size; i++) {
PdfArray orderChild = GetDirectArray(orderArray[i]);
if (orderChild == null) {
order.Add(orderArray[i]);
} else {
FillOrderRecursively(orderChild, order);
}
}
}
示例4: CheckLayer
protected override void CheckLayer(PdfWriter writer, int key, Object obj1) {
if (obj1 is IPdfOCG) {
} else if (obj1 is PdfOCProperties) {
PdfOCProperties properties = (PdfOCProperties)obj1;
List<PdfDictionary> configsList = new List<PdfDictionary>();
PdfDictionary d = GetDirectDictionary(properties.Get(PdfName.D));
if (d != null)
configsList.Add(d);
PdfArray configs = GetDirectArray(properties.Get(PdfName.CONFIGS));
if (configs != null) {
for (int i = 0; i < configs.Size; i++) {
PdfDictionary config = GetDirectDictionary(configs[i]);
if (config != null)
configsList.Add(config);
}
}
HashSet2<PdfObject> ocgs = new HashSet2<PdfObject>();
PdfArray ocgsArray = GetDirectArray(properties.Get(PdfName.OCGS));
if (ocgsArray != null)
for (int i = 0; i < ocgsArray.Size; i++)
ocgs.Add(ocgsArray[i]);
HashSet2<String> names = new HashSet2<String>();
HashSet2<PdfObject> order = new HashSet2<PdfObject>();
foreach (PdfDictionary config in configsList) {
PdfString name = config.GetAsString(PdfName.NAME);
if (name == null) {
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("optional.content.configuration.dictionary.shall.contain.name.entry"));
}
String name1 = name.ToUnicodeString();
if (names.Contains(name1)) {
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("value.of.name.entry.shall.be.unique.amongst.all.optional.content.configuration.dictionaries"));
}
names.Add(name1);
if (config.Contains(PdfName.AS)) {
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("the.as.key.shall.not.appear.in.any.optional.content.configuration.dictionary"));
}
PdfArray orderArray = GetDirectArray(config.Get(PdfName.ORDER));
if (orderArray != null)
FillOrderRecursively(orderArray, order);
}
if (order.Count != ocgs.Count) {
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("order.array.shall.contain.references.to.all.ocgs"));
}
ocgs.RetainAll(order);
if (order.Count != ocgs.Count) {
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("order.array.shall.contain.references.to.all.ocgs"));
}
} else {
}
}
示例5: PdfCleanUpContentOperator
static PdfCleanUpContentOperator() {
pathPaintingOperators = new HashSet2<string>(strokeOperators);
pathPaintingOperators.AddAll(nwFillOperators);
pathPaintingOperators.AddAll(eoFillOperators);
pathPaintingOperators.Add("n");
}