Example #1
0
        public Profiler(WriteDelegate Output) {
            InitializeProperties();

            this.Output += Output;

            Start();
        }
Example #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param deviceType="nm"></param>
 /// <returns></returns>
 public static TransItem Create(NameMap nm, FromDBI fromDBI, ToDBI toDBI, WriteDelegate writeDelegate)
 {
     TransItem item = new TransItem(writeDelegate);
     item.FromDevice = CreateFromDevice(nm.FromName, fromDBI);
     item.ToDevice = CreateToDevice(nm.ToName, toDBI, nm.Elvation, writeDelegate);
     return item;
 }
Example #3
0
        public static void Initialize()
        {
            if (Initialized)
                return;

            Core.Log(LogSeverity.Minor, "initializing stream hooks..");
            _memStreamReadOff = Utility.FindPattern("blue",
                                                    "55 8b ec 56 8b 75 0c 57 8b f9 85 f6 78 ? 8b 47 18 8d 0c 30 3b 4f 10 76 ? 8b 47 18 8b 77 10");
            _memStreamWriteOff = Utility.FindPattern("blue",
                                                     "55 8b ec 53 8b 5d 0c 56 8b f1 57 8b 7e 18 03 fb 3b 7e 10 76 ? 56 8b c7 e8 ? ? ? ? 84 c0 75 ? 5f 5e");
            if (_memStreamReadOff != 0 && _memStreamWriteOff != 0)
            {
                Core.Log(LogSeverity.Minor,
                         "stream functions: Read: 0x" + (_memStreamReadOff - BlueOS.Library.ToInt64()).ToString("X") +
                         " Write: 0x" + (_memStreamWriteOff - BlueOS.Library.ToInt64()).ToString("X"));

                _memStreamReadOrig = Utility.Magic.RegisterDelegate<ReadDelegate>(_memStreamReadOff);
                _memStreamWriteOrig = Utility.Magic.RegisterDelegate<WriteDelegate>(_memStreamWriteOff);
                _memStreamReadFake = HandleRead;
                _memStreamWriteFake = HandleWrite;
                _memStreamReadDetour = Utility.Magic.Detours.Create(_memStreamReadOrig, _memStreamReadFake,
                                                                            "MemStream::Read");
                _memStreamWriteDetour = Utility.Magic.Detours.Create(_memStreamWriteOrig, _memStreamWriteFake,
                                                                             "MemStream::Write");
                Core.Log(LogSeverity.Minor, "stream functions hooked");
            }
            else
                Core.Log(LogSeverity.Minor, "pattern failed to find Read/Write stream functions");

            Initialized = true;
        }
Example #4
0
        public override IAsyncResult BeginWrite(byte [] array, int offset, int numBytes,
                                                AsyncCallback userCallback, object stateObject)
        {
            if (handle == MonoIO.InvalidHandle)
            {
                throw new ObjectDisposedException("Stream has been closed");
            }

            if (!CanWrite)
            {
                throw new NotSupportedException("This stream does not support writing");
            }

            if (array == null)
            {
                throw new ArgumentNullException("array");
            }

            if (numBytes < 0)
            {
                throw new ArgumentOutOfRangeException("numBytes", "Must be >= 0");
            }

            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", "Must be >= 0");
            }

            // reordered to avoid possible integer overflow
            if (numBytes > array.Length - offset)
            {
                throw new ArgumentException("array too small. numBytes/offset wrong.");
            }

            if (!async)
            {
                return(base.BeginWrite(array, offset, numBytes, userCallback, stateObject));
            }

            FileStreamAsyncResult result = new FileStreamAsyncResult(userCallback, stateObject);

            result.BytesRead     = -1;
            result.Count         = numBytes;
            result.OriginalCount = numBytes;

            if (buf_dirty)
            {
                MemoryStream ms = new MemoryStream();
                FlushBuffer(ms);
                ms.Write(array, offset, numBytes);
                offset   = 0;
                numBytes = (int)ms.Length;
            }

            WriteDelegate w = new WriteDelegate(WriteInternal);

            return(w.BeginInvoke(array, offset, numBytes, userCallback, stateObject));
        }
Example #5
0
        private bool RewriteZonesBuffered(
            BinaryWriter w,
            WriteDelegate write,
            ICollection <Zone> zones,
            TagData dataToWrite,
            bool tagExists)
        {
            bool result = true;

            // Load the 'interesting' part of the file in memory
            // TODO - detect and fine-tune cases when block at the extreme ends of the file are considered (e.g. SPC)
            long chunkBeginOffset = getFirstRecordedOffset(zones);
            long chunkEndOffset   = getLastRecordedOffset(zones);

            if (embedder != null && implementedTagType == MetaDataIOFactory.TAG_ID3V2)
            {
                chunkBeginOffset = Math.Min(chunkBeginOffset, embedder.Id3v2Zone.Offset);
                chunkEndOffset   = Math.Max(chunkEndOffset, embedder.Id3v2Zone.Offset + embedder.Id3v2Zone.Size);
            }

            long initialChunkLength = chunkEndOffset - chunkBeginOffset;


            w.BaseStream.Seek(chunkBeginOffset, SeekOrigin.Begin);

            using (MemoryStream chunk = new MemoryStream((int)initialChunkLength))
            {
                StreamUtils.CopyStream(w.BaseStream, chunk, (int)initialChunkLength);
                using (BinaryWriter msw = new BinaryWriter(chunk, Settings.DefaultTextEncoding))
                {
                    result = RewriteZonesDirect(msw, write, zones, dataToWrite, tagExists, chunkBeginOffset, true);

                    // -- Adjust file slot to new size of chunk --
                    long tagBeginOffset = chunkBeginOffset;
                    long tagEndOffset   = tagBeginOffset + initialChunkLength;

                    // Need to build a larger file
                    if (chunk.Length > initialChunkLength)
                    {
                        Logging.LogDelegator.GetLogDelegate()(Logging.Log.LV_DEBUG, "Disk stream operation : Lengthening (delta=" + (chunk.Length - initialChunkLength) + ")");
                        StreamUtils.LengthenStream(w.BaseStream, tagEndOffset, (uint)(chunk.Length - initialChunkLength));
                    }
                    else if (chunk.Length < initialChunkLength) // Need to reduce file size
                    {
                        Logging.LogDelegator.GetLogDelegate()(Logging.Log.LV_DEBUG, "Disk stream operation : Shortening (delta=" + (chunk.Length - initialChunkLength) + ")");
                        StreamUtils.ShortenStream(w.BaseStream, tagEndOffset, (uint)(initialChunkLength - chunk.Length));
                    }

                    // Copy tag contents to the new slot
                    w.BaseStream.Seek(tagBeginOffset, SeekOrigin.Begin);
                    chunk.Seek(0, SeekOrigin.Begin);

                    StreamUtils.CopyStream(chunk, w.BaseStream);
                }
            }

            return(result);
        }
