24 namespace Lucene.Net.Support
28 delegate
void SetLevelDelegate(
int level);
29 delegate
void SetInputDelegate(byte[] input,
int offset,
int count);
30 delegate
void FinishDelegate();
31 delegate
bool GetIsFinishedDelegate();
32 delegate
int DeflateDelegate(byte[] output);
34 SetLevelDelegate setLevelMethod;
35 SetInputDelegate setInputMethod;
36 FinishDelegate finishMethod;
37 GetIsFinishedDelegate getIsFinishedMethod;
38 DeflateDelegate deflateMethod;
40 public const int BEST_COMPRESSION = 9;
42 internal Deflater(
object deflaterInstance)
44 Type type = deflaterInstance.GetType();
46 setLevelMethod = (SetLevelDelegate)Delegate.CreateDelegate(
47 typeof(SetLevelDelegate),
49 type.GetMethod(
"SetLevel",
new Type[] { typeof(
int) }));
51 setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
52 typeof(SetInputDelegate),
54 type.GetMethod(
"SetInput",
new Type[] { typeof(byte[]), typeof(
int), typeof(
int) }));
56 finishMethod = (FinishDelegate)Delegate.CreateDelegate(
57 typeof(FinishDelegate),
59 type.GetMethod(
"Finish", Type.EmptyTypes));
61 getIsFinishedMethod = (GetIsFinishedDelegate)Delegate.CreateDelegate(
62 typeof(GetIsFinishedDelegate),
64 type.GetMethod(
"get_IsFinished", Type.EmptyTypes));
66 deflateMethod = (DeflateDelegate)Delegate.CreateDelegate(
67 typeof(DeflateDelegate),
69 type.GetMethod(
"Deflate",
new Type[] { typeof(byte[]) }));
72 public void SetLevel(
int level)
74 setLevelMethod(level);
77 public void SetInput(byte[] input,
int offset,
int count)
79 setInputMethod(input, offset, count);
87 public bool IsFinished
89 get {
return getIsFinishedMethod(); }
92 public int Deflate(byte[] output)
94 return deflateMethod(output);