本文整理汇总了C#中HashedSet.RemoveAll方法的典型用法代码示例。如果您正苦于以下问题:C# HashedSet.RemoveAll方法的具体用法?C# HashedSet.RemoveAll怎么用?C# HashedSet.RemoveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashedSet
的用法示例。
在下文中一共展示了HashedSet.RemoveAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTypeLibWrapper
private Assembly CreateTypeLibWrapper(string typeLibFileName)
{
if (_remoteObj == null)
{
return null;
}
typeLibFileName = new FileInfo(typeLibFileName).FullName;
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(typeLibFileName);
byte[] publicKey;
if (KeyPair == null)
{
publicKey = null;
}
else
{
publicKey = KeyPair.PublicKey;
}
bool hasOutputDirectory = !string.IsNullOrEmpty(OutputDirectory);
string previousCurrentDirectory;
if (hasOutputDirectory)
{
if (!Directory.Exists(OutputDirectory))
{
Directory.CreateDirectory(OutputDirectory);
}
previousCurrentDirectory = Environment.CurrentDirectory;
Environment.CurrentDirectory = OutputDirectory;
}
else
{
previousCurrentDirectory = null;
}
try
{
ICollection existingLibraries = new ArrayList(_alreadyImportedLibraries.Keys);
_runMethod.Invoke(_remoteObj, new object[]
{
typeLibFileName,
null,
null,
OutputDirectory,
publicKey,
KeyPair,
null,
null,
new Version(versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart, versionInfo.ProductPrivatePart),
TypeLibImporterFlags.ReflectionOnlyLoading,
true,
true,
false,
false,
false,
false
});
ISet newLibraries = new HashedSet(_alreadyImportedLibraries.Keys);
newLibraries.RemoveAll(existingLibraries);
foreach (Guid newLibraryID in newLibraries)
{
Assembly libraryAssembly = (Assembly) _alreadyImportedLibraries[newLibraryID];
ImportedFileNames[libraryAssembly.FullName] = libraryAssembly.GetName().Name + ".dll";
}
string assemblyFileName = (string) _assemblyNameField.GetValue(_optionsField.GetValue(null));
Assembly assembly = Assembly.LoadFrom(hasOutputDirectory
? Path.Combine(OutputDirectory, assemblyFileName)
: assemblyFileName);
ImportedFileNames[assembly.FullName] = assemblyFileName;
return assembly;
}
finally
{
if (previousCurrentDirectory != null)
{
Environment.CurrentDirectory = previousCurrentDirectory;
}
}
}
示例2: MapCollectionChanges
public IList<PersistentCollectionChangeData> MapCollectionChanges(string referencingPropertyName,
IPersistentCollection newColl,
object oldColl,
object id)
{
if (!CommonCollectionMapperData.CollectionReferencingPropertyData.Name.Equals(referencingPropertyName))
{
return null;
}
var collectionChanges = new List<PersistentCollectionChangeData>();
// Comparing new and old collection content.
var newCollection = GetNewCollectionContent(newColl);
var oldCollection = GetOldCollectionContent(oldColl);
var added = new HashedSet();
if (newColl != null)
{
foreach (var item in newCollection)
{
added.Add(item);
}
}
// Re-hashing the old collection as the hash codes of the elements there may have changed, and the
// removeAll in AbstractSet has an implementation that is hashcode-change sensitive (as opposed to addAll).
if (oldColl != null)
{
var itemsToRemove = new HashedSet();
foreach (var item in oldCollection)
{
itemsToRemove.Add(item);
}
added.RemoveAll(itemsToRemove);
}
addCollectionChanges(collectionChanges, added, RevisionType.Added, id);
var deleted = new HashedSet();
if (oldColl != null)
{
foreach (var item in oldCollection)
{
deleted.Add(item);
}
}
// The same as above - re-hashing new collection.
if (newColl != null)
{
var itemsToRemove = new HashedSet();
foreach (var item in newCollection)
{
itemsToRemove.Add(item);
}
deleted.RemoveAll(itemsToRemove);
}
addCollectionChanges(collectionChanges, deleted, RevisionType.Deleted, id);
return collectionChanges;
}