Example #6
0
 /// <summary>
 /// costruttore
 /// </summary>
 /// <param name="_w"></param>
 /// <param name="verbose"></param>
 public PMed1(WriteDelegate _w, bool verbose = true)
     : base(_w, verbose)
 {
     MaxReSetSolution   = _MaxReSetSolution;
     MaxZeroRandomCount = _MaxZeroRandomCount;
     Seed     = -1;
     solution = uint.MaxValue;
     ReinitRandom();
 }
Example #7
0
        static void Main(string[] args)
        {
            //Log log = new Log();
            //WriteDelegate writeDelegate = new WriteDelegate(log.Write);
            WriteDelegate writeDelegate = new WriteDelegate(Log.Write);

            writeDelegate("Hello World!");
            Console.ReadLine();
        }
Example #8
0
 /// <summary>
 /// 释放由 System.IO.Stream 占用的非托管资源,还可以另外再释放托管资源。
 /// </summary>
 /// <param name="disposing">为 true,则释放托管资源和非托管资源;为 false,则仅释放非托管资源。</param>
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         _writeAction = null;
         _flushAction = null;
     }
 }
Example #9
0
        private static void InvokeOnWrite(string message, ConsoleColor col)
        {
            WriteDelegate Delegate = OnWrite;

            if (Delegate != null)
            {
                Delegate(message, col);
            }
        }
Example #10
0
        private static void EndWrite(IAsyncResult ar)
        {
            HidAsyncState hidAsyncState = (HidAsyncState)ar.AsyncState;
            WriteDelegate writeDelegate = (WriteDelegate)hidAsyncState.CallerDelegate;
            WriteCallback writeCallback = (WriteCallback)hidAsyncState.CallbackDelegate;
            bool          success       = writeDelegate.EndInvoke(ar);

            writeCallback?.Invoke(success);
        }
Example #11
0
        public LoupeLogProvider()
        {
            if (!IsLoggerAvailable())
            {
                throw new InvalidOperationException("Gibraltar.Agent.Log (Loupe) not found");
            }

            _logWriteDelegate = GetLogWriteDelegate();
        }
Example #12
0
        private static void InvokeOnWrite(string message, LogType col)
        {
            WriteDelegate @delegate = OnWrite;

            if (@delegate != null)
            {
                @delegate(message, col);
            }
        }
Example #13
0
        public override IAsyncResult BeginWrite(byte [] buffer, int offset, int count,
                                                AsyncCallback cback, object state)
        {
            //if (handle == MonoIO.InvalidHandle)
            //    throw new ObjectDisposedException ("Stream has been closed");

            if (!CanWrite)
            {
                throw new NotSupportedException("This stream does not support writing");
            }

            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", "Must be >= 0");
            }

            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", "Must be >= 0");
            }

            // reordered to avoid possible integer overflow
            if (count > buffer.Length - offset)
            {
                throw new ArgumentException("Buffer too small. count/offset wrong.");
            }

            if (!async)
            {
                return(base.BeginWrite(buffer, offset, count, cback, state));
            }

            FileStreamAsyncResult result = new FileStreamAsyncResult(cback, state);

            result.BytesRead     = -1;
            result.Count         = count;
            result.OriginalCount = count;

            if (buf_dirty)
            {
                MemoryStream ms = new MemoryStream();
                FlushBufferToStream(ms);
                ms.Write(buffer, offset, count);
                offset = 0;
                count  = (int)ms.Length;
            }

            WriteDelegate w = new WriteDelegate(WriteInternal);

            return(w.BeginInvoke(buffer, offset, count, cback, state));
        }
Example #14
0
            internal LoupeLogger(string category, WriteDelegate logWriteDelegate)
            {
                _category         = category;
                _logWriteDelegate = logWriteDelegate;
#if DEBUG
                _skipLevel = 2;
#else
                _skipLevel = 1;
#endif
            }
Example #15
0
        public async Task <bool> WriteAsync(byte[] data, int timeout = 0)
        {
            var writeDelegate = new WriteDelegate(Write);

#if NET20 || NET35
            return(await Task <bool> .Factory.StartNew(() => writeDelegate.Invoke(data, timeout)));
#else
            return(await Task <bool> .Factory.FromAsync(writeDelegate.BeginInvoke, writeDelegate.EndInvoke, data, timeout, null));
#endif
        }
Example #16
0
            internal LoupeLogger(string category, WriteDelegate logWriteDelegate)
            {
                this.category         = category;
                this.logWriteDelegate = logWriteDelegate;
#if DEBUG
                skipLevel = 2;
#else
                skipLevel = 1;
#endif
            }
Example #17
0
        private static void OutputResult(CalculationOutput result)
        {
            WriteDelegate write = System.Console.WriteLine;

            write("The order result is:");
            write($"Order Id: {result.OrderId}");
            write($"Order speedy discount: {result.Discounts}");
            write($"Order Speedy Charge: {result.SpeedyCost}");
            write($"Total cost: {result.Total}");
        }
 private static ParquetHandle Create(
     WriteDelegate write,
     TellDelegate tell,
     FlushDelegate flush,
     CloseDelegate close,
     ClosedDelegate closed)
 {
     ExceptionInfo.Check(ManagedOutputStream_Create(write, tell, flush, close, closed, out var handle));
     return(new ParquetHandle(handle, OutputStream_Free));
 }
