/// <summary> /// アクセス権チェック /// </summary> /// <param name="regKey"></param> private void CheckAccess(RegistryKey regKey) { string tempAccess = new RegistrySummary(regKey, false, true).Access; if (Access == string.Empty) { retValue = string.IsNullOrEmpty(tempAccess); if (!retValue) { Console.Error.WriteLine("指定のアクセス権無し: \"{0}\" / \"{1}\"", Access, tempAccess); } } else if (TestMode == Item.CONTAIN) { // Accessパラメータで指定したAccess文字列が、対象のレジストリキーに含まれているかチェック // Access文字列は複数の場合は、全て対象のレジストリキーに含まれているかをチェック //string tempAccess = new RegistrySummary(regKey, false, true).Access; string[] tempAccessArray = tempAccess.Split('/'); foreach (string accessString in Access.Split('/')) { retValue = tempAccessArray.Any(x => RegistryControl.IsMatchAccess(x, accessString)); if (!retValue) { Console.Error.WriteLine("指定のアクセス権無し: {0} / {1}", Access, tempAccess); break; } } } else { List <string> accessListA = new List <string>(); accessListA.AddRange(tempAccess.Split('/')); List <string> accessListB = new List <string>(); accessListB.AddRange(Access.Split('/')); if (accessListA.Count == accessListB.Count) { for (int i = accessListA.Count - 1; i >= 0; i--) { string matchString = accessListB.FirstOrDefault(x => RegistryControl.IsMatchAccess(x, accessListA[i])); if (matchString != null) { accessListB.Remove(matchString); } } retValue = accessListB.Count == 0; } else { retValue = false; } if (!retValue) { Console.Error.WriteLine("アクセス権不一致: {0} / {1}", Access, tempAccess); } } }