public static void TestRemove() { LinkedDictionary <string, int> linked = new LinkedDictionary <string, int>(); linked.Add("a", 1); linked.Add("b", 2); Assert.AreEqual(linked.Count, 2); Assert.AreEqual(linked["a"], 1); Assert.AreEqual(linked["b"], 2); Assert.IsTrue(linked.ContainsKey("a")); Assert.IsTrue(linked.ContainsKey("b")); Assert.IsTrue(linked.Remove("a")); Assert.IsFalse(linked.Remove("c")); Assert.AreEqual(linked.Count, 1); Assert.IsFalse(linked.ContainsKey("a")); Assert.IsTrue(linked.ContainsKey("b")); Assert.AreEqual(linked["b"], 2); Assert.IsFalse(linked.Remove("a")); Assert.IsTrue(linked.Remove("b")); Assert.AreEqual(linked.Count, 0); Assert.IsFalse(linked.ContainsKey("b")); }
public static void TestContains() { LinkedDictionary <int, string> linked = new LinkedDictionary <int, string>(); linked.Add(1, "a"); Assert.AreEqual(linked.Count, 1); Assert.AreEqual(linked[1], "a"); Assert.IsTrue(linked.ContainsKey(1)); Assert.IsFalse(linked.ContainsKey(0)); Assert.IsFalse(linked.ContainsKey(2)); }
///<summary>Возвращает итератор, перечисляющий элементы индексатора ///IndexEntry</summary> public IEnumerator <Leaf> GetEnumerator() { CSharpDataStructures.Structures.Lists.LinkedList <Leaf> E = new CSharpDataStructures.Structures.Lists.LinkedList <Leaf>(); STACK S = new STACK(); S.Push(_tree); while (!S.IsEmpty()) { Object b = S.Top(); S.Pop(); LinkedDictionary <Char, Object> children = (LinkedDictionary <Char, Object>)b; ICollection <Char> keys = children.Keys; foreach (Char k in keys) { if (k == '$') { continue; } S.Push(children.GetValue(k)); } if (children.ContainsKey('$') && children.GetValue('$') != null) { E.add((Leaf)children.GetValue('$')); } } return(E.GetEnumerator()); }
/// <summary> /// Parses each hocr file from the provided list, retrieves text, and /// returns data in the format described below. /// </summary> /// <param name="inputFiles">list of input files</param> /// <param name="textPositioning"> /// /// <see cref="TextPositioning"/> /// </param> /// <returns> /// /// <see cref="System.Collections.IDictionary{K, V}"/> /// where key is /// <see cref="int?"/> /// representing the number of the page and value is /// <see cref="System.Collections.IList{E}"/> /// of /// <see cref="iText.Pdfocr.TextInfo"/> /// elements where each /// <see cref="iText.Pdfocr.TextInfo"/> /// element contains a word or a line and its 4 /// coordinates(bbox) /// </returns> public static IDictionary <int, IList <TextInfo> > ParseHocrFile(IList <FileInfo> inputFiles, TextPositioning textPositioning) { IDictionary <int, IList <TextInfo> > imageData = new LinkedDictionary <int, IList <TextInfo> >(); IDictionary <String, iText.StyledXmlParser.Jsoup.Nodes.Node> unparsedBBoxes = new LinkedDictionary <String, iText.StyledXmlParser.Jsoup.Nodes.Node>(); foreach (FileInfo inputFile in inputFiles) { if (inputFile != null && File.Exists(System.IO.Path.Combine(inputFile.FullName))) { FileStream fileInputStream = new FileStream(inputFile.FullName, FileMode.Open, FileAccess.Read); Document doc = iText.StyledXmlParser.Jsoup.Jsoup.Parse(fileInputStream, System.Text.Encoding.UTF8.Name(), inputFile.FullName); Elements pages = doc.GetElementsByClass("ocr_page"); IList <String> searchedClasses = TextPositioning.BY_LINES.Equals(textPositioning) ? JavaUtil.ArraysAsList("ocr_line" , "ocr_caption") : JavaCollectionsUtil.SingletonList <String>("ocrx_word"); foreach (iText.StyledXmlParser.Jsoup.Nodes.Element page in pages) { String[] pageNum = iText.IO.Util.StringUtil.Split(page.Id(), "page_"); int pageNumber = Convert.ToInt32(pageNum[pageNum.Length - 1], System.Globalization.CultureInfo.InvariantCulture ); IList <TextInfo> textData = new List <TextInfo>(); if (searchedClasses.Count > 0) { Elements objects = page.GetElementsByClass(searchedClasses[0]); for (int i = 1; i < searchedClasses.Count; i++) { Elements foundElements = page.GetElementsByClass(searchedClasses[i]); for (int j = 0; j < foundElements.Count; j++) { objects.Add(foundElements[j]); } } foreach (iText.StyledXmlParser.Jsoup.Nodes.Element obj in objects) { IList <float> coordinates = GetAlignedBBox(obj, textPositioning, unparsedBBoxes); textData.Add(new TextInfo(obj.Text(), coordinates)); } } if (textData.Count > 0) { if (imageData.ContainsKey(pageNumber)) { pageNumber = Enumerable.Max(imageData.Keys) + 1; } imageData.Put(pageNumber, textData); } } fileInputStream.Dispose(); } } foreach (iText.StyledXmlParser.Jsoup.Nodes.Node node in unparsedBBoxes.Values) { LOGGER.Warn(MessageFormatUtil.Format(Tesseract4LogMessageConstant.CANNOT_PARSE_NODE_BBOX, node.ToString()) ); } return(imageData); }
public void CopyConstructor_MutateOriginal_CopyIsUnaffected() { var linkedDictionary = InitializeDictionarySequentialKeys(30); var copyDictionary = new LinkedDictionary <int, int>(linkedDictionary); linkedDictionary.Remove(15); Assert.True(copyDictionary.ContainsKey(15)); }
/// <summary> /// 增加到工作流的头部,moveTask用于控制当已经存在key的时候,是否将它移动到头部 /// </summary> public void AddFirst(string key, CoroutineAcion coroutineAcion, bool replaceAction = true, bool moveTask = false) { if (m_CoroutineMap.ContainsKey(key)) { if (replaceAction) { m_CoroutineMap[key] = coroutineAcion; } if (moveTask) { coroutineAcion = m_CoroutineMap[key]; m_CoroutineMap.Remove(key); m_CoroutineMap.AddFirst(key, coroutineAcion); } } else { m_CoroutineMap.AddFirst(key, coroutineAcion); } }
public void RemoveCallback(AssetAsyncLoad asyncLoad) { if (m_LoadedCallbackList.ContainsKey(asyncLoad)) { m_LoadedCallbackList.Remove(asyncLoad); } if (m_ProgressCallbackList.ContainsKey(asyncLoad)) { m_ProgressCallbackList.Remove(asyncLoad); } }
public void LinkedDictionary_Generic_ContainsValue_DefaultValuePresent(int count) { LinkedDictionary <TKey, TValue> dictionary = (LinkedDictionary <TKey, TValue>)GenericIDictionaryFactory(count); int seed = 4315; TKey notPresent = CreateTKey(seed++); while (dictionary.ContainsKey(notPresent)) { notPresent = CreateTKey(seed++); } dictionary.Add(notPresent, default(TValue)); Assert.True(dictionary.ContainsValue(default(TValue))); }
public void DeleteDataBlock(IDataBlock dataBlock) { PreConditions.Argument("dataBlock").Value(dataBlock).IsNotNull(); if (!_inputFiles.ContainsKey(dataBlock.InputFile)) { throw new ArgumentException("Input file not in project.", "dataBlock"); } // Remove data block if it exists if (!_inputFiles[dataBlock.InputFile].DataBlocks.Remove(dataBlock)) { throw new ArgumentException("Data block does not exist.", "dataBlock"); } UpdateProject(ProjectChangedType.DataBlockDeleted, dataBlock); }
public void LinkedDictionary_Generic_RemoveKey_DefaultKeyNotContainedInDictionary(int count) { LinkedDictionary <TKey, TValue> dictionary = (LinkedDictionary <TKey, TValue>)GenericIDictionaryFactory(count); TValue outValue; if (DefaultValueAllowed) { TKey missingKey = default(TKey); while (dictionary.ContainsKey(missingKey)) { dictionary.Remove(missingKey); } Assert.False(dictionary.Remove(missingKey, out outValue)); Assert.Equal(default(TValue), outValue); } else { TValue initValue = CreateTValue(count); outValue = initValue; Assert.Throws <ArgumentNullException>(() => dictionary.Remove(default(TKey), out outValue)); Assert.Equal(initValue, outValue); } }
/// <exception cref="System.IO.IOException"/> private void InitializeFontProperties() { // initialize sfnt tables OpenTypeParser.HeaderTable head = fontParser.GetHeadTable(); OpenTypeParser.HorizontalHeader hhea = fontParser.GetHheaTable(); OpenTypeParser.WindowsMetrics os_2 = fontParser.GetOs_2Table(); OpenTypeParser.PostTable post = fontParser.GetPostTable(); isFontSpecific = fontParser.GetCmapTable().fontSpecific; kerning = fontParser.ReadKerning(head.unitsPerEm); bBoxes = fontParser.ReadBbox(head.unitsPerEm); // font names group fontNames = fontParser.GetFontNames(); // font metrics group fontMetrics.SetUnitsPerEm(head.unitsPerEm); fontMetrics.UpdateBbox(head.xMin, head.yMin, head.xMax, head.yMax); fontMetrics.SetNumberOfGlyphs(fontParser.ReadNumGlyphs()); fontMetrics.SetGlyphWidths(fontParser.GetGlyphWidthsByIndex()); fontMetrics.SetTypoAscender(os_2.sTypoAscender); fontMetrics.SetTypoDescender(os_2.sTypoDescender); fontMetrics.SetCapHeight(os_2.sCapHeight); fontMetrics.SetXHeight(os_2.sxHeight); fontMetrics.SetItalicAngle(post.italicAngle); fontMetrics.SetAscender(hhea.Ascender); fontMetrics.SetDescender(hhea.Descender); fontMetrics.SetLineGap(hhea.LineGap); fontMetrics.SetWinAscender(os_2.usWinAscent); fontMetrics.SetWinDescender(os_2.usWinDescent); fontMetrics.SetAdvanceWidthMax(hhea.advanceWidthMax); fontMetrics.SetUnderlinePosition((post.underlinePosition - post.underlineThickness) / 2); fontMetrics.SetUnderlineThickness(post.underlineThickness); fontMetrics.SetStrikeoutPosition(os_2.yStrikeoutPosition); fontMetrics.SetStrikeoutSize(os_2.yStrikeoutSize); fontMetrics.SetSubscriptOffset(-os_2.ySubscriptYOffset); fontMetrics.SetSubscriptSize(os_2.ySubscriptYSize); fontMetrics.SetSuperscriptOffset(os_2.ySuperscriptYOffset); fontMetrics.SetSuperscriptSize(os_2.ySuperscriptYSize); fontMetrics.SetIsFixedPitch(post.isFixedPitch); // font identification group String[][] ttfVersion = fontNames.GetNames(5); if (ttfVersion != null) { fontIdentification.SetTtfVersion(ttfVersion[0][3]); } String[][] ttfUniqueId = fontNames.GetNames(3); if (ttfUniqueId != null) { fontIdentification.SetTtfVersion(ttfUniqueId[0][3]); } byte[] pdfPanose = new byte[12]; pdfPanose[1] = (byte)(os_2.sFamilyClass); pdfPanose[0] = (byte)(os_2.sFamilyClass >> 8); Array.Copy(os_2.panose, 0, pdfPanose, 2, 10); fontIdentification.SetPanose(pdfPanose); IDictionary <int, int[]> cmap = GetActiveCmap(); int[] glyphWidths = fontParser.GetGlyphWidthsByIndex(); int numOfGlyphs = fontMetrics.GetNumberOfGlyphs(); unicodeToGlyph = new LinkedDictionary <int, Glyph>(cmap.Count); codeToGlyph = new LinkedDictionary <int, Glyph>(numOfGlyphs); avgWidth = 0; foreach (int charCode in cmap.Keys) { int index = cmap.Get(charCode)[0]; if (index >= numOfGlyphs) { ILog LOGGER = LogManager.GetLogger(typeof(iText.IO.Font.TrueTypeFont)); LOGGER.Warn(MessageFormatUtil.Format(iText.IO.LogMessageConstant.FONT_HAS_INVALID_GLYPH, GetFontNames().GetFontName (), index)); continue; } Glyph glyph = new Glyph(index, glyphWidths[index], charCode, bBoxes != null ? bBoxes[index] : null); unicodeToGlyph.Put(charCode, glyph); // This is done on purpose to keep the mapping to glyphs with smaller unicode values, in contrast with // larger values which often represent different forms of other characters. if (!codeToGlyph.ContainsKey(index)) { codeToGlyph.Put(index, glyph); } avgWidth += glyph.GetWidth(); } FixSpaceIssue(); for (int index = 0; index < glyphWidths.Length; index++) { if (codeToGlyph.ContainsKey(index)) { continue; } Glyph glyph = new Glyph(index, glyphWidths[index], -1); codeToGlyph.Put(index, glyph); avgWidth += glyph.GetWidth(); } if (codeToGlyph.Count != 0) { avgWidth /= codeToGlyph.Count; } ReadGdefTable(); ReadGsubTable(); ReadGposTable(); isVertical = false; }
public bool ContainsKey(string key) { string dataKey = Attributes.DataKey(key); return(!String.IsNullOrEmpty(key) && enclosingAttributes.ContainsKey(dataKey)); }
/// <exception cref="System.IO.IOException"/> private void InitializeFontProperties() { // initialize sfnt tables OpenTypeParser.HeaderTable head = fontParser.GetHeadTable(); OpenTypeParser.HorizontalHeader hhea = fontParser.GetHheaTable(); OpenTypeParser.WindowsMetrics os_2 = fontParser.GetOs_2Table(); OpenTypeParser.PostTable post = fontParser.GetPostTable(); isFontSpecific = fontParser.GetCmapTable().fontSpecific; kerning = fontParser.ReadKerning(head.unitsPerEm); bBoxes = fontParser.ReadBbox(head.unitsPerEm); // font names group fontNames.SetAllNames(fontParser.GetAllNameEntries()); fontNames.SetFontName(fontParser.GetPsFontName()); fontNames.SetFullName(fontNames.GetNames(4)); String[][] otfFamilyName = fontNames.GetNames(16); if (otfFamilyName != null) { fontNames.SetFamilyName(otfFamilyName); } else { fontNames.SetFamilyName(fontNames.GetNames(1)); } String[][] subfamily = fontNames.GetNames(2); if (subfamily != null) { fontNames.SetStyle(subfamily[0][3]); } String[][] otfSubFamily = fontNames.GetNames(17); if (otfFamilyName != null) { fontNames.SetSubfamily(otfSubFamily); } else { fontNames.SetSubfamily(subfamily); } String[][] cidName = fontNames.GetNames(20); if (cidName != null) { fontNames.SetCidFontName(cidName[0][3]); } fontNames.SetWeight(os_2.usWeightClass); fontNames.SetWidth(os_2.usWidthClass); fontNames.SetMacStyle(head.macStyle); fontNames.SetAllowEmbedding(os_2.fsType != 2); // font metrics group fontMetrics.SetUnitsPerEm(head.unitsPerEm); fontMetrics.UpdateBbox(head.xMin, head.yMin, head.xMax, head.yMax); fontMetrics.SetMaxGlyphId(fontParser.ReadMaxGlyphId()); fontMetrics.SetGlyphWidths(fontParser.GetGlyphWidthsByIndex()); fontMetrics.SetTypoAscender(os_2.sTypoAscender); fontMetrics.SetTypoDescender(os_2.sTypoDescender); fontMetrics.SetCapHeight(os_2.sCapHeight); fontMetrics.SetXHeight(os_2.sxHeight); fontMetrics.SetItalicAngle(post.italicAngle); fontMetrics.SetAscender(hhea.Ascender); fontMetrics.SetDescender(hhea.Descender); fontMetrics.SetLineGap(hhea.LineGap); fontMetrics.SetWinAscender(os_2.usWinAscent); fontMetrics.SetWinDescender(os_2.usWinDescent); fontMetrics.SetAdvanceWidthMax(hhea.advanceWidthMax); fontMetrics.SetUnderlinePosition((post.underlinePosition - post.underlineThickness) / 2); fontMetrics.SetUnderlineThickness(post.underlineThickness); fontMetrics.SetStrikeoutPosition(os_2.yStrikeoutPosition); fontMetrics.SetStrikeoutSize(os_2.yStrikeoutSize); fontMetrics.SetSubscriptOffset(-os_2.ySubscriptYOffset); fontMetrics.SetSubscriptSize(os_2.ySubscriptYSize); fontMetrics.SetSuperscriptOffset(os_2.ySuperscriptYOffset); fontMetrics.SetSuperscriptSize(os_2.ySuperscriptYSize); fontMetrics.SetIsFixedPitch(post.isFixedPitch); // font identification group String[][] ttfVersion = fontNames.GetNames(5); if (ttfVersion != null) { fontIdentification.SetTtfVersion(ttfVersion[0][3]); } String[][] ttfUniqueId = fontNames.GetNames(3); if (ttfUniqueId != null) { fontIdentification.SetTtfVersion(ttfUniqueId[0][3]); } fontIdentification.SetPanose(os_2.panose); IDictionary <int, int[]> cmap = GetActiveCmap(); int[] glyphWidths = fontParser.GetGlyphWidthsByIndex(); unicodeToGlyph = new LinkedDictionary <int, Glyph>(cmap.Count); codeToGlyph = new LinkedDictionary <int, Glyph>(glyphWidths.Length); avgWidth = 0; foreach (int charCode in cmap.Keys) { int index = cmap.Get(charCode)[0]; if (index >= glyphWidths.Length) { ILogger LOGGER = LoggerFactory.GetLogger(typeof(iText.IO.Font.TrueTypeFont)); LOGGER.Warn(String.Format(LogMessageConstant.FONT_HAS_INVALID_GLYPH, GetFontNames().GetFontName(), index)); continue; } Glyph glyph = new Glyph(index, glyphWidths[index], charCode, bBoxes != null ? bBoxes[index] : null); unicodeToGlyph[charCode] = glyph; codeToGlyph[index] = glyph; avgWidth += glyph.GetWidth(); } FixSpaceIssue(); for (int index_1 = 0; index_1 < glyphWidths.Length; index_1++) { if (codeToGlyph.ContainsKey(index_1)) { continue; } Glyph glyph = new Glyph(index_1, glyphWidths[index_1], -1); codeToGlyph[index_1] = glyph; avgWidth += glyph.GetWidth(); } if (codeToGlyph.Count != 0) { avgWidth /= codeToGlyph.Count; } ReadGdefTable(); ReadGsubTable(); ReadGposTable(); isVertical = false; }
public static void LinkedDictionaryTest() { LinkedDictionary <string, int> ldEmpty = new LinkedDictionary <string, int>(); LinkedDictionary <string, int> a = new LinkedDictionary <string, int>(); a.Add("a1", 1); a.Add("a12", 12); a.Add("a123", 123); a.Add("a4", 4); a.Add("a5", 5); #region Pseudo-LINQ-Extensions Assert.AreEqual("a1", a.First().Key); Assert.AreEqual(1, a.First().Value); Assert.AreEqual("a5", a.Last().Key); Assert.AreEqual(5, a.Last().Value); Assert.Throws <InvalidOperationException>(() => ldEmpty.First()); Assert.Throws <InvalidOperationException>(() => ldEmpty.Last()); Assert.DoesNotThrow(() => ldEmpty.FirstOrDefault()); Assert.DoesNotThrow(() => ldEmpty.LastOrDefault()); Assert.AreEqual(default(KeyValuePair <string, int>), ldEmpty.FirstOrDefault()); Assert.AreEqual(default(KeyValuePair <string, int>), ldEmpty.LastOrDefault()); Assert.DoesNotThrow(() => ldEmpty.Reverse()); List <KeyValuePair <string, int> > reversed = new List <KeyValuePair <string, int> >(a.Reverse()); Assert.AreEqual(a.Count, reversed.Count); Assert.AreEqual("a5", reversed[0].Key); Assert.AreEqual(5, reversed[0].Value); Assert.AreEqual("a4", reversed[1].Key); Assert.AreEqual(4, reversed[1].Value); Assert.AreEqual("a123", reversed[2].Key); Assert.AreEqual(123, reversed[2].Value); Assert.AreEqual("a12", reversed[3].Key); Assert.AreEqual(12, reversed[3].Value); Assert.AreEqual("a1", reversed[4].Key); Assert.AreEqual(1, reversed[4].Value); #endregion Assert.AreEqual(5, a.Count); Assert.IsTrue(a.ContainsKey("a4")); Assert.IsTrue(a.ContainsKey("a123")); Assert.IsTrue(a.Remove("a123")); Assert.IsFalse(a.Remove("a123")); Assert.IsFalse(a.ContainsKey("a123")); Assert.AreEqual(4, a.Count); List <string> keys = new List <string>(a.Keys); List <int> values = new List <int>(a.Values); List <KeyValuePair <string, int> > kv = new List <KeyValuePair <string, int> >(a); Assert.AreEqual("a1", keys[0]); Assert.AreEqual("a12", keys[1]); Assert.AreEqual("a4", keys[2]); Assert.AreEqual("a5", keys[3]); Assert.AreEqual(1, values[0]); Assert.AreEqual(12, values[1]); Assert.AreEqual(4, values[2]); Assert.AreEqual(5, values[3]); Assert.AreEqual("a1", kv[0].Key); Assert.AreEqual("a12", kv[1].Key); Assert.AreEqual("a4", kv[2].Key); Assert.AreEqual("a5", kv[3].Key); Assert.AreEqual(1, kv[0].Value); Assert.AreEqual(12, kv[1].Value); Assert.AreEqual(4, kv[2].Value); Assert.AreEqual(5, kv[3].Value); a.Clear(); Assert.AreEqual(0, a.Count); }
private void FillFields(AcroFields acroFields) { var fields = new LinkedDictionary <string, AcroFields.Item>(); typeof(AcroFields).GetField("fields", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(acroFields, fields); PdfDictionary top = (PdfDictionary)GetPdfObjectRelease(Catalog.Get(PdfName.ACROFORM)); if (top == null) { return; } PdfArray arrfds = (PdfArray)GetPdfObjectRelease(top.Get(PdfName.FIELDS)); if (arrfds == null || arrfds.Size == 0) { return; } for (int k = 1; k <= NumberOfPages; ++k) { PdfDictionary page = GetPageNRelease(k); PdfArray annots = (PdfArray)GetPdfObjectRelease(page.Get(PdfName.ANNOTS), page); if (annots == null) { continue; } for (int j = 0; j < annots.Size; ++j) { PdfDictionary annot = annots.GetAsDict(j); if (annot == null) { ReleaseLastXrefPartial(annots.GetAsIndirectObject(j)); continue; } if (!PdfName.WIDGET.Equals(annot.GetAsName(PdfName.SUBTYPE))) { ReleaseLastXrefPartial(annots.GetAsIndirectObject(j)); continue; } PdfDictionary widget = annot; PdfDictionary dic = new PdfDictionary(); dic.Merge(annot); string name = string.Empty; PdfDictionary value = null; PdfObject lastV = null; while (annot != null) { dic.Merge(annot); PdfString t = annot.GetAsString(PdfName.T); if (t != null) { name = t.ToUnicodeString() + "." + name; } if (lastV == null && annot.Get(PdfName.V) != null) { lastV = GetPdfObjectRelease(annot.Get(PdfName.V)); } if (value == null && t != null) { value = annot; if (annot.Get(PdfName.V) == null && lastV != null) { value.Put(PdfName.V, lastV); } } annot = annot.GetAsDict(PdfName.PARENT); } if (name.Length > 0) { name = name.Substring(0, name.Length - 1); } AcroFields.Item item; if (!fields.TryGetValue(name, out item)) { item = new AcroFields.Item(); fields[name] = item; } var addValueMethod = item.GetType().GetMethod("AddValue", BindingFlags.Instance | BindingFlags.NonPublic); if (value == null) { addValueMethod.Invoke(item, new object[] { widget }); } else { addValueMethod.Invoke(item, new object[] { value }); } item.GetType().GetMethod("AddWidget", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(item, new object[] { widget }); item.GetType().GetMethod("AddWidgetRef", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(item, new object[] { annots.GetAsIndirectObject(j) }); // must be a reference if (top != null) { dic.MergeDifferent(top); } item.GetType().GetMethod("AddMerged", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(item, new object[] { dic }); item.GetType().GetMethod("AddPage", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(item, new object[] { k }); item.GetType().GetMethod("AddTabOrder", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(item, new object[] { j }); } } // some tools produce invisible signatures without an entry in the page annotation array // look for a single level annotation PdfNumber sigFlags = top.GetAsNumber(PdfName.SIGFLAGS); if (sigFlags == null || (sigFlags.IntValue & 1) != 1) { return; } for (int j = 0; j < arrfds.Size; ++j) { PdfDictionary annot = arrfds.GetAsDict(j); if (annot == null) { ReleaseLastXrefPartial(arrfds.GetAsIndirectObject(j)); continue; } if (!PdfName.WIDGET.Equals(annot.GetAsName(PdfName.SUBTYPE))) { ReleaseLastXrefPartial(arrfds.GetAsIndirectObject(j)); continue; } PdfArray kids = (PdfArray)GetPdfObjectRelease(annot.Get(PdfName.KIDS)); if (kids != null) { continue; } PdfDictionary dic = new PdfDictionary(); dic.Merge(annot); PdfString t = annot.GetAsString(PdfName.T); if (t == null) { continue; } string name = t.ToUnicodeString(); if (fields.ContainsKey(name)) { continue; } var item = new AcroFields.Item(); fields[name] = item; item.GetType().GetMethod("AddValue", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(item, new object[] { dic }); item.GetType().GetMethod("AddWidget", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(item, new object[] { dic }); item.GetType().GetMethod("AddWidgetRef", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(item, new object[] { arrfds.GetAsIndirectObject(j) }); // must be a reference item.GetType().GetMethod("AddMerged", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(item, new object[] { dic }); item.GetType().GetMethod("AddPage", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(item, new object[] { -1 }); item.GetType().GetMethod("AddTabOrder", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(item, new object[] { -1 }); } }
public bool HasCached(string userId) { return(_cache.ContainsKey(userId)); }