コード例 #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 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());
        }
コード例 #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);
 }
コード例 #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);
        }
コード例 #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);
        }