本文整理汇总了C#中ISymbol.TypeParameters方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.TypeParameters方法的具体用法?C# ISymbol.TypeParameters怎么用?C# ISymbol.TypeParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISymbol
的用法示例。
在下文中一共展示了ISymbol.TypeParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetMethodReference
public bool TryGetMethodReference(ISymbol semanticMethod, out IMethodReference cciMethod) {
Contract.Requires(semanticMethod == null || semanticMethod.Kind == SymbolKind.Method);
Contract.Ensures(!Contract.Result<bool>() || Contract.ValueAtReturn(out cciMethod) != null);
cciMethod = null;
#region Check input
if (semanticMethod == null) {
return false;
}
#endregion
#region Check cache
if (ContractsPackageAccessor.Current.VSOptionsPage.Caching)
if (_semanticMembersToCCIMethods.TryGetValue(semanticMethod, out cciMethod))
return (!(cciMethod is Dummy)) && cciMethod != null;
#endregion
#region Set up our working cci method
var workingCciMethod = new Microsoft.Cci.MutableCodeModel.MethodReference();
#endregion
#region Set the intern factory
workingCciMethod.InternFactory = Host.InternFactory;
#endregion
#region Get calling conventions
workingCciMethod.CallingConvention = CSharpToCCIHelper.GetCallingConventionFor(semanticMethod);
#endregion
#region Get containing type reference
ITypeReference containingType;
if (!TryGetTypeReference(semanticMethod.ContainingType, out containingType))
goto ReturnFalse;
workingCciMethod.ContainingType = containingType;
#endregion
#region Get return type reference
if (semanticMethod.IsConstructor())
workingCciMethod.Type = this.Host.PlatformType.SystemVoid;
else {
ITypeReference returnType;
if (!TryGetTypeReference(semanticMethod.ReturnType(), out returnType))
goto ReturnFalse;
workingCciMethod.Type = returnType;
}
#endregion
#region Get name
if (!semanticMethod.IsConstructor() && semanticMethod.Name == null) goto ReturnFalse;
workingCciMethod.Name = Host.NameTable.GetNameFor(semanticMethod.IsConstructor()?".ctor":semanticMethod.Name);
#endregion
#region Get generic param count
if (semanticMethod.TypeParameters().IsDefault)
workingCciMethod.GenericParameterCount = 0;
else
workingCciMethod.GenericParameterCount = (ushort)semanticMethod.TypeParameters().Length;
#endregion
#region Get parameter references
List<IParameterTypeInformation> cciParameters;
if (semanticMethod.Parameters().IsDefault) goto ReturnFalse;
Contract.Assume(semanticMethod.Parameters().Length <= ushort.MaxValue, "Should be a postcondition?");
if (!TryGetParametersList(semanticMethod.Parameters(), out cciParameters))
goto ReturnFalse;
workingCciMethod.Parameters = cciParameters;
#endregion
#region Get the assembly reference (this also ensures the assembly gets loaded properly)
IAssemblyReference assemblyReference;
TryGetAssemblyReference(semanticMethod.ContainingAssembly, out assemblyReference);
#endregion
cciMethod = workingCciMethod;
return true;
#region ReturnFalse:
ReturnFalse:
cciMethod = Dummy.MethodReference;
if (ContractsPackageAccessor.Current.VSOptionsPage.Caching)
_semanticMembersToCCIMethods[semanticMethod] = cciMethod;
return false;
#endregion
}