/// <summary> /// Gets all the node indices with matching names. /// </summary> private IEnumerable<int> FindNodes(string name, StringComparer comparer) { // find any node that matches var position = BinarySearch(name, comparer); if (position != -1) { // back up to the first node that matches. var start = position; while (start > 0 && comparer.Compare(nodes[start - 1].Name, name) == 0) { start--; } // yield the nodes we already know that match for (int i = start; i <= position; i++) { yield return i; } // also yield any following nodes that might also match for (int i = position + 1; i < nodes.Count; i++) { var node = nodes[i]; if (comparer.Compare(node.Name, name) == 0) { yield return i; } else { break; } } } }
public static string GetParam(this Application application, string name, StringComparer stringComparer) { stringComparer = stringComparer ?? StringComparer.CurrentCulture; return (from child in HtmlPage.Plugin.Children let nameAttribute = child.GetProperty("name") as string let valueAttribute = child.GetProperty("value") as string where stringComparer.Compare(name, nameAttribute) == 0 select valueAttribute as string).FirstOrDefault(); }
internal TypeDeobfuscator(XElement typeNode) { m_comparer = StringComparer.Ordinal; ObfuscatedName = ((string)typeNode.Element("newname")).Replace('/', '+'); OriginalName = ((string)typeNode.Element("name")).Replace('/', '+'); m_fields = (from fieldNode in typeNode.Elements("fieldlist").Elements("field") let originalName = (string)fieldNode.Element("name") let obfuscatedName = (string)fieldNode.Element("newname") select new ObfuscatedField(obfuscatedName, originalName)).ToArray(); Array.Sort(m_fields, (left, right) => m_comparer.Compare(left.ObfuscatedName, right.ObfuscatedName)); }
private static void VerifyComparer(StringComparer sc, bool ignoreCase) { String s1 = "Hello"; String s1a = "Hello"; String s1b = "HELLO"; String s2 = "There"; Assert.True(sc.Equals(s1, s1a)); Assert.True(sc.Equals(s1, s1a)); Assert.Equal(0, sc.Compare(s1, s1a)); Assert.Equal(0, ((IComparer)sc).Compare(s1, s1a)); Assert.True(sc.Equals(s1, s1)); Assert.True(((IEqualityComparer)sc).Equals(s1, s1)); Assert.Equal(0, sc.Compare(s1, s1)); Assert.Equal(0, ((IComparer)sc).Compare(s1, s1)); Assert.False(sc.Equals(s1, s2)); Assert.False(((IEqualityComparer)sc).Equals(s1, s2)); Assert.True(sc.Compare(s1, s2) < 0); Assert.True(((IComparer)sc).Compare(s1, s2) < 0); Assert.Equal(ignoreCase, sc.Equals(s1, s1b)); Assert.Equal(ignoreCase, ((IEqualityComparer)sc).Equals(s1, s1b)); int result = sc.Compare(s1, s1b); if (ignoreCase) Assert.Equal(0, result); else Assert.NotEqual(0, result); result = ((IComparer)sc).Compare(s1, s1b); if (ignoreCase) Assert.Equal(0, result); else Assert.NotEqual(0, result); }
public static ProjectItem FindItemByPath(this ProjectItems items, string itemFilePath, StringComparer comparer) { foreach (var item in items) { var projectItem = item as ProjectItem; if (projectItem != null) { if (projectItem.TryGetFullPath(out var filePath) && comparer.Compare(filePath, itemFilePath) == 0) { return projectItem; } } } return null; }
public static Boolean checkMd5Hash(this string input, string hash) { MD5 md5Hash = MD5.Create(); string hashOfInput = input.Hash(); StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } }
public bool VerifySHA256Hash(string input, string hash) { System.Security.Cryptography.SHA256 SHA256 = new System.Security.Cryptography.SHA256CryptoServiceProvider(); // Hash the input. string hashOfInput = GetSHA256Hash(input); // Create a StringComparer an compare the hashes. StringComparer comparer = StringComparer.CurrentCulture;//.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } }
/// <summary> /// Verifies that the usser's passed in password matches with the hashed password stored in the database /// </summary> /// <param name="md5"></param> /// <param name="userInput"></param> /// <param name="storedHash"></param> /// <returns></returns> private bool VerifyPassword(MD5 md5, string userInput, string storedHash) { // Get a hash of the user's submitted password string hashOfUserInput = HashPassword(md5, userInput); // StringComparer used two compare the two hashed passwords StringComparer comparer = StringComparer.OrdinalIgnoreCase; // If the two stored passwords are the same, return true. Otherwise, return false if (0 == comparer.Compare(hashOfUserInput, storedHash)) { return(true); } else { return(false); } }
public static bool VerifyMd5Hash(byte[] input, string hash) { lock (verifyLocker) { string hashOfInput = GetMd5Hash(input); StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } } }
/// <summary> /// Take input then hash and compare with already hash string before /// </summary> /// <param name="input">The input string need to compare</param> /// <param name="hash">The hashed one</param> /// <returns>true if equal</returns> public static bool VerifyMD5Hash(string input, string hash) { //Hash input string hashInput = GetMD5Hash(input); //Compare StringComparer cmp = StringComparer.Ordinal; //return 0 means equal if (cmp.Compare(hashInput, hash) == 0) { return(true); } else { return(false); } }
public int Compare(FileInfo x, FileInfo y) { // Create string comparer StringComparer sc = StringComparer.Create(CultureInfo.InvariantCulture, true); // Create flag to check if one of the file is a directory bool xDir = x.Attributes.HasFlag(FileAttributes.Directory); bool yDir = y.Attributes.HasFlag(FileAttributes.Directory); // String compare only if the fileinfo are of same type if ((xDir && yDir) || (!xDir && !yDir)) { return(sc.Compare(x.Name, y.Name)); } // If not directory become first return(xDir ? -1 : 1); }
private void ThrowIfTypeExist(string typeName, ICodeSource code) { if (TypeManager.IsKnownType(typeName) && _loadedModules.ContainsKey(typeName)) { using (MD5 md5Hash = MD5.Create()) { string moduleCode = code.Code; string hash = GetMd5Hash(md5Hash, moduleCode); string storedHash = _fileHashes[typeName]; StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (comparer.Compare(hash, storedHash) != 0) { throw new RuntimeException("Type «" + typeName + "» already registered"); } } } }
private bool VerifyMd5Hash(string input, string hash) { string hashOfInput = Compute(input); Console.WriteLine("z veryfiy hash"); Console.WriteLine(hashOfInput); Console.WriteLine(hash); StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } }
/// <summary> /// MD5验证 /// </summary> /// <param name="input"></param> /// <param name="hash"></param> /// <returns></returns> public static bool VerifyMd5Hash(string input, string hash) { string hashOfInput = MD5Hash(input); using (MD5 md5Hash = MD5.Create()) { StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } } }
// Verify a hash against a string. public static bool VerifyMd5Hash(string input, string hash) { // Hash the input. string hashOfInput = GetMd5Hash(input); // Create a StringComparer an compare the hashes. StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } }
// Verify a hash against a string. public static bool verifyMd5Hash(string hashOfInput) { // Hash the input. //string hashOfInput = getMd5Hash(input); // Create a StringComparer an compare the hashes. StringComparer comparer = StringComparer.OrdinalIgnoreCase; //use cpu id as hash if (0 == comparer.Compare(hashOfInput, getCpuIDhash())) { return(true); } else { return(false); } }
/// <summary> /// 支付成功回调结果验签 /// </summary> /// <param name="customernumber"></param> /// <param name="requestid"></param> /// <param name="code"></param> /// <param name="notifytype"></param> /// <param name="externalid"></param> /// <param name="amount"></param> /// <param name="cardno"></param> /// <param name="hmacKey"></param> /// <param name="VSign"></param> /// <returns></returns> public static bool PayResultVerifyHMAC(string customernumber, string requestid, int code, string notifytype, string externalid, string amount, string cardno, string hmacKey, string VSign) { string sign = "{0}{1}{2}{3}{4}{5}{6}"; sign = string.Format(sign, customernumber, requestid, code, notifytype, externalid, amount, cardno); sign = HmacSign(sign, hmacKey); StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(sign, VSign)) { return(true); } else { return(false); } }
/// <summary> /// 修改帐号密码 /// </summary> /// <param name="strOldPassword">原密码</param> /// <param name="strNewPassword">新密码</param> /// <param name="nOpStaffId">操作员工编码</param> /// <param name="strOpStaffName">操作员工姓名</param> /// <param name="strErrText">出错信息</param> /// <returns>成功返回True,否则返回False</returns> public bool UpdatePassword(string strOldPassword, string strNewPassword, long nOpStaffId, string strOpStaffName, out string strErrText) { try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (AuthenticateDAO dao = new AuthenticateDAO()) { //读取登录帐号数据 Account data = dao.LoadAccount(nOpStaffId, nOpStaffId, strOpStaffName, out strErrText); if (data == null) { return(false); } //生成登录密码MD5码 string strHash = Utils.GetMD5Hash(data.Name + "@" + strOldPassword); StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (comparer.Compare(strHash, data.Password) == 0) { data.Password = Utils.GetMD5Hash(data.Name + "@" + strNewPassword); if (!dao.UpdateAccount(data, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } } else { strErrText = InnoSoft.LS.Resources.Strings.OldPasswordIsIncorrect; return(false); } } transScope.Complete(); } strErrText = String.Empty; return(true); } catch (Exception e) { strErrText = e.Message; return(false); } }
static void Main(string[] args) { string s1 = "Strasse"; string s2 = "Straße"; bool eq; eq = string.Compare(s1, s2, StringComparison.Ordinal) == 0; Console.WriteLine("Ordinal comparission: {0} {2} {1}", s1, s2, eq ? "==" : "!="); CultureInfo ci = new CultureInfo("de-DE"); eq = string.Compare(s1, s2, true, ci) == 0; Console.WriteLine("Cultural comparison: {0} {2} {1}", s1, s2, eq ? "==" : "!="); Console.WriteLine(((IConvertible)10).ToDouble(null) + 0.3); StringComparer s = StringComparer.Create(ci, true); Console.WriteLine(s.Compare(10, 10)); }
/// <summary> /// Adds the specified cache index item. /// </summary> /// <param name="cacheIndexItem">The cache index item.</param> /// <param name="saveIndex">if set to <c>true</c> save the index to persietent storage.</param> public void Add(CacheIndexItem cacheIndexItem, bool saveIndex) { StringComparer comparer = CacheIndexMap.IgnoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal; lock (syncLock) { CacheIndexItem item1 = this.FirstOrDefault(item => comparer.Compare(item.RelativeUri, cacheIndexItem.RelativeUri) == 0); if (item1 != null) { base.Remove(item1); } base.Add(cacheIndexItem); if (saveIndex) { SerializeCacheIndex(this); } } }
public override int Compare(string x, string y) { int idxX = _priorityStrings.IndexOf(x); int idxY = _priorityStrings.IndexOf(y); if (idxX != -1 && idxY != -1) { return(idxX.CompareTo(idxY)); } if (idxX != -1) { return(idxX); } if (idxY != -1) { return(idxY); } return(_defaultStringComparer.Compare(x, y)); }
// Verify a hash against a string. static bool VerificarSenha(MD5 md5Hash, string senha, string hash) { string senhazeeng = "zeeng" + senha; // Hash the input. string hashOfInput = GetMd5Hash(md5Hash, senhazeeng); // Create a StringComparer an compare the hashes. StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } }
/* * Realiza a verificao de um hash em relacao a um texto para * saber o hash eh produto do texto passado. * @Return true caso o hash seja foi criado atraves do texto ou * fase caso contrario ou ocorra algum erro. */ public bool verifyMD5HashText(string hash, string text) { bool ret = false; try { text = getMD5Hash(text); StringComparer comp = StringComparer.OrdinalIgnoreCase; if (comp.Compare(hash, text) == 0) { ret = true; } } catch (Exception e) { ret = false; } return(ret); }
public static bool VerifyMd5Hash(this string input, string hash) { using (MD5 md5 = MD5.Create()) { string hashOfInput = GetMd5Hash(md5, input); // Create a StringComparer an compare the hashes. StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } } }
public bool VerifyHash(string text, string hash) { byte[] dataToHash = this.AES.GetBytes(EncryptContent(text)); byte[] HashOfInput = SHA_Hasher.ComputeHash(dataToHash); StringBuilder builder = new StringBuilder(); for (int i = 0; i < HashOfInput.Length; i++) { builder.Append(HashOfInput[i].ToString()); } string cleanedHash = builder.ToString(); StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (comparer.Compare(cleanedHash, hash) == 0) { return(true); } return(false); }
// Verify a hash against a string. public bool VerifyHash(string input, string hashPath) { // Hash the input. string hashOfInput = GetHash(input); var hash = File.ReadAllText(hashPath); // Create a StringComparer an compare the hashes. StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } }
public int Compare(TableIdentifier table1, TableIdentifier table2) { if (ReferenceEquals(table1, table2)) { return(0); } else if (table1 == null) { return(-1); } else if (table2 == null) { return(1); } else { return(stringComparer.Compare(table1.QualifiedName, table2.QualifiedName)); } }
/// <summary>See <see cref="Comparer{TModelElement}.Compare"/>.</summary> public sealed override int Compare(TModelElement x, TModelElement y) { if (x == y) { return(0); } else if (x == null) { return(-1); } else if (y == null) { return(1); } else { return(myStringComparer.Compare(DomainClassInfo.GetName(x), DomainClassInfo.GetName(y))); } }
public void Compare_ExpectedResults() { StringComparer c = StringComparer.Ordinal; Assert.Equal(0, c.Compare((object)"hello", (object)"hello")); #pragma warning disable 0618 // suppress obsolete warning for String.Copy Assert.Equal(0, c.Compare((object)"hello", (object)string.Copy("hello"))); #pragma warning restore 0618 // restore warning when accessing obsolete members Assert.Equal(-1, c.Compare(null, (object)"hello")); Assert.Equal(1, c.Compare((object)"hello", null)); Assert.InRange(c.Compare((object)"hello", (object)"world"), int.MinValue, -1); Assert.InRange(c.Compare((object)"world", (object)"hello"), 1, int.MaxValue); }
/// <summary> /// Gets or sets the <see cref="MimeKit.Parameter"/> at the specified index. /// </summary> /// <param name="index">The index.</param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="value"/> is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// The <paramref name="index"/> is out of range. /// </exception> /// <exception cref="System.ArgumentException"> /// A parameter with the same name as <paramref name="value"/> /// already exists. /// </exception> public Parameter this [int index] { get { return(parameters[index]); } set { if (index < 0 || index > Count) { throw new ArgumentOutOfRangeException("index"); } var param = parameters[index]; if (param == value) { return; } if (icase.Compare(param.Name, value.Name) == 0) { // replace the old param with the new one if (table[param.Name] == param) { table[param.Name] = value; } } else if (table.ContainsKey(value.Name)) { throw new ArgumentException("A parameter of that name already exists."); } else { table.Add(value.Name, value); table.Remove(param.Name); } param.Changed -= OnParamChanged; value.Changed += OnParamChanged; parameters[index] = value; OnChanged(); } }
public override int Compare(String x, String y) { int xIndex = 0; int yIndex = 0; x = (x ?? String.Empty); y = (y ?? String.Empty); while (xIndex < x.Length || yIndex < y.Length) { var xEntry = GetNextPart(x, xIndex); xIndex += xEntry.length; var yEntry = GetNextPart(y, yIndex); yIndex += xEntry.length; if (xEntry.value is double && yEntry.value is double) { var xNumber = (double)xEntry.value; var yNumber = (double)yEntry.value; var order = xNumber.CompareTo(yNumber); if (order != 0) { return(order); } } else { var xText = Convert.ToString(xEntry.value); var yText = Convert.ToString(yEntry.value); var order = _comparer.Compare(xText, yText); if (order != 0) { return(order); } } } return(0); }
public void StartPicDownload() { int cntTMP = curCount++; var post = posts.ToArray() [cntTMP]; string filePath = Path.Combine(outPath, ParseFilenameMask(textBoxNameMask.Text, Path.GetFileNameWithoutExtension(post ["file_url"].ToString()), post ["file_ext"].ToString(), cntTMP + (checkBoxStartOne.Checked ? 1 : 0))); if (File.Exists(filePath)) { using (var str = File.OpenRead(filePath)) { StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (comparer.Compare(GetMD5HashFromStream(str), post ["md5"].ToString()) == 0) { StartPicDownload(); return; } } } SetHeaders(picClient.Headers); picClient.DownloadFileAsync(new Uri(post ["file_url"].ToString()), Path.Combine(outPath, ParseFilenameMask(textBoxNameMask.Text, Path.GetFileNameWithoutExtension(post ["file_url"].ToString()), post ["file_ext"].ToString(), cntTMP + (checkBoxStartOne.Checked ? 1 : 0)))); }
/// <summary> /// Verify a hash against a string /// </summary> /// <param name="input">The input string</param> /// <param name="hash">The MD5 hash to use to verify the input string</param> /// <returns>True if the input string is verified</returns> public static bool VerifyMd5Hash(string input, string hash) { using (var md5 = System.Security.Cryptography.MD5.Create()) { // Hash the input. string hashOfInput = GetMd5Hash(input, md5); // Create a StringComparer an compare the hashes. StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } } }
private bool VerifyHash(string input, string hash) { using (SHA256 sha256 = SHA256.Create()) { // Hash the input. string hashOfInput = GetHash(input); // Create a StringComparer an compare the hashes. StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } } }
/// <summary> /// 验证输入数据的合法性 /// </summary> /// <param name="input">输入数据</param> /// <param name="hash">比对数据</param> /// <returns></returns> private bool VerifyMd5Hash(string input, string hash) { if (!string.IsNullOrEmpty(hash)) { string hashOfInput = MSGetMd5Hash(input); StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash)) { return(true); } else { return(false); } } else { return(true); } }
public static bool Contains(this string[] strings, string value, StringComparer comparer) { return strings.Any(val => comparer.Compare(val, value) == 0); }
public static Predicate<INode> ByNodeName(string name, StringComparer comparer) { return ByNodeName(delegate(string value) { return comparer.Compare(value, name) == 0; }); }
// search for a node with matching name in ordered list private int BinarySearch(string name, StringComparer nameComparer) { int max = nodes.Count - 1; int min = 0; while (max >= min) { int mid = min + ((max - min) >> 1); var comparison = nameComparer.Compare(nodes[mid].Name, name); if (comparison < 0) { min = mid + 1; } else if (comparison > 0) { max = mid - 1; } else { return mid; } } return -1; }
public static ProjectItem FindItem(this ProjectItems items, string itemName, StringComparer comparer) { return items.OfType<ProjectItem>().FirstOrDefault(p => comparer.Compare(p.Name, itemName) == 0); }
/// <summary> /// Calculates information about types and namespaces immediately contained within a namespace. /// </summary> /// <param name="isGlobalNamespace"> /// Is current namespace a global namespace? /// </param> /// <param name="namespaceNameLength"> /// Length of the fully-qualified name of this namespace. /// </param> /// <param name="typesByNS"> /// The sequence of groups of TypeDef row ids for types contained within the namespace, /// recursively including those from nested namespaces. The row ids must be grouped by the /// fully-qualified namespace name in case-sensitive manner. /// Key of each IGrouping is a fully-qualified namespace name, which starts with the name of /// this namespace. There could be multiple groups for each fully-qualified namespace name. /// /// The groups must be sorted by the keys in a manner consistent with comparer passed in as /// nameComparer. Therefore, all types immediately contained within THIS namespace, if any, /// must be in several IGrouping at the very beginning of the sequence. /// </param> /// <param name="nameComparer"> /// Equality comparer to compare namespace names. /// </param> /// <param name="types"> /// Output parameter, never null: /// A sequence of groups of TypeDef row ids for types immediately contained within this namespace. /// </param> /// <param name="namespaces"> /// Output parameter, never null: /// A sequence with information about namespaces immediately contained within this namespace. /// For each pair: /// Key - contains simple name of a child namespace. /// Value – contains a sequence similar to the one passed to this function, but /// calculated for the child namespace. /// </param> /// <remarks></remarks> public static void GetInfoForImmediateNamespaceMembers( bool isGlobalNamespace, int namespaceNameLength, IEnumerable<IGrouping<string, TypeDefinitionHandle>> typesByNS, StringComparer nameComparer, out IEnumerable<IGrouping<string, TypeDefinitionHandle>> types, out IEnumerable<KeyValuePair<string, IEnumerable<IGrouping<string, TypeDefinitionHandle>>>> namespaces) { Debug.Assert(typesByNS != null); Debug.Assert(namespaceNameLength >= 0); Debug.Assert(!isGlobalNamespace || namespaceNameLength == 0); // A list of groups of TypeDef row ids for types immediately contained within this namespace. var nestedTypes = new List<IGrouping<string, TypeDefinitionHandle>>(); // A list accumulating information about namespaces immediately contained within this namespace. // For each pair: // Key - contains simple name of a child namespace. // Value – contains a sequence similar to the one passed to this function, but // calculated for the child namespace. var nestedNamespaces = new List<KeyValuePair<string, IEnumerable<IGrouping<string, TypeDefinitionHandle>>>>(); bool possiblyHavePairsWithDuplicateKey = false; var enumerator = typesByNS.GetEnumerator(); using (enumerator) { if (enumerator.MoveNext()) { var pair = enumerator.Current; // Simple name of the last encountered child namespace. string lastChildNamespaceName = null; // A list accumulating information about types within the last encountered child namespace. // The list is similar to the sequence passed to this function. List<IGrouping<string, TypeDefinitionHandle>> typesInLastChildNamespace = null; // if there are any types in this namespace, // they will be in the first several groups if their key length // is equal to namespaceNameLength. while (pair.Key.Length == namespaceNameLength) { nestedTypes.Add(pair); if (!enumerator.MoveNext()) { goto DoneWithSequence; } pair = enumerator.Current; } // Account for the dot following THIS namespace name. if (!isGlobalNamespace) { namespaceNameLength++; } do { pair = enumerator.Current; string childNamespaceName = ExtractSimpleNameOfChildNamespace(namespaceNameLength, pair.Key); int cmp = nameComparer.Compare(lastChildNamespaceName, childNamespaceName); if (cmp == 0) { // We are still processing the same child namespace typesInLastChildNamespace.Add(pair); } else { // This is a new child namespace if (cmp > 0) { // The sort order is violated for child namespace names. Obfuscation is the likely reason for this. Debug.Assert((object)lastChildNamespaceName != null); possiblyHavePairsWithDuplicateKey = true; } // Preserve information about previous child namespace. if (typesInLastChildNamespace != null) { Debug.Assert(typesInLastChildNamespace.Count != 0); nestedNamespaces.Add( new KeyValuePair<string, IEnumerable<IGrouping<string, TypeDefinitionHandle>>>( lastChildNamespaceName, typesInLastChildNamespace)); } typesInLastChildNamespace = new List<IGrouping<string, TypeDefinitionHandle>>(); lastChildNamespaceName = childNamespaceName; Debug.Assert((object)lastChildNamespaceName != null); typesInLastChildNamespace.Add(pair); } } while (enumerator.MoveNext()); // Preserve information about last child namespace. if (typesInLastChildNamespace != null) { Debug.Assert(typesInLastChildNamespace.Count != 0); nestedNamespaces.Add( new KeyValuePair<string, IEnumerable<IGrouping<string, TypeDefinitionHandle>>>( lastChildNamespaceName, typesInLastChildNamespace)); } DoneWithSequence: /*empty statement*/ ; } } // using types = nestedTypes; // Merge pairs with the same key if (possiblyHavePairsWithDuplicateKey) { var names = new Dictionary<string, int>(nestedNamespaces.Count, nameComparer); for (int i = nestedNamespaces.Count - 1; i >= 0; i--) { names[nestedNamespaces[i].Key] = i; } if (names.Count != nestedNamespaces.Count) // nothing to merge otherwise { for (int i = 1; i < nestedNamespaces.Count; i++) { var pair = nestedNamespaces[i]; int keyIndex = names[pair.Key]; if (keyIndex != i) { Debug.Assert(keyIndex < i); var primaryPair = nestedNamespaces[keyIndex]; nestedNamespaces[keyIndex] = KeyValuePair.Create(primaryPair.Key, primaryPair.Value.Concat(pair.Value)); nestedNamespaces[i] = default(KeyValuePair<string, IEnumerable<IGrouping<string, TypeDefinitionHandle>>>); } } int removed = nestedNamespaces.RemoveAll(pair => (object)pair.Key == null); Debug.Assert(removed > 0); } } namespaces = nestedNamespaces; Debug.Assert(types != null); Debug.Assert(namespaces != null); }
private bool VerificationHelper(StringComparer sc, string x, string y, int expected, string errorno) { bool retVal = true; int actual = sc.Compare(x, y); if (actual != expected) { TestLibrary.TestFramework.LogError(errorno, "Compare returns wrong value"); TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE]"); retVal = false; } else if (actual < expected) { } return retVal; }