Here are the examples of the csharp api System.Collections.Generic.HashSet.Contains(TypeRef) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
5 Examples
19
Source : CppTypeContext.cs
with The Unlicense
from sc2ad
with The Unlicense
from sc2ad
private void SetUniqueInterfaces(ITypeData data)
{
// Iterate over all of my data's interfaces
// For each, add its unique interfaces to a local hashset
// Then, set my UniqueInterfaces to be my original interfaces - anything shared in the local hashset
var nestedUnique = new List<TypeRef>();
ITypeData CollectImplementingInterfaces(TypeRef face)
{
var nested = face.Resolve(Types);
if (nested is null)
throw new ArgumentException($"Could not resolve TypeRef: {face}!");
var map = face.IsGenericInstance ? face.ExtractGenericMap(Types) : null;
nestedUnique.AddRange(nested.ImplementingInterfaces.Select(i => (!i.IsGeneric || map is null) ? i : i.MakeGenericInstance(map)));
return nested;
}
foreach (var face in data.ImplementingInterfaces)
{
UniqueInterfaces.AddOrThrow(face);
CollectImplementingInterfaces(face);
}
var parent = data.Parent;
while (parent != null)
parent = CollectImplementingInterfaces(parent).Parent;
var alreadyDefined = GetUniqueInterfaces(nestedUnique);
foreach (var i in data.ImplementingInterfaces)
if (alreadyDefined.Contains(i))
UniqueInterfaces.Remove(i);
}
19
Source : CppTypeContext.cs
with The Unlicense
from sc2ad
with The Unlicense
from sc2ad
internal bool IsGenericParameter(TypeRef type) => _genericTypes.Contains(type) || type.IsGenericParameter;
19
Source : CppTypeContext.cs
with The Unlicense
from sc2ad
with The Unlicense
from sc2ad
private void AddDefinition(TypeRef def, ITypeData? resolved = null)
{
// Adding a definition is simple, ensure the type is resolved and add it
if (resolved is null)
resolved = def.Resolve(Types);
if (resolved is null)
throw new UnresolvedTypeException(LocalType.This, def);
def = resolved.This;
if (Definitions.Contains(def)) return;
if (DefinitionsToGet.Contains(def)) return;
// Remove anything that is already declared, we only need to define it
if (!DeclarationsToMake.Remove(def))
Declarations.Remove(def);
// When we add a definition, we add it to our DefinitionsToGet
// However, if the type we are looking for is a nested type with a declaring type that we share:
// We need to set the InPlace property for all declaring types of that desired type to true
// (up until the DeclaringType is shared between them)
// If the definition I am adding shares the same RootContext as me, I need to InPlace nest it.
if (!RootContext.HasInNestedHierarchy(resolved, out var defContext))
DefinitionsToGet.AddOrThrow(def);
else
InPlaceNestedType(defContext);
}
19
Source : CppTypeContext.cs
with The Unlicense
from sc2ad
with The Unlicense
from sc2ad
private void AddDeclaration(TypeRef def, ITypeData? resolved)
{
Contract.Requires(!def.IsVoid());
if (resolved is null)
resolved = def.Resolve(Types);
if (resolved is null)
throw new UnresolvedTypeException(LocalType.This, def);
def = resolved.This;
// If we have it in our DefinitionsToGet, no need to declare as well
if (DefinitionsToGet.Contains(def)) return;
if (DeclarationsToMake.Contains(def)) return; // this def is already queued for declaration
if (Declarations.Contains(def)) return;
if (def.DeclaringType != null && !Definitions.Contains(def.DeclaringType))
{
// If def's declaring type is not defined, we cannot declare def. Define def's declaring type instead.
AddDefinition(def.DeclaringType);
Declarations.AddOrThrow(def);
}
else
// Otherwise, we can safely add it to declarations
DeclarationsToMake.AddOrThrow(def);
}
19
Source : CppTypeContext.cs
with The Unlicense
from sc2ad
with The Unlicense
from sc2ad
private void AddDeclaration(TypeRef def, ITypeData? resolved)
{
Contract.Requires(!def.IsVoid());
if (resolved is null)
resolved = def.Resolve(Types);
if (resolved is null)
throw new UnresolvedTypeException(LocalType.This, def);
def = resolved.This;
// If we have it in our DefinitionsToGet, no need to declare as well
if (DefinitionsToGet.Contains(def)) return;
if (DeclarationsToMake.Contains(def)) return; // this def is already queued for declaration
if (Declarations.Contains(def)) return;
if (def.DeclaringType != null && !Definitions.Contains(def.DeclaringType))
{
// If def's declaring type is not defined, we cannot declare def. Define def's declaring type instead.
AddDefinition(def.DeclaringType);
Declarations.AddOrThrow(def);
}
else
// Otherwise, we can safely add it to declarations
DeclarationsToMake.AddOrThrow(def);
}