本文整理汇总了C#中ConstructorBuilder.DefineParameter方法的典型用法代码示例。如果您正苦于以下问题:C# ConstructorBuilder.DefineParameter方法的具体用法?C# ConstructorBuilder.DefineParameter怎么用?C# ConstructorBuilder.DefineParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstructorBuilder
的用法示例。
在下文中一共展示了ConstructorBuilder.DefineParameter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyAttributes
public virtual void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index, PredefinedAttributes pa)
{
if (builder != null)
throw new InternalErrorException ("builder already exists");
var pattrs = ParametersCompiled.GetParameterAttribute (modFlags);
if (HasOptionalExpression)
pattrs |= ParameterAttributes.Optional;
if (mb == null)
builder = cb.DefineParameter (index, pattrs, Name);
else
builder = mb.DefineParameter (index, pattrs, Name);
if (OptAttributes != null)
OptAttributes.Emit ();
if (HasDefaultValue) {
//
// Emit constant values for true constants only, the other
// constant-like expressions will rely on default value expression
//
var def_value = DefaultValue;
Constant c = def_value != null ? def_value.Child as Constant : default_expr as Constant;
if (c != null) {
if (c.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) {
pa.DecimalConstant.EmitAttribute (builder, (decimal) c.GetValue (), c.Location);
} else {
builder.SetConstant (c.GetValue ());
}
} else if (default_expr.Type.IsStruct) {
//
// Handles special case where default expression is used with value-type
//
// void Foo (S s = default (S)) {}
//
builder.SetConstant (null);
}
}
if (parameter_type != null) {
if (parameter_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
pa.Dynamic.EmitAttribute (builder);
} else if (parameter_type.HasDynamicElement) {
pa.Dynamic.EmitAttribute (builder, parameter_type, Location);
}
}
}