Exemplo n.º 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());
 }
Exemplo n.º 2
0
        public static string[] Replace(string[] arrayToSearch, string pattern, string replacement)
        {
            if (arrayToSearch == null || arrayToSearch.Length == 0)
            {
                return(arrayToSearch);
            }
            List <string> list = new List <string>();

            foreach (string val in arrayToSearch)
            {
                string text = AnalysisHelpers.Replace(val, pattern, replacement);
                if (text != null)
                {
                    list.Add(text);
                }
            }
            return(list.ToArray());
        }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
        public static int SdGet(byte[] sd)
        {
            int      result              = 0;
            GCHandle gchandle            = GCHandle.Alloc(sd, GCHandleType.Pinned);
            IntPtr   pSecurityDescriptor = gchandle.AddrOfPinnedObject();

            try
            {
                ValidationConstant.SecurityDescriptorControl securityDescriptorControl;
                int num;
                AnalysisHelpers.GetSecurityDescriptorControl(pSecurityDescriptor, out securityDescriptorControl, out num);
                result = (int)securityDescriptorControl;
            }
            finally
            {
                gchandle.Free();
            }
            return(result);
        }
Exemplo n.º 5
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);
        }