Exemple #1
0
 /*public static string BitToBytes(string str1) {
  *  byte[] byte1 = Encoding.UTF8.GetBytes(str1);
  *  //string str2 = Encoding.UTF8.GetString(byte1);
  *  byte[] bstr2 = Convert.FromBase64String(str1);
  *  string str2 = Encoding.UTF8.GetString(bstr2);
  *  return str2;
  * }*/
 public static string BitToBytes(string s)
 {
     System.Text.RegularExpressions.CaptureCollection cs =
         System.Text.RegularExpressions.Regex.Match(s, @"([01]{8})+").Groups[1].Captures;
     byte[] data = new byte[cs.Count];
     for (int i = 0; i < cs.Count; i++)
     {
         data[i] = Convert.ToByte(cs[i].Value, 2);
     }
     //return Encoding.Unicode.GetString(data, 0, data.Length);
     return(Encoding.UTF8.GetString(data));
 }
        static StackObject *get_IsSynchronized_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Text.RegularExpressions.CaptureCollection instance_of_this_method = (System.Text.RegularExpressions.CaptureCollection) typeof(System.Text.RegularExpressions.CaptureCollection).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.IsSynchronized;

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
        static StackObject *GetEnumerator_6(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Text.RegularExpressions.CaptureCollection instance_of_this_method = (System.Text.RegularExpressions.CaptureCollection) typeof(System.Text.RegularExpressions.CaptureCollection).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.GetEnumerator();

            object obj_result_of_this_method = result_of_this_method;

            if (obj_result_of_this_method is CrossBindingAdaptorType)
            {
                return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance));
            }
            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
        static StackObject *CopyTo_5(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Int32 @index = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Array @array = (System.Array) typeof(System.Array).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Text.RegularExpressions.CaptureCollection instance_of_this_method = (System.Text.RegularExpressions.CaptureCollection) typeof(System.Text.RegularExpressions.CaptureCollection).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.CopyTo(@array, @index);

            return(__ret);
        }
        /// <summary>
        /// 二进制读取数据链接信息。
        /// </summary>
        /// <returns></returns>
        private string BinaryReadDBInfo()
        {
            FileStream   fs;
            BinaryReader bReader;
            string       content = string.Empty;

            if (!File.Exists(_filePath))
            {
                ExceptionMessage = "File is not exist";
            }
            else
            {
                try
                {
                    fs      = new FileStream(_filePath, FileMode.Open);
                    bReader = new BinaryReader(fs);
                    content = bReader.ReadString();
                    System.Text.RegularExpressions.CaptureCollection cs = System.Text.RegularExpressions.Regex.Match(content, @"([01]{8})+").Groups[1].Captures;
                    byte[] data = new byte[cs.Count];
                    for (int i = 0; i < cs.Count; i++)
                    {
                        data[i] = Convert.ToByte(cs[i].Value, 2);
                    }
                    content = System.Text.Encoding.ASCII.GetString(data, 0, data.Length);
                    bReader.Close();
                    fs.Close();
                }
                catch (Exception ex)
                {
                    ExceptionMessage = ex.Message;
                }
                finally
                {
                    bReader = null;
                    fs      = null;
                }
            }
            return(content);
        }