本文整理汇总了C#中System.Reflection.ParameterInfo.IsOutParameter方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterInfo.IsOutParameter方法的具体用法?C# ParameterInfo.IsOutParameter怎么用?C# ParameterInfo.IsOutParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.ParameterInfo
的用法示例。
在下文中一共展示了ParameterInfo.IsOutParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapParameterReduceByRef
private void MapParameterReduceByRef(ParameterInfo pi) {
Debug.Assert(_returnArgs != null);
// See KeywordArgBuilder.BuilderExpectsSingleParameter
int indexForArgBuilder = 0;
int nameIndex = -1;
if (!pi.IsOutParameter()) {
nameIndex = _argNames.IndexOf(pi.Name);
if (nameIndex == -1) {
indexForArgBuilder = _argIndex++;
}
}
ArgBuilder ab;
if (pi.IsOutParameter()) {
_returnArgs.Add(_arguments.Count);
ab = new OutArgBuilder(pi);
} else if (pi.ParameterType.IsByRef) {
// if the parameter is marked as [In] it is not returned.
if ((pi.Attributes & (ParameterAttributes.In | ParameterAttributes.Out)) != ParameterAttributes.In) {
_returnArgs.Add(_arguments.Count);
}
_parameters.Add(new ParameterWrapper(pi, pi.ParameterType.GetElementType(), pi.Name, ParameterBindingFlags.None));
ab = new ReturnReferenceArgBuilder(pi, indexForArgBuilder);
} else {
ab = AddSimpleParameterMapping(pi, indexForArgBuilder);
}
if (nameIndex == -1) {
_arguments.Add(ab);
} else {
Debug.Assert(KeywordArgBuilder.BuilderExpectsSingleParameter(ab));
_arguments.Add(new KeywordArgBuilder(ab, _argNames.Count, nameIndex));
}
}
示例2: MapParameterReduceByRef
/// <summary>
/// Maps out parameters to return args and ref parameters to ones that don't accept StrongBox.
/// </summary>
private void MapParameterReduceByRef(ParameterInfo pi) {
Debug.Assert(_returnArgs != null);
// TODO:
// Is this reduction necessary? What if
// 1) we had an implicit conversion StrongBox<T> -> T& and
// 2) all out parameters were treated as optional StrongBox<T> parameters? (if not present we return the result in a return value)
int indexForArgBuilder = 0;
int nameIndex = -1;
if (!pi.IsOutParameter()) {
nameIndex = _argNames.IndexOf(pi.Name);
if (nameIndex == -1) {
indexForArgBuilder = _argIndex++;
}
}
ArgBuilder ab;
if (pi.IsOutParameter()) {
_returnArgs.Add(_arguments.Count);
ab = new OutArgBuilder(pi);
} else if (pi.ParameterType.IsByRef) {
// if the parameter is marked as [In] it is not returned.
if ((pi.Attributes & (ParameterAttributes.In | ParameterAttributes.Out)) != ParameterAttributes.In) {
_returnArgs.Add(_arguments.Count);
}
_parameters.Add(new ParameterWrapper(pi, pi.ParameterType.GetElementType(), pi.Name, ParameterBindingFlags.None));
ab = new ReturnReferenceArgBuilder(pi, indexForArgBuilder);
} else {
ab = AddSimpleParameterMapping(pi, indexForArgBuilder);
}
if (nameIndex == -1) {
_arguments.Add(ab);
} else {
Debug.Assert(KeywordArgBuilder.BuilderExpectsSingleParameter(ab));
_arguments.Add(new KeywordArgBuilder(ab, _argNames.Count, nameIndex));
}
}