Exemplo n.º 1
0
        internal Deflater(object deflaterInstance)
        {
            Type type = deflaterInstance.GetType();

            setLevelMethod = (SetLevelDelegate)Delegate.CreateDelegate(
                typeof(SetLevelDelegate),
                deflaterInstance,
                type.GetMethod("SetLevel", new Type[] { typeof(int) }));

            setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
                typeof(SetInputDelegate),
                deflaterInstance,
                type.GetMethod("SetInput", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));

            finishMethod = (FinishDelegate)Delegate.CreateDelegate(
                typeof(FinishDelegate),
                deflaterInstance,
                type.GetMethod("Finish", Type.EmptyTypes));

            getIsFinishedMethod = (GetIsFinishedDelegate)Delegate.CreateDelegate(
                typeof(GetIsFinishedDelegate),
                deflaterInstance,
                type.GetMethod("get_IsFinished", Type.EmptyTypes));

            deflateMethod = (DeflateDelegate)Delegate.CreateDelegate(
                typeof(DeflateDelegate),
                deflaterInstance,
                type.GetMethod("Deflate", new Type[] { typeof(byte[]) }));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Let the caller override our delegates with their own functions...
 /// </summary>
 /// <param name="a_closedelegate">use this to close the logging session</param>
 /// <param name="a_getleveldelegate">get the current log level</param>
 /// <param name="a_opendelegate">open the logging session</param>
 /// <param name="a_registertwaindelegate">not needed at this time</param>
 /// <param name="a_setflushdelegate">turn flushing on and off</param>
 /// <param name="a_setleveldelegate">set the new log level</param>
 /// <param name="a_writeentrydelegate">the function that actually writes to the log</param>
 /// <param name="a_getstatedelegate">returns a way to get the current TWAIN state</param>
 public static void Override
 (
     CloseDelegate a_closedelegate,
     GetLevelDelegate a_getleveldelegate,
     OpenDelegate a_opendelegate,
     RegisterTwainDelegate a_registertwaindelegate,
     SetFlushDelegate a_setflushdelegate,
     SetLevelDelegate a_setleveldelegate,
     WriteEntryDelegate a_writeentrydelegate,
     out GetStateDelegate a_getstatedelegate
 )
 {
     Close = (a_closedelegate != null) ? a_closedelegate : CloseLocal;
     GetLevel = (a_getleveldelegate != null) ? a_getleveldelegate : GetLevelLocal;
     Open = (a_opendelegate != null) ? a_opendelegate : OpenLocal;
     RegisterTwain = (a_registertwaindelegate != null) ? a_registertwaindelegate : RegisterTwainLocal;
     SetFlush = (a_setflushdelegate != null) ? a_setflushdelegate : SetFlushLocal;
     SetLevel = (a_setleveldelegate != null) ? a_setleveldelegate : SetLevelLocal;
     WriteEntry = (a_writeentrydelegate != null) ? a_writeentrydelegate : WriteEntryLocal;
     a_getstatedelegate = GetStateLocal;
 }