Ejemplo n.º 1
0
        void CopyCurrentRuleToClipboard()
        {
            if (CurrentRule != null)
            {
                MemoryStream        ms = new System.IO.MemoryStream();
                CountedStreamWriter sw = new CountedStreamWriter(ms);
                CurrentRule.Write(sw);
                sw.Flush();
                ms.Position = 0;
                using (StreamReader reader = new StreamReader(ms, Encoding.ASCII))
                {
                    string contents = reader.ReadToEnd();
                    if (!String.IsNullOrEmpty(contents))
                    {
                        //Need to make sure corrupt rules don't get pasted.
                        System.Security.Cryptography.SHA256Managed c = new System.Security.Cryptography.SHA256Managed();
                        System.Text.UTF8Encoding e = new UTF8Encoding();
                        byte[] rep     = e.GetBytes(contents);
                        string hashstr = Convert.ToBase64String(c.ComputeHash(rep));

                        Clipboard.SetText(hashstr + "#" + contents);
                    }
                }
            }
        }
        public void Write(CountedStreamWriter inf)
        {
            foreach (IUTLFileBlockHandler h in FileBlocks)
            {
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                CountedStreamWriter    sw = new CountedStreamWriter(ms);
                h.Write(sw);
                sw.Flush();

                inf.WriteLine(h.BlockTypeID);
                inf.WriteLine(((int)sw.Count).ToString(System.Globalization.CultureInfo.InvariantCulture));

                ms.Position = 0;
                System.IO.StreamReader sr = new System.IO.StreamReader(ms);
                inf.Write(sr.ReadToEnd());
            }
        }
Ejemplo n.º 3
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (CurrentRule != null)
     {
         MemoryStream        ms = new System.IO.MemoryStream();
         CountedStreamWriter sw = new CountedStreamWriter(ms);
         CurrentRule.Write(sw);
         sw.Flush();
         ms.Position = 0;
         using (StreamReader reader = new StreamReader(ms, Encoding.ASCII))
         {
             string contents = reader.ReadToEnd();
             if (!String.IsNullOrEmpty(contents))
             {
                 Clipboard.SetText(contents);
             }
         }
     }
 }
Ejemplo n.º 4
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (CurrentRule != null)
     {
         MemoryStream ms = new System.IO.MemoryStream();
         CountedStreamWriter sw = new CountedStreamWriter(ms);
         CurrentRule.Write(sw);
         sw.Flush();
         ms.Position = 0;
         using (StreamReader reader = new StreamReader(ms, Encoding.ASCII))
         {
             string contents = reader.ReadToEnd();
             if (!String.IsNullOrEmpty(contents))
             {
                 Clipboard.SetText(contents);
             }
         }
     }
 }
Ejemplo n.º 5
0
        public void Write(CountedStreamWriter inf)
        {
            foreach (IUTLFileBlockHandler h in FileBlocks)
            {
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                CountedStreamWriter sw = new CountedStreamWriter(ms);
                h.Write(sw);
                sw.Flush();

                inf.WriteLine(h.BlockTypeID);
                inf.WriteLine(((int)sw.Count).ToString(System.Globalization.CultureInfo.InvariantCulture));

                ms.Position = 0;
                System.IO.StreamReader sr = new System.IO.StreamReader(ms);
                inf.Write(sr.ReadToEnd());
            }
        }