Пример #1
0
 public static string ConvertToStringSid(object val)
 {
     if (AnalysisHelpers.IsNullOrEmpty(val))
     {
         return(string.Empty);
     }
     if (val.GetType() == typeof(byte[]))
     {
         return(AnalysisHelpers.ConvertToStringSid((byte[])val));
     }
     return(val.ToString());
 }
Пример #2
0
 public static bool Match(string pattern, params string[] strings)
 {
     if (string.IsNullOrEmpty(pattern))
     {
         throw new ArgumentException("Argument 'pattern' should not be null or empty.");
     }
     if (!AnalysisHelpers.IsNullOrEmpty(strings))
     {
         foreach (string text in strings)
         {
             if (!string.IsNullOrEmpty(text) && Regex.IsMatch(text, pattern, AnalysisHelpers.matchOptions))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #3
0
        public static string ConvertBinaryToString(object val)
        {
            string text = string.Empty;

            if (AnalysisHelpers.IsNullOrEmpty(val))
            {
                return(text);
            }
            Type          type          = val.GetType();
            StringBuilder stringBuilder = new StringBuilder();

            if (type == typeof(string))
            {
                val  = ((string)val).ToCharArray();
                text = string.Empty;
                foreach (char c in (char[])val)
                {
                    string str = text;
                    int    num = (int)c;
                    text = str + num.ToString("X4");
                }
            }
            else
            {
                if (!(type == typeof(byte[])))
                {
                    throw new ArgumentException("val must be of type string or byte[].");
                }
                stringBuilder.Capacity = 2 * ((byte[])val).Length + 1;
                foreach (byte b in (byte[])val)
                {
                    stringBuilder.Append(b.ToString("X2"));
                }
                text = stringBuilder.ToString();
            }
            return(text);
        }