Example #19
0
 /// <summary>
 /// Costruttore. throws a DDLNotFoundException if neither CoinOp or CPLEX was founnd.
 /// </summary>
 /// <param name="_w">WriteDelegate</param>
 /// <param name="_problem_name"> nome problema</param>
 /// <param name="N">number of solutions</param>
 /// <param name="verbose">verbose results</param>
 /// <param name="CPLEX">use CPLEX? else CoinOP</param>
 /// <param name="pt">SetCovering or SetPartitioning?</param>
 public PMed3(WriteDelegate _w, uint N, string _problem_name = "PMedProb", bool verbose = false, bool CPLEX = false, eProblemType pt = eProblemType.SetCovering)
     : base(_w, N, verbose)
 {
     fase3         = new Stopwatch();
     MaxIterSecond = 0.0;
     CurDir        = Directory.GetCurrentDirectory();
     InitDLL(_problem_name, CPLEX);
     ProblemType         = pt;
     WrapperVerboseLevel = Wrapper.CoinLogLevel.JustFactorizationsAndMore;
 }
        /// <summary>
        ///   Add a ZipEntry for which content is written directly by the application.
        /// </summary>
        ///
        /// <remarks>
        /// <para>
        ///   When the application needs to write the zip entry data, use this
        ///   method to add the ZipEntry. For example, in the case that the
        ///   application wishes to write the XML representation of a DataSet into
        ///   a ZipEntry, the application can use this method to do so.
        /// </para>
        ///
        /// <para>
        ///   For <c>ZipFile</c> properties including <see cref="Encryption"/>, <see
        ///   cref="Password"/>, <see cref="SetCompression"/>, <see
        ///   cref="ProvisionalAlternateEncoding"/>, <see cref="ExtractExistingFile"/>,
        ///   <see cref="ZipErrorAction"/>, and <see cref="CompressionLevel"/>, their
        ///   respective values at the time of this call will be applied to the
        ///   <c>ZipEntry</c> added.
        /// </para>
        ///
        /// <para>
        ///   About progress events: When using the WriteDelegate, DotNetZip does
        ///   not issue any SaveProgress events with <c>EventType</c> = <see
        ///   cref="ZipProgressEventType.Saving_EntryBytesRead">
        ///   Saving_EntryBytesRead</see>. (This is because it is the
        ///   application's code that runs in WriteDelegate - there's no way for
        ///   DotNetZip to know when to issue a EntryBytesRead event.)
        ///   Applications that want to update a progress bar or similar status
        ///   indicator should do so from within the WriteDelegate
        ///   itself. DotNetZip will issue the other SaveProgress events,
        ///   including <see cref="ZipProgressEventType.Saving_Started">
        ///   Saving_Started</see>,
        ///   <see cref="ZipProgressEventType.Saving_BeforeWriteEntry">
        ///   Saving_BeforeWriteEntry</see>, and <see
        ///   cref="ZipProgressEventType.Saving_AfterWriteEntry">
        ///   Saving_AfterWriteEntry</see>.
        /// </para>
        ///
        /// <para>
        ///   Note: When you use PKZip encryption, it's normally necessary to
        ///   compute the CRC of the content to be encrypted, before compressing or
        ///   encrypting it. Therefore, when using PKZip encryption with a
        ///   WriteDelegate, the WriteDelegate CAN BE called twice: once to compute
        ///   the CRC, and the second time to potentially compress and
        ///   encrypt. Surprising, but true. This is because PKWARE specified that
        ///   the encryption initialization data depends on the CRC.
        ///   If this happens, for each call of the delegate, your
        ///   application must stream the same entry data in its entirety. If your
        ///   application writes different data during the second call, it will
        ///   result in a corrupt zip file.
        /// </para>
        ///
        /// <para>
        ///   The double-read behavior happens with all types of entries, not only
        ///   those that use WriteDelegate. It happens if you add an entry from a
        ///   filesystem file, or using a string, or a stream, or an opener/closer
        ///   pair. But in those cases, DotNetZip takes care of reading twice; in
        ///   the case of the WriteDelegate, the application code gets invoked
        ///   twice. Be aware.
        /// </para>
        ///
        /// <para>
        ///   As you can imagine, this can cause performance problems for large
        ///   streams, and it can lead to correctness problems when you use a
        ///   <c>WriteDelegate</c>. This is a pretty big pitfall.  There are two
        ///   ways to avoid it.  First, and most preferred: don't use PKZIP
        ///   encryption.  If you use the WinZip AES encryption, this problem
        ///   doesn't occur, because the encryption protocol doesn't require the CRC
        ///   up front. Second: if you do choose to use PKZIP encryption, write out
        ///   to a non-seekable stream (like standard output, or the
        ///   Response.OutputStream in an ASP.NET application).  In this case,
        ///   DotNetZip will use an alternative encryption protocol that does not
        ///   rely on the CRC of the content.  This also implies setting bit 3 in
        ///   the zip entry, which still presents problems for some zip tools.
        /// </para>
        ///
        /// <para>
        ///   In the future I may modify DotNetZip to *always* use bit 3 when PKZIP
        ///   encryption is in use.  This seems like a win overall, but there will
        ///   be some work involved.  If you feel strongly about it, visit the
        ///   DotNetZip forums and vote up <see
        ///   href="http://dotnetzip.codeplex.com/workitem/13686">the Workitem
        ///   tracking this issue</see>.
        /// </para>
        ///
        /// </remarks>
        ///
        /// <param name="entryName">the name of the entry to add</param>
        /// <param name="writer">the delegate which will write the entry content</param>
        /// <returns>the ZipEntry added</returns>
        ///
        /// <example>
        ///
        ///   This example shows an application filling a DataSet, then saving the
        ///   contents of that DataSet as XML, into a ZipEntry in a ZipFile, using an
        ///   anonymous delegate in C#. The DataSet XML is never saved to a disk file.
        ///
        /// <code lang="C#">
        /// var c1= new System.Data.SqlClient.SqlConnection(connstring1);
        /// var da = new System.Data.SqlClient.SqlDataAdapter()
        ///     {
        ///         SelectCommand=  new System.Data.SqlClient.SqlCommand(strSelect, c1)
        ///     };
        ///
        /// DataSet ds1 = new DataSet();
        /// da.Fill(ds1, "Invoices");
        ///
        /// using(Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
        /// {
        ///     zip.AddEntry(zipEntryName, (name,stream) => ds1.WriteXml(stream) );
        ///     zip.Save(zipFileName);
        /// }
        /// </code>
        /// </example>
        ///
        /// <example>
        ///
        /// This example uses an anonymous method in C# as the WriteDelegate to provide
        /// the data for the ZipEntry. The example is a bit contrived - the
        /// <c>AddFile()</c> method is a simpler way to insert the contents of a file
        /// into an entry in a zip file. On the other hand, if there is some sort of
        /// processing or transformation of the file contents required before writing,
        /// the application could use the <c>WriteDelegate</c> to do it, in this way.
        ///
        /// <code lang="C#">
        /// using (var input = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite ))
        /// {
        ///     using(Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
        ///     {
        ///         zip.AddEntry(zipEntryName, (name,output) =>
        ///             {
        ///                 byte[] buffer = new byte[BufferSize];
        ///                 int n;
        ///                 while ((n = input.Read(buffer, 0, buffer.Length)) != 0)
        ///                 {
        ///                     // could transform the data here...
        ///                     output.Write(buffer, 0, n);
        ///                     // could update a progress bar here
        ///                 }
        ///             });
        ///
        ///         zip.Save(zipFileName);
        ///     }
        /// }
        /// </code>
        /// </example>
        ///
        /// <example>
        ///
        /// This example uses a named delegate in VB to write data for the given
        /// ZipEntry (VB9 does not have anonymous delegates). The example here is a bit
        /// contrived - a simpler way to add the contents of a file to a ZipEntry is to
        /// simply use the appropriate <c>AddFile()</c> method.  The key scenario for
        /// which the <c>WriteDelegate</c> makes sense is saving a DataSet, in XML
        /// format, to the zip file. The DataSet can write XML to a stream, and the
        /// WriteDelegate is the perfect place to write into the zip file.  There may be
        /// other data structures that can write to a stream, but cannot be read as a
        /// stream.  The <c>WriteDelegate</c> would be appropriate for those cases as
        /// well.
        ///
        /// <code lang="VB">
        /// Private Sub WriteEntry (ByVal name As String, ByVal output As Stream)
        ///     Using input As FileStream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
        ///         Dim n As Integer = -1
        ///         Dim buffer As Byte() = New Byte(BufferSize){}
        ///         Do While n &lt;&gt; 0
        ///             n = input.Read(buffer, 0, buffer.Length)
        ///             output.Write(buffer, 0, n)
        ///         Loop
        ///     End Using
        /// End Sub
        ///
        /// Public Sub Run()
        ///     Using zip = New ZipFile
        ///         zip.AddEntry(zipEntryName, New WriteDelegate(AddressOf WriteEntry))
        ///         zip.Save(zipFileName)
        ///     End Using
        /// End Sub
        /// </code>
        /// </example>
        public ZipEntry AddEntry(string entryName, WriteDelegate writer)
        {
            ZipEntry ze = ZipEntry.CreateForWriter(entryName, writer);

            if (Verbose)
            {
                StatusMessageTextWriter.WriteLine("adding {0}...", entryName);
            }
            return(_InternalAddEntry(ze));
        }
