本文整理汇总了C#中System.Reflection.ParameterInfo.IsAttributeDefined方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterInfo.IsAttributeDefined方法的具体用法?C# ParameterInfo.IsAttributeDefined怎么用?C# ParameterInfo.IsAttributeDefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.ParameterInfo
的用法示例。
在下文中一共展示了ParameterInfo.IsAttributeDefined方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
public override Expression/*!*/ Convert(DynamicMetaObject/*!*/ metaObject, Type restrictedType, ParameterInfo info, Type/*!*/ toType) {
Expression expr = metaObject.Expression;
Type fromType = restrictedType ?? expr.Type;
// block:
if (fromType == typeof(MissingBlockParam)) {
Debug.Assert(toType == typeof(BlockParam) || toType == typeof(MissingBlockParam));
return AstUtils.Constant(null);
}
if (fromType == typeof(BlockParam) && toType == typeof(MissingBlockParam)) {
return AstUtils.Constant(null);
}
// protocol conversions:
if (info != null && info.IsAttributeDefined(typeof(DefaultProtocolAttribute), false)) {
var action = RubyConversionAction.TryGetDefaultConversionAction(Context, toType);
if (action != null) {
// TODO: inline implicit conversions:
return Ast.Dynamic(action, toType, expr);
}
// Do not throw an exception here to allow generic type parameters to be used with D.P. attribute.
// The semantics should be to use DP if available for the current instantiation and ignore it otherwise.
}
if (restrictedType != null) {
if (restrictedType == typeof(DynamicNull)) {
if (!toType.IsValueType || toType.IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>)) {
return AstUtils.Constant(null, toType);
} else if (toType == typeof(bool)) {
return AstUtils.Constant(false);
}
}
if (toType.IsAssignableFrom(restrictedType)) {
// expr can be converted to restrictedType, which can be converted toType => we can convert expr to toType:
return AstUtils.Convert(expr, CompilerHelpers.GetVisibleType(toType));
}
// if there is a simple conversion from restricted type, convert the expression to the restricted type and use that conversion:
Type visibleRestrictedType = CompilerHelpers.GetVisibleType(restrictedType);
if (Converter.CanConvertFrom(metaObject, visibleRestrictedType, toType, false, NarrowingLevel.None, false, false)) {
expr = AstUtils.Convert(expr, visibleRestrictedType);
}
}
return Converter.ConvertExpression(expr, toType, _args.RubyContext, _args.MetaContext.Expression, _implicitProtocolConversions);
}
示例2: IsParamDictionary
public static bool IsParamDictionary(ParameterInfo parameter) {
return parameter.IsAttributeDefined(typeof(ParamDictionaryAttribute), false);
}