WriteBinHex() public method

public WriteBinHex ( byte buffer, int index, int count ) : void
buffer byte
index int
count int
return void
Example #1
0
 public override string ToString()
 {
     StringWriter sw = new StringWriter();
     XmlTextWriter tw = new XmlTextWriter(sw);
     tw.WriteBinHex(BinaryValue, 0, BinaryValue.Length);
     tw.Close();
     return sw.ToString();
 }
Example #2
0
        public static string ConvertToHexaDecimal(Byte[] stream)
        {
            System.Text.StringBuilder encryptedSB = new System.Text.StringBuilder();
            XmlTextWriter writer = new XmlTextWriter(new System.IO.StringWriter(encryptedSB));
            writer.WriteBinHex(stream, 0, stream.Length);
            writer.Close();

            return encryptedSB.ToString();
        }
Example #3
0
 /// <summary>
 /// This is implementd using a temporary XmlTextWriter to turn the 
 /// given binary blob into a string, then it calls WriteString with
 /// the result.
 /// </summary>
 public override void WriteBinHex(byte[] buffer, int index, int count)
 {
     StringWriter sw = new StringWriter();
     XmlTextWriter w = new XmlTextWriter(sw);
     w.WriteBinHex(buffer, index, count);
     w.Close();
     WriteString(sw.ToString());
 }
Example #4
0
		public void WriteBinHexAttribute () // for bug #79019
		{
			XmlWriter writer = new XmlTextWriter (TextWriter.Null);
			writer.WriteStartElement ("test");
			byte [] buffer1 = new byte [] {200, 155};
			writer.WriteStartAttribute ("key", "");
			writer.WriteBinHex (buffer1, 0, buffer1.Length);
			writer.WriteEndAttribute ();
			writer.WriteEndElement ();
		}
Example #5
0
        public static void SerializeIcon(System.Drawing.Icon icon, XmlElement xml)
        {
            if (icon == null)
                return;

            System.IO.MemoryStream mem = new System.IO.MemoryStream(1024);
            // TODO: Beta 2 issue with the ImageFormat. RawFormat on image object does not return the actual image format
            // Right now it is hard coded to PNG but in final version we should get the original image format
            icon.Save(mem);

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            System.IO.StringWriter sw = new System.IO.StringWriter(sb);

            System.Xml.XmlTextWriter xt = new System.Xml.XmlTextWriter(sw);

            xml.SetAttribute("encoding", "binhex");
            //xt.WriteBase64(mem.GetBuffer(),0,(int)mem.Length);
            xt.WriteBinHex(mem.GetBuffer(), 0, (int)mem.Length);

            xml.InnerText = sb.ToString();
        }
Example #6
0
 private void createXml(byte[] user, byte[] pass)
 {
     int i = 0  ; 
     string userstr = hex2str(user);
     string passstr = hex2str(pass); 
     if (File.Exists("hehe.xml"))
     {
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.Load("hehe.xml");
         XmlNode root = xmlDoc.SelectSingleNode("ALLUSER");
         // lookup the id 
         XmlNodeList nodeList=xmlDoc.SelectSingleNode("ALLUSER").ChildNodes;
         foreach (XmlNode xn in nodeList)
         {
             XmlElement xe = (XmlElement)xn;
             if(xe.GetAttribute("id") !="" )
             {
                 i++; 
             }
         }
         XmlElement xe1 = xmlDoc.CreateElement("USER");
         xe1.SetAttribute("id", i.ToString()) ;
         XmlElement xesub1 = xmlDoc.CreateElement("user");
         xesub1.InnerText =userstr;
         xe1.AppendChild(xesub1);
         
         XmlElement xesub2 = xmlDoc.CreateElement("pass");
         xesub2.InnerText = passstr;
         xe1.AppendChild(xesub2);
         
         root.AppendChild(xe1);
         xmlDoc.Save("hehe.xml");
     }
     else
     {   
         XmlTextWriter writer = new XmlTextWriter("hehe.xml", System.Text.Encoding.UTF8);
         writer.Formatting = Formatting.Indented;
         writer.WriteStartDocument();
         writer.WriteStartElement("ALLUSER");
         writer.WriteStartElement("USER");
         writer.WriteAttributeString("id", "0");
         writer.WriteStartElement("user");
         writer.WriteBinHex(user, 0, user.Length);
         writer.WriteEndElement();
         writer.WriteStartElement("pass");
         writer.WriteBinHex(pass, 0, pass.Length);
         writer.WriteEndElement();
         writer.Close(); 
     }
     
 }