Example #21
0
        public GifskiInterop()
        {
            #region Get Gifski version

            var info = new FileInfo(UserSettings.All.GifskiLocation);
            info.Refresh();

            switch (info.Length)
            {
            case 502_720:
                Version = new Version(0, 10, 2);
                break;

            case 502_208:
                Version = new Version(0, 9, 3);
                break;

            default:
                Version = new Version(0, 0);
                break;
            }

            #endregion

            #region Load functions

            _new         = (NewDelegate)FunctionLoader.LoadFunction <NewDelegate>(UserSettings.All.GifskiLocation, "gifski_new");
            _addPngFrame = (AddPngFrameDelegate)FunctionLoader.LoadFunction <AddPngFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_png_file");
            //_addRgbaFrame = (AddRgbaFrameDelegate)FunctionLoader.LoadFunction<AddRgbaFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_rgba");

            if (Version.Major == 0 && Version.Minor < 10)
            {
                _addRgbFrame = (AddRgbFrameDelegate)FunctionLoader.LoadFunction <AddRgbFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_rgb");
            }
            else
            {
                _addRgb2Frame = (AddRgb2FrameDelegate)FunctionLoader.LoadFunction <AddRgb2FrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_rgb");
            }

            if (Version.Major == 0 && Version.Minor < 9)
            {
                //Older versions of the library.
                _endAddingFrames = (EndAddingFramesDelegate)FunctionLoader.LoadFunction <EndAddingFramesDelegate>(UserSettings.All.GifskiLocation, "gifski_end_adding_frames");
                _write           = (WriteDelegate)FunctionLoader.LoadFunction <WriteDelegate>(UserSettings.All.GifskiLocation, "gifski_write");
                _drop            = (DropDelegate)FunctionLoader.LoadFunction <DropDelegate>(UserSettings.All.GifskiLocation, "gifski_drop");
            }
            else
            {
                //Newer versions.
                _setFileOutput = (SetFileOutputDelegate)FunctionLoader.LoadFunction <SetFileOutputDelegate>(UserSettings.All.GifskiLocation, "gifski_set_file_output");
                _finish        = (FinishDelegate)FunctionLoader.LoadFunction <FinishDelegate>(UserSettings.All.GifskiLocation, "gifski_finish");
            }

            #endregion
        }
 static CallbackHandler()
 {
     readCallback    = new ReadDelegate(read);
     writeCallback   = new WriteDelegate(write);
     skipCallback    = new SkipDelegate(skip);
     seekCallback    = new SeekDelegate(seek);
     tellCallback    = new TellDelegate(tell);
     eofCallback     = new EofDelegate(eof);
     closeCallback   = new CloseDelegate(close);
     deletedCallback = new DeletedDelegate(deleted);
 }
Example #23
0
 /// <summary>
 /// 
 /// </summary>
 /// <param deviceType="p"></param>
 /// <returns></returns>
 private static ToDevice CreateToDevice(string name, ToDBI toDBI, float elvation, WriteDelegate writeDelegate)
 {
     ToDevice to = new ToDevice(writeDelegate);
     to.DBI = toDBI;
     to.Name = name;
     to.ID = toDBI.ReadToDeviceID(name);
     // TODO:
     //
     //to.ComAdr = toDBI.ReadToDeviceComAdr(to.ID);
     to.Elvation = elvation;
     return to;
 }
Example #24
0
        private void Deserialize(Stream Wire)
        {
            BinaryReader BR = new BinaryReader(Wire);

            Type = (DelegateTypes)BR.ReadByte();
            switch (Type)
            {
            case DelegateTypes.WRITESCREEN: Write = new WriteDelegate(WriteScreen); break;

            default: Write = new WriteDelegate(WriteFile); break;
            }
        }
Example #25
0
        private void HandleWriteEvent(string message)
        {
            if (InvokeRequired)
            {
                WriteDelegate delFunction = new WriteDelegate(HandleWriteEvent);
                Invoke(delFunction, new object[] { message });
                return;
            }

            //this.AppendText(message);
            this.Text += message;
        }
