本文整理汇总了C#中IMethodSymbol.IsExported方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodSymbol.IsExported方法的具体用法?C# IMethodSymbol.IsExported怎么用?C# IMethodSymbol.IsExported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodSymbol
的用法示例。
在下文中一共展示了IMethodSymbol.IsExported方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TranslateArguments
/*
public JsExpression[] TranslateArguments(MethodSymbol method, params JsExpression[] args)
{
return TranslateArguments(method, (x, i) => x is JsArrayExpression);
}
*/
public JsExpression[] TranslateArguments(SyntaxNode context, IMethodSymbol method, Func<JsExpression, int, bool> isArgumentArray, Func<JsExpression, int, string> getArgumentName, params JsExpression[] args)
{
var isExported = method.IsExported();
// The number of arguments may differ from the number of parameters, due to default parameters and the params keyword.
// This queue holds all the remaining arguments, and the matching of parameters to arguments happens in sequence,
// consuming from the queue.
var remainingArguments = new Queue<JsExpression>(args);
var argumentsByName = args
.Select((x, i) => new { Name = getArgumentName(x, i), Argument = x })
.Where(x => x.Name != null)
.ToDictionary(x => x.Name, x => x.Argument);
if (argumentsByName.Any())
{
var newArguments = new List<JsExpression>();
foreach (var parameter in method.Parameters)
{
if (!parameter.HasExplicitDefaultValue)
{
newArguments.Add(remainingArguments.Dequeue());
}
else
{
if (!argumentsByName.ContainsKey(parameter.Name))
{
if (parameter.GetAttributes().Any(x => Equals(x.AttributeClass, Context.Instance.CallerMemberNameAttribute)))
{
var value = context.GetContainingMemberName();
newArguments.Add(value != null ? Js.Literal(value) : GetExplicitDefaultValue(parameter));
}
else
{
newArguments.Add(GetExplicitDefaultValue(parameter));
}
}
else
{
var argument = argumentsByName[parameter.Name];
newArguments.Add(argument);
}
}
}
remainingArguments = new Queue<JsExpression>(newArguments);
}
var arguments = new List<JsExpression>();
foreach (var parameter in method.Parameters)
{
// params parameters require special handling
if (parameter.IsParams)
{
// If there's only one argument for the params parameter, it could be either an array containing
// the the params arguments, or just a single argument.
if (remainingArguments.Count == 1)
{
var argument = remainingArguments.Peek();
var argIndex = args.Length - remainingArguments.Count;
if (isArgumentArray(argument, argIndex))
{
// If it's an array and exported, we just pass it as is, since the argument must ultimately be an array.
if (isExported)
{
arguments.Add(argument);
}
// If it's NOT exported, then we simply pass them as ordinary arguments, since that's how this "params"
// concept works over there (it's not abstracted into an array).
else
{
foreach (var element in ((JsArrayExpression)argument).Elements)
{
arguments.Add(element);
}
}
remainingArguments.Dequeue();
continue;
}
}
// If exported, then add all the rest of the arguments as an array
if (isExported)
{
arguments.Add(MakeArray(Js.Array(remainingArguments.ToArray()), (IArrayTypeSymbol)parameter.Type));
}
// Otherwise, add all the rest of the arguments as ordinary arguments per the comment earlier about non exported types.
else
{
while (remainingArguments.Any())
arguments.Add(remainingArguments.Dequeue());
}
}
else if (!remainingArguments.Any())
{
//.........这里部分代码省略.........