本文整理汇总了C#中ITypeSymbol.GetDelegateInvokeMethod方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeSymbol.GetDelegateInvokeMethod方法的具体用法?C# ITypeSymbol.GetDelegateInvokeMethod怎么用?C# ITypeSymbol.GetDelegateInvokeMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeSymbol
的用法示例。
在下文中一共展示了ITypeSymbol.GetDelegateInvokeMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCompatibleMethods
void AddCompatibleMethods (CompletionEngine engine, List<CompletionData> list, ITypeSymbol delegateType, IMethodSymbol [] memberMethods, CancellationToken cancellationToken)
{
var delegateMethod = delegateType.GetDelegateInvokeMethod ();
foreach (var method in memberMethods) {
if (method.ReturnType.Equals (delegateMethod.ReturnType) && SignatureComparer.HaveSameSignature (delegateMethod.Parameters, method.Parameters, false, false)) {
list.Add (engine.Factory.CreateExistingMethodDelegate (this, method));
}
}
}
示例2: AddDelegateHandlers
void AddDelegateHandlers (List<CompletionData> completionList, SyntaxNode parent, SemanticModel semanticModel, CompletionEngine engine, CompletionResult result, ITypeSymbol delegateType, int position, string optDelegateName, CancellationToken cancellationToken)
{
var delegateMethod = delegateType.GetDelegateInvokeMethod ();
result.PossibleDelegates.Add (delegateMethod);
var thisLineIndent = "";
string EolMarker = "\n";
bool addSemicolon = true;
bool addDefault = true;
string delegateEndString = EolMarker + thisLineIndent + "}" + (addSemicolon ? ";" : "");
//bool containsDelegateData = completionList.Result.Any(d => d.DisplayText.StartsWith("delegate("));
CompletionData item;
if (addDefault) {
item = engine.Factory.CreateAnonymousMethod (
this,
"delegate",
"Creates anonymous delegate.",
"delegate {" + EolMarker + thisLineIndent,
delegateEndString
);
if (!completionList.Any (i => i.DisplayText == item.DisplayText))
completionList.Add (item);
//if (LanguageVersion.Major >= 5)
item = engine.Factory.CreateAnonymousMethod (
this,
"async delegate",
"Creates anonymous async delegate.",
"async delegate {" + EolMarker + thisLineIndent,
delegateEndString
);
if (!completionList.Any (i => i.DisplayText == item.DisplayText))
completionList.Add (item);
}
var sb = new StringBuilder ("(");
var sbWithoutTypes = new StringBuilder ("(");
for (int k = 0; k < delegateMethod.Parameters.Length; k++) {
if (k > 0) {
sb.Append (", ");
sbWithoutTypes.Append (", ");
}
sb.Append (RoslynCompletionData.SafeMinimalDisplayString (delegateMethod.Parameters [k], semanticModel, position, overrideNameFormat));
sbWithoutTypes.Append (delegateMethod.Parameters [k].Name);
}
sb.Append (")");
sbWithoutTypes.Append (")");
var signature = sb.ToString ()
.Replace (", params ", ", ")
.Replace ("(params ", "(");
if (completionList.All (data => data.DisplayText != signature)) {
item = engine.Factory.CreateAnonymousMethod (
this,
signature + " =>",
"Creates typed lambda expression.",
signature + " => ",
(addSemicolon ? ";" : "")
);
if (!completionList.Any (i => i.DisplayText == item.DisplayText))
completionList.Add (item);
// if (LanguageVersion.Major >= 5) {
item = engine.Factory.CreateAnonymousMethod (
this,
"async " + signature + " =>",
"Creates typed async lambda expression.",
"async " + signature + " => ",
(addSemicolon ? ";" : "")
);
if (!completionList.Any (i => i.DisplayText == item.DisplayText))
completionList.Add (item);
var signatureWithoutTypes = sbWithoutTypes.ToString ();
if (!delegateMethod.Parameters.Any (p => p.RefKind != RefKind.None) && completionList.All (data => data.DisplayText != signatureWithoutTypes)) {
item = engine.Factory.CreateAnonymousMethod (
this,
signatureWithoutTypes + " =>",
"Creates typed lambda expression.",
signatureWithoutTypes + " => ",
(addSemicolon ? ";" : "")
);
if (!completionList.Any (i => i.DisplayText == item.DisplayText))
completionList.Add (item);
//if (LanguageVersion.Major >= 5) {
item = engine.Factory.CreateAnonymousMethod (
this,
"async " + signatureWithoutTypes + " =>",
"Creates typed async lambda expression.",
"async " + signatureWithoutTypes + " => ",
(addSemicolon ? ";" : "")
);
if (!completionList.Any (i => i.DisplayText == item.DisplayText))
completionList.Add (item);
//.........这里部分代码省略.........
示例3: DelegateParameterHintingData
public DelegateParameterHintingData (ITypeSymbol symbol) : base (symbol)
{
this.invocationMethod = symbol.GetDelegateInvokeMethod ();
}