Example #26
0
        public void WriteDataTable(DataTable arg)
        {
#if !DISABLE_DATATABLE
            int numCols = arg.Columns.Count;
            int numRows = arg.Rows.Count;

            VariantBase.EnumType[] colTypes = new VariantBase.EnumType[numCols];
            string[] colNames = new string[numCols];

            for (int i = 0; i < numCols; ++i)
            {
                DataColumn col = arg.Columns[i];
                colTypes[i] = VariantPrimitiveBase.TypeToEnum(col.DataType);
                colNames[i] = col.ColumnName;
            }

            // Write number of columns
            WriteInt(numCols);

            // Write number of rows
            WriteInt(numRows);

            // Write column types
            foreach (VariantBase.EnumType colType in colTypes)
            {
                WriteInt((int)colType);
            }

            // Write column names
            foreach (string colName in colNames)
            {
                WriteString(colName);
            }

            // Write columns
            for (int i = 0; i < numCols; ++i)
            {
                WriteDelegate colWriter = GetWriterDelegate(colTypes[i]);

                foreach (DataRow item in arg.Rows)
                {
                    if (item.IsNull(i))
                    {
                        throw new VariantException("Cannot serialise DataTables containing null elements.");
                    }
                    colWriter(item[i]);
                }
            }
#else
            throw new NotSupportedException("Datatables are not supported on this platform.");
#endif
        }
Example #27
0
        public void Write(string text, string additionalInformation, OutputTypes outputTypes)
        {
            if (table.InvokeRequired)
            {
                WriteDelegate write = new WriteDelegate(Write);
                table.Invoke(write, text, additionalInformation, outputTypes);
            }
            else
            {
                Bitmap icon      = new Bitmap(1, 1);
                Color  foreColor = Color.Black;
                if (outputTypes == OutputTypes.Information)
                {
                    icon      = Resources.information16;
                    foreColor = Color.Black;
                }
                if (outputTypes == OutputTypes.Warning)
                {
                    icon      = Resources.warning16;
                    foreColor = Color.Orange;
                }
                if (outputTypes == OutputTypes.Error)
                {
                    icon      = Resources.error16;
                    foreColor = Color.Red;
                }
                if (outputTypes == OutputTypes.Debug)
                {
                    icon      = Resources.data16;
                    foreColor = Color.Green;
                }
                if (table.TableModel.Rows.Count > historyLength)
                {
                    table.TableModel.Rows.RemoveAt(0);
                }

                Cell cellIcon = new Cell("", icon);
                cellIcon.Editable = false;

                Cell cellTimeStamp = new Cell(DateTime.Now.ToLongTimeString());
                cellTimeStamp.Editable  = false;
                cellTimeStamp.ForeColor = foreColor;

                Cell cellText = new Cell(text);
                cellText.Editable  = false;
                cellText.ForeColor = foreColor;
                cellText.Tag       = additionalInformation;

                table.TableModel.Rows.Add(new Row(new Cell[] { cellIcon, cellTimeStamp, cellText }));
                table.EnsureVisible(table.TableModel.Rows.Count - 1, 0);
            }
        }
Example #28
0
 private void Write(string text)
 {
     if (txtResults.InvokeRequired)
     {
         WriteDelegate d = new WriteDelegate(Write);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         txtResults.AppendText(text + "\r\n");
         ActivityLogger.WriteLog(text);
     }
 }
Example #29
0
        protected override bool OnPreService()
        {
            Response.ContentType = "application/json";

            _streamWriter = new StreamWriter(Response.OutputStream);

            Write = x => {
                var str = String.Join(",", x);
                _streamWriter.WriteLine(str);
            };

            return(true);
        }
Example #30
0
 private void WriteCallback(IAsyncResult ar)
 {
     try
     {
         AsyncResult   result = (AsyncResult)ar;
         WriteDelegate caller = (WriteDelegate)result.AsyncDelegate;
         caller.EndInvoke(ar);
     }
     catch (Exception)
     {
         Close();
     }
 }
Example #31
0
        public static void Convert(IDelimitedTextReader csvReader, Stream xlsxStream)
        {
            WriteDelegate writeContetnt =
                (en, s) =>
            {
                GenerateWorksheetPartContent(csvReader, s);
            };

            using (Stream templateStream = PrepareTemplateStream())
            {
                Save(templateStream, writeContetnt, xlsxStream);
            }
        }
Example #32
0
 void Test(WriteDelegate writeProc, ReadDelegate readProc, byte[] expectedBytes)
 {
     byte[] raw;
     using (MemoryStream ms = new MemoryStream()) {
         MsgPackWriter writer = new MsgPackWriter(ms);
         writeProc(writer);
         raw = ms.ToArray();
     }
     Assert.AreEqual(expectedBytes, raw, "pack failed");
     using (MemoryStream ms = new MemoryStream(raw)) {
         MsgPackReader reader = new MsgPackReader(ms);
         readProc(reader);
     }
 }
Example #33
0
        public Logger(string vhost, string url, string name, string password, string channel)
        {
            mqSend = new MQHelper.RabbitMQHelper(url, vhost, name, password);
            mqSend.BindQueue(channel, 10, new string[] { channel });
            run             = true;
            sends           = new Queue <string>();
            otherSendThread = new Thread(new ThreadStart(OtherSendThread));
            write           = new WriteDelegate(LogWrite);
            System.Net.IPHostEntry IpEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());

            _ips = IpEntry.AddressList[0].ToString();

            otherSendThread.Start();
        }
Example #34
0
 public void WriteLine(String msg, params object[] args)
 {
     if (!String.IsNullOrEmpty(msg))
     {
         if (cDetails.InvokeRequired)
         {
             WriteDelegate d = new WriteDelegate(WriteLine);
             this.Invoke(d, msg, args);
         }
         else
         {
             cDetails.Text += String.Format(msg, args) + Environment.NewLine;
         }
     }
 }
Example #35
0
		public override IAsyncResult BeginWrite (byte [] buffer, int offset, int count,
							AsyncCallback cback, object state)
		{
			if (!CanWrite)
				throw new NotSupportedException ("This stream does not support writing");

			if (buffer == null)
				throw new ArgumentNullException ("buffer");

			if (count < 0)
				throw new ArgumentOutOfRangeException ("count", "Must be >= 0");

			if (offset < 0)
				throw new ArgumentOutOfRangeException ("offset", "Must be >= 0");

			WriteDelegate d = new WriteDelegate (this.Write);
			return d.BeginInvoke (buffer, offset, count, cback, state);
		}
 public virtual IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
 {
     if (!this.CanWrite)
     {
         __Error.WriteNotSupported();
     }
     Interlocked.Increment(ref this._asyncActiveCount);
     WriteDelegate delegate2 = new WriteDelegate(this.Write);
     if (this._asyncActiveEvent == null)
     {
         lock (this)
         {
             if (this._asyncActiveEvent == null)
             {
                 this._asyncActiveEvent = new AutoResetEvent(true);
             }
         }
     }
     this._asyncActiveEvent.WaitOne();
     this._writeDelegate = delegate2;
     return delegate2.BeginInvoke(buffer, offset, count, callback, state);
 }
