public bool TryGet(Type key, out TypeName value) { var keyFullName = key.FullName; var node = First; while (node != null) { var comp = NameComparer.Compare(GetName(node.Item), keyFullName); if (comp < 0) { node = node.Next; continue; } else if (comp == 0) { value = node.Item; return(true); } else { break; } } value = default(TypeName); return(false); }
public bool TryGet(string key, out INamespaceName value) { var node = First; while (node != null) { var comp = NameComparer.Compare(GetName(node.Item), key); if (comp < 0) { node = node.Next; continue; } else if (comp == 0) { value = node.Item; return(true); } else { break; } } value = default(INamespaceName); return(false); }
public void CompareFileAndDirectory() { var fileInfo = new Mock <IFileInfo>(); fileInfo.Setup(x => x.Name).Returns("a"); fileInfo.Setup(x => x.Exists).Returns(true); var fileEntity = new FileEntity(fileInfo.Object); var directoryInfo = new Mock <IDirectoryInfo>(); directoryInfo.Setup(x => x.Name).Returns("b"); directoryInfo.Setup(x => x.Exists).Returns(true); var directoryEntity = new DirectoryEntity(directoryInfo.Object); var compare = comparer.Compare(fileEntity, directoryEntity); Assert.AreEqual(1, compare); }
private bool CheckResDGVSorted(int rowIndex) { DataGridViewColumnHeaderCell hc = this.resDGV.Columns[this.mColIndex].HeaderCell; if (hc.SortGlyphDirection == SortOrder.None) { return(true); } int num = 0; INamedResourceIndexEntry x, y; if (rowIndex > 0) { x = this.mResources[rowIndex - 1]; y = this.mResources[rowIndex]; switch ((ColumnName)this.mColIndex) { case ColumnName.Tag: num = sTagComparer.Compare(x, y); break; case ColumnName.TID: num = sTIDComparer.Compare(x, y); break; case ColumnName.GID: num = sGIDComparer.Compare(x, y); break; case ColumnName.IID: num = sIIDComparer.Compare(x, y); break; case ColumnName.Comp: num = sCompComparer.Compare(x, y); break; case ColumnName.Name: num = sNameComparer.Compare(x, y); break; } if (hc.SortGlyphDirection == SortOrder.Descending) { num = -num; } if (num < 0) { return(false); } } if (rowIndex < (this.mResources.Length - 1)) { x = this.mResources[rowIndex]; y = this.mResources[rowIndex + 1]; switch ((ColumnName)this.mColIndex) { case ColumnName.Tag: num = sTagComparer.Compare(x, y); break; case ColumnName.TID: num = sTIDComparer.Compare(x, y); break; case ColumnName.GID: num = sGIDComparer.Compare(x, y); break; case ColumnName.IID: num = sIIDComparer.Compare(x, y); break; case ColumnName.Comp: num = sCompComparer.Compare(x, y); break; case ColumnName.Name: num = sNameComparer.Compare(x, y); break; } if (hc.SortGlyphDirection == SortOrder.Descending) { num = -num; } if (num < 0) { return(false); } } return(true); }