Files
Gary Sharp 5ea9a814d6 Pdf Import Rewrite
Pdf Import rewritten to greatly improve QR Code detection, reduce
reliance on iTextSharp and improve thumbnails. Fixes #50
2016-09-01 18:31:35 +10:00

57 lines
1.5 KiB
C#

using System;
using System.Collections;
namespace Disco.Models.Services.Documents
{
public class DocumentState : IDisposable
{
public int SequenceNumber { get; set; }
public Hashtable FieldCache { get; set; }
public Hashtable ScopeCache { get; set; }
public Hashtable DocumentCache { get; set; }
public DocumentState(int SequenceNumber)
{
this.SequenceNumber = SequenceNumber;
this.FieldCache = new Hashtable();
this.ScopeCache = new Hashtable();
this.DocumentCache = new Hashtable();
}
public void FlushFieldCache()
{
FlushDictionary(this.FieldCache);
}
public void FlushScopeCache()
{
FlushFieldCache();
FlushDictionary(this.ScopeCache);
}
public void FlushDocumentCache()
{
FlushScopeCache();
FlushDictionary(this.DocumentCache);
}
private static void FlushDictionary(Hashtable d)
{
foreach (var key in d.Keys)
{
var disposeItem = d[key] as IDisposable;
if (disposeItem != null)
disposeItem.Dispose();
}
d.Clear();
}
public static DocumentState DefaultState()
{
return new DocumentState(1);
}
public void Dispose()
{
FlushDocumentCache();
}
}
}