Example #37
0
 public void UpdateStatusGateway(string msg)
 {
     WriteDelegate writer = new WriteDelegate(WriteStatusGateway);
     this.Invoke(writer, new object[] { msg });
 }
Example #38
0
		public override IAsyncResult BeginWrite (byte [] array, int offset, int numBytes,
							AsyncCallback userCallback, object stateObject)
		{
			if (handle == MonoIO.InvalidHandle)
				throw new ObjectDisposedException ("Stream has been closed");

			if (!CanWrite)
				throw new NotSupportedException ("This stream does not support writing");

			if (array == null)
				throw new ArgumentNullException ("array");

			if (numBytes < 0)
				throw new ArgumentOutOfRangeException ("numBytes", "Must be >= 0");

			if (offset < 0)
				throw new ArgumentOutOfRangeException ("offset", "Must be >= 0");

			// reordered to avoid possible integer overflow
			if (numBytes > array.Length - offset)
				throw new ArgumentException ("array too small. numBytes/offset wrong.");

			if (!async)
				return base.BeginWrite (array, offset, numBytes, userCallback, stateObject);

			FileStreamAsyncResult result = new FileStreamAsyncResult (userCallback, stateObject);
			result.BytesRead = -1;
			result.Count = numBytes;
			result.OriginalCount = numBytes;

			if (buf_dirty) {
				MemoryStream ms = new MemoryStream ();
				FlushBuffer (ms);
				ms.Write (array, offset, numBytes);
				offset = 0;
				numBytes = (int) ms.Length;
			}

			WriteDelegate w = new WriteDelegate (WriteInternal);
			return w.BeginInvoke (array, offset, numBytes, userCallback, stateObject);			
		}
Example #39
0
		protected void writeScriptPath(FileScriptResource script, AppScripts appScripts, WriteDelegate write)
		{
			string path = Debug ? script.DebugPath : script.MinPath;

			// Don't append scripts folder if path looks like:
			// http://... https://... //www.blah... /folder/blah...
			if (!(path.StartsWith("http") || path.StartsWith("/")))
				write(appScripts.ScriptsFolder);

			write(path);
		}
Example #40
0
	public SSLHelperStream(ReadDelegate Read, WriteDelegate Send)
	{
		ReadFromDevice = Read;
		SendToDevice = Send;
	}
Example #41
0
 public void UpdateNotify(string msg)
 {
     WriteDelegate writer = new WriteDelegate(WriteNotify);
     this.Invoke(writer, new object[] { msg });
 }
Example #42
0
 public Importer(WriteDelegate writeDelegate)
 {
     _writeDelegate = writeDelegate;
 }
        private void HandleWriteEvent(string message)
        {
            if (InvokeRequired)
            {
                WriteDelegate delFunction = new WriteDelegate(HandleWriteEvent);
                Invoke(delFunction, new object[] { message });
                return;
            }

            //this.AppendText(message);
            this.Text += message;
        }
Example #44
0
 void Test(WriteDelegate writeProc, ReadDelegate readProc, byte[] expectedBytes)
 {
     byte[] raw;
     using (MemoryStream ms = new MemoryStream ()) {
         MsgPackWriter writer = new MsgPackWriter (ms);
         writeProc (writer);
         raw = ms.ToArray ();
     }
     Assert.AreEqual (expectedBytes, raw, "pack failed");
     using (MemoryStream ms = new MemoryStream (raw)) {
         MsgPackReader reader = new MsgPackReader (ms);
         readProc (reader);
     }
 }
Example #45
0
 public TransItem(WriteDelegate writeDelegate)
 {
     _writeDelegate = writeDelegate;
 }
