本文整理汇总了C#中ITypeParameter类的典型用法代码示例。如果您正苦于以下问题:C# ITypeParameter类的具体用法?C# ITypeParameter怎么用?C# ITypeParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITypeParameter类属于命名空间,在下文中一共展示了ITypeParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitTypeParameter
public override IType VisitTypeParameter(ITypeParameter type)
{
// TODO: how to map type parameters?
// It might have constraints, and those constraints might be mutually recursive.
// Maybe reintroduce ITypeParameter.Owner?
throw new NotImplementedException();
}
示例2: TypeParameterCompletionData
public TypeParameterCompletionData(ITypeParameter typeParameter)
{
TypeParameter = typeParameter;
SetDefaultText(typeParameter.Name);
DeclarationCategory = DeclarationCategory.Type_Parameter;
//Documentation = typeParameter.GetDefinition().Documentation;
}
示例3: InstantiatedParameterType
public InstantiatedParameterType (ProjectDom dom, ITypeParameterMember typeParameterMember, ITypeParameter tp)
{
IType outerType = typeParameterMember as IType ?? typeParameterMember.DeclaringType;
typeparam = tp;
compilationUnit = outerType.CompilationUnit;
ClassType = ClassType.Class;
Modifiers = Modifiers.Public;
Name = tp.Name;
Namespace = outerType.DecoratedFullName;
Location = outerType.Location;
DeclaringType = outerType;
if (tp.Constraints.Count > 0)
ClassType = ClassType.Interface;
foreach (IReturnType rt in tp.Constraints) {
if (FindCyclicReference (new HashSet<ITypeParameter> () { tp }, outerType, ((DomReturnType)rt).DecoratedFullName))
continue;
IType bt = dom.SearchType (typeParameterMember, rt);
IReturnType resolvedType = rt;
if (bt != null) {
resolvedType = new DomReturnType (bt);
if (bt.ClassType == ClassType.Interface || BaseType != null) {
AddInterfaceImplementation (resolvedType);
} else {
ClassType = bt.ClassType;
BaseType = resolvedType;
}
} else {
AddInterfaceImplementation (resolvedType);
}
}
if (BaseType == null)
BaseType = DomReturnType.Object;
}
示例4: VisitTypeParameter
public override IType VisitTypeParameter(ITypeParameter type)
{
if (type.OwnerType == SymbolKind.TypeDefinition) {
return DummyTypeParameter.GetClassTypeParameter(type.Index);
} else {
return base.VisitTypeParameter(type);
}
}
示例5: GetBaseTypeParameter
ITypeParameter GetBaseTypeParameter()
{
ITypeParameter baseTP = this.baseTypeParameter;
if (baseTP == null) {
// ResolveBaseTypeParameter() is idempotent, so this is thread-safe.
this.baseTypeParameter = baseTP = ResolveBaseTypeParameter((IMethod)this.Owner, this.Index);
}
return baseTP;
}
示例6: CheckTypeParameterConstraints
static bool CheckTypeParameterConstraints (IType type, IEnumerable<IType> baseTypes,
ITypeParameter typeParameter)
{
if (!typeParameter.DirectBaseTypes.All (t => baseTypes.Any (t2 => t2.Equals (t))))
return false;
if (typeParameter.HasDefaultConstructorConstraint &&
!type.GetConstructors (c => c.IsPublic && c.Parameters.Count == 0).Any ())
return false;
return true;
}
示例7: BoundTypeParameter
public BoundTypeParameter(ITypeParameter baseTypeParameter, IClass owningClass, IMethod owningMethod)
{
if (owningClass == null)
throw new ArgumentNullException("owningClass");
if (baseTypeParameter == null)
throw new ArgumentNullException("baseTypeParameter");
this.baseTypeParameter = baseTypeParameter;
this.owningMethod = owningMethod;
this.owningClass = owningClass;
}
示例8: CheckContstraints
void CheckContstraints(IMethod omethod, ITypeParameter p1, ITypeParameter p2, ref AbiCompatibility compatibility)
{
if (p1.DirectBaseTypes.Count () != p2.DirectBaseTypes.Count () ||
p1.HasReferenceTypeConstraint != p2.HasReferenceTypeConstraint ||
p1.HasValueTypeConstraint != p2.HasValueTypeConstraint ||
p1.HasDefaultConstructorConstraint != p2.HasDefaultConstructorConstraint) {
OnIncompatibilityFound (new AbiEventArgs (string.Format (TranslateString ("Type parameter constraints of method {0} have changed."), omethod.FullName)));
compatibility = AbiCompatibility.Incompatible;
}
}
示例9: AddConstraintsFromType
static void AddConstraintsFromType(ITypeParameter tp, GenericParameter g)
{
foreach (TypeReference constraint in g.Constraints) {
if (tp.Method != null) {
tp.Constraints.Add(CreateType(tp.Class.ProjectContent, tp.Method, constraint));
} else {
tp.Constraints.Add(CreateType(tp.Class.ProjectContent, tp.Class, constraint));
}
}
}
示例10: FindUsage
protected static bool FindUsage (BaseRefactoringContext context, SyntaxTree unit,
ITypeParameter typaParameter, AstNode declaration)
{
var found = false;
refFinder.FindTypeParameterReferences (typaParameter, context.UnresolvedFile, unit, context.Compilation,
(node, resolveResult) =>
{
found = found || node != declaration;
}, context.CancellationToken);
return found;
}
示例11: VisitTypeParameter
public override IType VisitTypeParameter(ITypeParameter type)
{
int index = type.Index;
if (type.OwnerType == EntityType.Method) {
if (index >= 0 && index < typeArguments.Count)
return typeArguments[index];
else
return SharedTypes.UnknownType;
} else {
return base.VisitTypeParameter(type);
}
}
示例12: VisitTypeParameter
public override IType VisitTypeParameter(ITypeParameter type)
{
int index = type.Index;
if (classTypeArguments != null && type.OwnerType == EntityType.TypeDefinition) {
if (index >= 0 && index < classTypeArguments.Count)
return classTypeArguments[index];
else
return SharedTypes.UnknownType;
} else if (methodTypeArguments != null && type.OwnerType == EntityType.Method) {
if (index >= 0 && index < methodTypeArguments.Count)
return methodTypeArguments[index];
else
return SharedTypes.UnknownType;
} else {
return base.VisitTypeParameter(type);
}
}
示例13: ResolveTypeParameter
public static JsExpression ResolveTypeParameter(ITypeParameter tp, ITypeDefinition currentType, IMethod currentMethod, IMetadataImporter metadataImporter, IErrorReporter errorReporter, INamer namer) {
bool unusable = false;
switch (tp.OwnerType) {
case EntityType.TypeDefinition:
unusable = metadataImporter.GetTypeSemantics(currentType).IgnoreGenericArguments;
break;
case EntityType.Method: {
var sem = metadataImporter.GetMethodSemantics(currentMethod);
unusable = sem.Type != MethodScriptSemantics.ImplType.InlineCode && metadataImporter.GetMethodSemantics(currentMethod).IgnoreGenericArguments;
break;
}
default:
errorReporter.InternalError("Invalid owner " + tp.OwnerType + " for type parameter " + tp);
return JsExpression.Null;
}
if (unusable) {
errorReporter.Message(Messages._7536, tp.Name, tp.OwnerType == EntityType.TypeDefinition ? "type" : "method", tp.OwnerType == EntityType.TypeDefinition ? currentType.FullName : currentMethod.FullName);
return JsExpression.Null;
}
return JsExpression.Identifier(namer.GetTypeParameterName(tp));
}
示例14: GetTypeParameter
static ITypeParameter GetTypeParameter(ref ITypeParameter[] typeParameters, SymbolKind symbolKind, int index)
{
ITypeParameter[] tps = typeParameters;
while (index >= tps.Length) {
// We don't have a normal type parameter for this index, so we need to extend our array.
// Because the array can be used concurrently from multiple threads, we have to use
// Interlocked.CompareExchange.
ITypeParameter[] newTps = new ITypeParameter[index + 1];
tps.CopyTo(newTps, 0);
for (int i = tps.Length; i < newTps.Length; i++) {
newTps[i] = new DummyTypeParameter(symbolKind, i);
}
ITypeParameter[] oldTps = Interlocked.CompareExchange(ref typeParameters, newTps, tps);
if (oldTps == tps) {
// exchange successful
tps = newTps;
} else {
// exchange not successful
tps = oldTps;
}
}
return tps[index];
}
示例15: FindTypeParameterReferencesNavigator
public FindTypeParameterReferencesNavigator(ITypeParameter typeParameter)
{
this.typeParameter = typeParameter;
}