Example #46
0
 /// <summary>
 /// 
 /// </summary>
 /// <param deviceType="writeDelegate"></param>
 public ToDevice(WriteDelegate writeDelegate)
 {
     if (writeDelegate == null)
     {
         throw new ArgumentException("writeDelegate");
     }
     _writeDelegate = writeDelegate;
 }
 /// <summary>
 ///   Add a ZipEntry for which content is written directly by the application.
 /// </summary>
 ///
 /// <remarks>
 /// <para>
 ///   When the application needs to write the zip entry data, use this
 ///   method to add the ZipEntry. For example, in the case that the
 ///   application wishes to write the XML representation of a DataSet into
 ///   a ZipEntry, the application can use this method to do so.
 /// </para>
 ///
 /// <para>
 ///   For <c>ZipFile</c> properties including <see cref="Encryption"/>, <see
 ///   cref="Password"/>, <see cref="SetCompression"/>, <see
 ///   cref="ProvisionalAlternateEncoding"/>, <see cref="ExtractExistingFile"/>,
 ///   <see cref="ZipErrorAction"/>, and <see cref="CompressionLevel"/>, their
 ///   respective values at the time of this call will be applied to the
 ///   <c>ZipEntry</c> added.
 /// </para>
 ///
 /// <para>
 ///   About progress events: When using the WriteDelegate, DotNetZip does
 ///   not issue any SaveProgress events with <c>EventType</c> = <see
 ///   cref="ZipProgressEventType.Saving_EntryBytesRead">
 ///   Saving_EntryBytesRead</see>. (This is because it is the
 ///   application's code that runs in WriteDelegate - there's no way for
 ///   DotNetZip to know when to issue a EntryBytesRead event.)
 ///   Applications that want to update a progress bar or similar status
 ///   indicator should do so from within the WriteDelegate
 ///   itself. DotNetZip will issue the other SaveProgress events,
 ///   including <see cref="ZipProgressEventType.Saving_Started">
 ///   Saving_Started</see>,
 ///   <see cref="ZipProgressEventType.Saving_BeforeWriteEntry">
 ///   Saving_BeforeWriteEntry</see>, and <see
 ///   cref="ZipProgressEventType.Saving_AfterWriteEntry">
 ///   Saving_AfterWriteEntry</see>.
 /// </para>
 ///
 /// <para>
 ///   Note: When you use PKZip encryption, it's normally necessary to
 ///   compute the CRC of the content to be encrypted, before compressing or
 ///   encrypting it. Therefore, when using PKZip encryption with a
 ///   WriteDelegate, the WriteDelegate CAN BE called twice: once to compute
 ///   the CRC, and the second time to potentially compress and
 ///   encrypt. Surprising, but true. This is because PKWARE specified that
 ///   the encryption initialization data depends on the CRC.
 ///   If this happens, for each call of the delegate, your
 ///   application must stream the same entry data in its entirety. If your
 ///   application writes different data during the second call, it will
 ///   result in a corrupt zip file.
 /// </para>
 ///
 /// <para>
 ///   The double-read behavior happens with all types of entries, not only
 ///   those that use WriteDelegate. It happens if you add an entry from a
 ///   filesystem file, or using a string, or a stream, or an opener/closer
 ///   pair. But in those cases, DotNetZip takes care of reading twice; in
 ///   the case of the WriteDelegate, the application code gets invoked
 ///   twice. Be aware.
 /// </para>
 ///
 /// <para>
 ///   As you can imagine, this can cause performance problems for large
 ///   streams, and it can lead to correctness problems when you use a
 ///   <c>WriteDelegate</c>. This is a pretty big pitfall.  There are two
 ///   ways to avoid it.  First, and most preferred: don't use PKZIP
 ///   encryption.  If you use the WinZip AES encryption, this problem
 ///   doesn't occur, because the encryption protocol doesn't require the CRC
 ///   up front. Second: if you do choose to use PKZIP encryption, write out
 ///   to a non-seekable stream (like standard output, or the
 ///   Response.OutputStream in an ASP.NET application).  In this case,
 ///   DotNetZip will use an alternative encryption protocol that does not
 ///   rely on the CRC of the content.  This also implies setting bit 3 in
 ///   the zip entry, which still presents problems for some zip tools.
 /// </para>
 ///
 /// <para>
 ///   In the future I may modify DotNetZip to *always* use bit 3 when PKZIP
 ///   encryption is in use.  This seems like a win overall, but there will
 ///   be some work involved.  If you feel strongly about it, visit the
 ///   DotNetZip forums and vote up <see
 ///   href="http://dotnetzip.codeplex.com/workitem/13686">the Workitem
 ///   tracking this issue</see>.
 /// </para>
 ///
 /// </remarks>
 ///
 /// <param name="entryName">the name of the entry to add</param>
 /// <param name="writer">the delegate which will write the entry content</param>
 /// <returns>the ZipEntry added</returns>
 ///
 /// <example>
 ///
 ///   This example shows an application filling a DataSet, then saving the
 ///   contents of that DataSet as XML, into a ZipEntry in a ZipFile, using an
 ///   anonymous delegate in C#. The DataSet XML is never saved to a disk file.
 ///
 /// <code lang="C#">
 /// var c1= new System.Data.SqlClient.SqlConnection(connstring1);
 /// var da = new System.Data.SqlClient.SqlDataAdapter()
 ///     {
 ///         SelectCommand=  new System.Data.SqlClient.SqlCommand(strSelect, c1)
 ///     };
 ///
 /// DataSet ds1 = new DataSet();
 /// da.Fill(ds1, "Invoices");
 ///
 /// using(Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
 /// {
 ///     zip.AddEntry(zipEntryName, (name,stream) => ds1.WriteXml(stream) );
 ///     zip.Save(zipFileName);
 /// }
 /// </code>
 /// </example>
 ///
 /// <example>
 ///
 /// This example uses an anonymous method in C# as the WriteDelegate to provide
 /// the data for the ZipEntry. The example is a bit contrived - the
 /// <c>AddFile()</c> method is a simpler way to insert the contents of a file
 /// into an entry in a zip file. On the other hand, if there is some sort of
 /// processing or transformation of the file contents required before writing,
 /// the application could use the <c>WriteDelegate</c> to do it, in this way.
 ///
 /// <code lang="C#">
 /// using (var input = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite ))
 /// {
 ///     using(Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
 ///     {
 ///         zip.AddEntry(zipEntryName, (name,output) =>
 ///             {
 ///                 byte[] buffer = new byte[BufferSize];
 ///                 int n;
 ///                 while ((n = input.Read(buffer, 0, buffer.Length)) != 0)
 ///                 {
 ///                     // could transform the data here...
 ///                     output.Write(buffer, 0, n);
 ///                     // could update a progress bar here
 ///                 }
 ///             });
 ///
 ///         zip.Save(zipFileName);
 ///     }
 /// }
 /// </code>
 /// </example>
 ///
 /// <example>
 ///
 /// This example uses a named delegate in VB to write data for the given
 /// ZipEntry (VB9 does not have anonymous delegates). The example here is a bit
 /// contrived - a simpler way to add the contents of a file to a ZipEntry is to
 /// simply use the appropriate <c>AddFile()</c> method.  The key scenario for
 /// which the <c>WriteDelegate</c> makes sense is saving a DataSet, in XML
 /// format, to the zip file. The DataSet can write XML to a stream, and the
 /// WriteDelegate is the perfect place to write into the zip file.  There may be
 /// other data structures that can write to a stream, but cannot be read as a
 /// stream.  The <c>WriteDelegate</c> would be appropriate for those cases as
 /// well.
 ///
 /// <code lang="VB">
 /// Private Sub WriteEntry (ByVal name As String, ByVal output As Stream)
 ///     Using input As FileStream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
 ///         Dim n As Integer = -1
 ///         Dim buffer As Byte() = New Byte(BufferSize){}
 ///         Do While n &lt;&gt; 0
 ///             n = input.Read(buffer, 0, buffer.Length)
 ///             output.Write(buffer, 0, n)
 ///         Loop
 ///     End Using
 /// End Sub
 ///
 /// Public Sub Run()
 ///     Using zip = New ZipFile
 ///         zip.AddEntry(zipEntryName, New WriteDelegate(AddressOf WriteEntry))
 ///         zip.Save(zipFileName)
 ///     End Using
 /// End Sub
 /// </code>
 /// </example>
 public ZipEntry AddEntry(string entryName, WriteDelegate writer)
 {
     ZipEntry ze = ZipEntry.CreateForWriter(entryName, writer);
     if (Verbose) StatusMessageTextWriter.WriteLine("adding {0}...", entryName);
     return _InternalAddEntry(ze);
 }
Example #48
0
        public virtual void EndWrite(IAsyncResult asyncResult)
        {
            if (asyncResult==null)
                throw new ArgumentNullException("asyncResult");

            // Ideally we want to throw InvalidOperationException but for ECMA conformance we need to throw ArgExc instead.
            if (_writeDelegate == null)  
                throw new ArgumentException(Environment.GetResourceString("InvalidOperation_WrongAsyncResultOrEndWriteCalledMultiple"));

            try {
                _writeDelegate.EndInvoke(asyncResult);
            }
            finally {
                _writeDelegate = null;
                _asyncActiveEvent.Set();
                
                // Decrement the count to account for this async operation
                // and close the handle if no other IO is pending
                _CloseAsyncActiveEvent(Interlocked.Decrement(ref _asyncActiveCount));
            }
        }
 /// <summary>
 ///   Updates the given entry in the <c>ZipFile</c>, using the given delegate
 ///   as the source for content for the <c>ZipEntry</c>.
 /// </summary>
 ///
 /// <remarks>
 ///   Calling this method is equivalent to removing the <c>ZipEntry</c> for the
 ///   given file name and directory path, if it exists, and then calling <see
 ///   cref="AddEntry(String,WriteDelegate)" />.  See the
 ///   documentation for that method for further explanation.
 /// </remarks>
 ///
 /// <param name="entryName">
 ///   The name, including any path, to use within the archive for the entry.
 /// </param>
 ///
 /// <param name="writer">the delegate which will write the entry content.</param>
 ///
 /// <returns>The <c>ZipEntry</c> added.</returns>
 ///
 public ZipEntry UpdateEntry(string entryName, WriteDelegate writer)
 {
     RemoveEntryForUpdate(entryName);
     return AddEntry(entryName, writer);
 }
Example #50
0
 public async Task<bool> WriteAsync(byte[] data, int timeout = 0)
 {
     var writeDelegate = new WriteDelegate(Write);
     return await Task<bool>.Factory.FromAsync(writeDelegate.BeginInvoke, writeDelegate.EndInvoke, data, timeout, null);
 }
Example #51
0
 public void UpdateCharName(string name)
 {
     WriteDelegate writer = new WriteDelegate(WriteCharName);
     this.Invoke(writer, new object[] { name });
 }
Example #52
0
        public virtual IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, Object state)
        {
            if (!CanWrite) __Error.WriteNotSupported();

            // Increment the count to account for this async operation
            BCLDebug.Assert(_asyncActiveCount >= 1, "ref counting mismatch, possible race in the code");
            Interlocked.Increment(ref _asyncActiveCount);
            
            WriteDelegate d = new WriteDelegate(Write);

            // To avoid a race with a stream's position pointer & generating race 
            // conditions with internal buffer indexes in our own streams that 
            // don't natively support async IO operations when there are multiple 
            // async requests outstanding, we will block the application's main
            // thread if it does a second IO request until the first one completes.
            //Monitor.Enter(this);
            if (_asyncActiveEvent == null) {
                lock(this) {
                    if (_asyncActiveEvent == null)
                        _asyncActiveEvent = new AutoResetEvent(true);
                }
            }
            bool r = _asyncActiveEvent.WaitOne();
            BCLDebug.Assert(r, "AutoResetEvent didn't get a signal when we called WaitOne!");

            BCLDebug.Assert(_readDelegate == null && _writeDelegate == null, "Expected no other readers or writers!");

            // Set delegate before we call BeginInvoke, to avoid a race
            _writeDelegate = d;
            IAsyncResult asyncResult = d.BeginInvoke(buffer, offset, count, callback, state);
            return asyncResult;
        }
Example #53
0
        public void Write(WriteDelegate funct)
        {
            var sb = new StringBuilder ();

            for (var currentRow = 0; currentRow < _rows; currentRow++) {
                for (var currentColumn = 0; currentColumn < _numberOfCols; currentColumn++) {

                    sb.AppendFormat ("0x{0:X4} ", currentRow * _cols + BaseMemoryAddress + bytesPerColumn * currentColumn);

                    sb.Append (IBM3151.Commands.Intense);
                    for (var columnIndex = 0; columnIndex < _cols; columnIndex++)
                        sb.Append (this[currentRow * _cols + columnIndex + bytesPerColumn * currentColumn]);
                    sb.Append (IBM3151.Commands.NotIntense);
                    sb.Append ("   ");
                }

                if (currentRow != _rows - 1)
                    sb.Append ("\r\n");
            }

            funct (sb.ToString ());
        }
        public override void Write(object data, HIDDevice.WriteCallback callback,int timeout)
        {
            if (!IsConnected) return;
            if (IsOpen == false) OpenDevice();

            var writeDelegate = new WriteDelegate(Write);
            var asyncState = new HidAsyncState(writeDelegate, callback);
            writeDelegate.BeginInvoke((byte[])data,timeout, EndWrite, asyncState);

        }
 public virtual void EndWrite(IAsyncResult asyncResult)
 {
     if (asyncResult == null)
     {
         throw new ArgumentNullException("asyncResult");
     }
     if (this._writeDelegate == null)
     {
         throw new ArgumentException(Environment.GetResourceString("InvalidOperation_WrongAsyncResultOrEndWriteCalledMultiple"));
     }
     try
     {
         this._writeDelegate.EndInvoke(asyncResult);
     }
     finally
     {
         this._writeDelegate = null;
         this._asyncActiveEvent.Set();
         this._CloseAsyncActiveEvent(Interlocked.Decrement(ref this._asyncActiveCount));
     }
 }
Example #56
0
 // Changes the output textbox. It'd be cool to allow for multiple output sources, so this would
 // need to be expanded
 public void SetOutput(TextBox tb)
 {
     this.target = tb;
     this.consoleOnly = false;
     this.writerDelegate = new WriteDelegate(this.WriteDelegated);
 }
Example #57
0
 public void Write(byte[] data, WriteCallback callback)
 {
     var writeDelegate = new WriteDelegate(Write);
     var asyncState = new HidAsyncState(writeDelegate, callback);
     writeDelegate.BeginInvoke(data, EndWrite, asyncState);
 }
Example #58
0
 public Client(WriteDelegate logDelegate, WriteDelegate listDelegate)
 {
     DSTMLib.Init();
     _logDelegate = logDelegate;
     _listDelegate = listDelegate;
 }
 internal static ZipEntry CreateForWriter(String entryName, WriteDelegate d)
 {
     return Create(entryName, ZipEntrySource.WriteDelegate, d, null);
 }
Example #60
0
 public void WriteLine(String msg, params object[] args)
 {
     if (!String.IsNullOrEmpty(msg))
     {
         if (cDetails.InvokeRequired)
         {
             WriteDelegate d = new WriteDelegate(WriteLine);
             this.Invoke(d, msg, args);
         }
         else
         {
             cDetails.Text += String.Format(msg, args) + Environment.NewLine;
         }
     }
 }