本文整理汇总了C#中IParameterData类的典型用法代码示例。如果您正苦于以下问题:C# IParameterData类的具体用法?C# IParameterData怎么用?C# IParameterData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IParameterData类属于命名空间,在下文中一共展示了IParameterData类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CheckReservedNameConflict
protected void CheckReservedNameConflict (string prefix, MethodSpec accessor)
{
string name;
AParametersCollection parameters;
if (accessor != null) {
name = accessor.Name;
parameters = accessor.Parameters;
} else {
name = prefix + ShortName;
if (IsExplicitImpl)
name = MemberName.Left + "." + name;
if (this is Indexer) {
parameters = ((Indexer) this).ParameterInfo;
if (prefix[0] == 's') {
var data = new IParameterData[parameters.Count + 1];
Array.Copy (parameters.FixedParameters, data, data.Length - 1);
data[data.Length - 1] = new ParameterData ("value", Parameter.Modifier.NONE);
var types = new TypeSpec[data.Length];
Array.Copy (parameters.Types, types, data.Length - 1);
types[data.Length - 1] = member_type;
parameters = new ParametersImported (data, types, false);
}
} else {
if (prefix[0] == 's')
parameters = ParametersCompiled.CreateFullyResolved (new[] { member_type });
else
parameters = ParametersCompiled.EmptyReadOnlyParameters;
}
}
var conflict = MemberCache.FindMember (Parent.Definition,
new MemberFilter (name, 0, MemberKind.Method, parameters, null),
BindingRestriction.DeclaredOnly | BindingRestriction.NoAccessors);
if (conflict != null) {
Report.SymbolRelatedToPreviousError (conflict);
Report.Error (82, Location, "A member `{0}' is already reserved", conflict.GetSignatureForError ());
}
}
开发者ID:bbqchickenrobot,项目名称:playscript-mono,代码行数:41,代码来源:property.cs
示例2: ParametersCompiled
private ParametersCompiled (IParameterData[] parameters, TypeSpec[] types)
{
this.parameters = parameters;
this.types = types;
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:5,代码来源:parameter.cs
示例3: ParametersImported
public ParametersImported (IParameterData[] param, TypeSpec[] types, bool hasParams)
{
this.parameters = param;
this.types = types;
this.has_params = hasParams;
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:6,代码来源:parameter.cs
示例4: CreateParameters
//
// Imports System.Reflection parameters
//
AParametersCollection CreateParameters (TypeSpec parent, ParameterInfo[] pi, MethodBase method)
{
int varargs = method != null && (method.CallingConvention & CallingConventions.VarArgs) != 0 ? 1 : 0;
if (pi.Length == 0 && varargs == 0)
return ParametersCompiled.EmptyReadOnlyParameters;
TypeSpec[] types = new TypeSpec[pi.Length + varargs];
IParameterData[] par = new IParameterData[pi.Length + varargs];
bool is_params = false;
for (int i = 0; i < pi.Length; i++) {
ParameterInfo p = pi[i];
Parameter.Modifier mod = 0;
Expression default_value = null;
if (p.ParameterType.IsByRef) {
if ((p.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out)
mod = Parameter.Modifier.OUT;
else
mod = Parameter.Modifier.REF;
//
// Strip reference wrapping
//
var el = p.ParameterType.GetElementType ();
types[i] = ImportType (el, new DynamicTypeReader (p)); // TODO: 1-based positio to be csc compatible
} else if (i == 0 && method.IsStatic && parent.IsStatic && parent.MemberDefinition.DeclaringAssembly.HasExtensionMethod &&
HasAttribute (CustomAttributeData.GetCustomAttributes (method), "ExtensionAttribute", CompilerServicesNamespace)) {
mod = Parameter.Modifier.This;
types[i] = ImportType (p.ParameterType);
} else {
types[i] = ImportType (p.ParameterType, new DynamicTypeReader (p));
if (i >= pi.Length - 2 && types[i] is ArrayContainer) {
if (HasAttribute (CustomAttributeData.GetCustomAttributes (p), "ParamArrayAttribute", "System")) {
mod = Parameter.Modifier.PARAMS;
is_params = true;
}
}
if (!is_params && p.IsOptional) {
object value = p.RawDefaultValue;
var ptype = types[i];
if ((p.Attributes & ParameterAttributes.HasDefault) != 0 && ptype.Kind != MemberKind.TypeParameter && (value != null || TypeSpec.IsReferenceType (ptype))) {
if (value == null) {
default_value = Constant.CreateConstant (ptype, null, Location.Null);
} else {
default_value = ImportParameterConstant (value);
if (ptype.IsEnum) {
default_value = new EnumConstant ((Constant) default_value, ptype);
}
}
} else if (value == Missing.Value) {
default_value = EmptyExpression.MissingValue;
} else if (value == null) {
default_value = new DefaultValueExpression (new TypeExpression (ptype, Location.Null), Location.Null);
} else if (ptype.BuiltinType == BuiltinTypeSpec.Type.Decimal) {
default_value = ImportParameterConstant (value);
}
}
}
par[i] = new ParameterData (p.Name, mod, default_value);
}
if (varargs != 0) {
par[par.Length - 1] = new ArglistParameter (Location.Null);
types[types.Length - 1] = InternalType.Arglist;
}
return method != null ?
new ParametersImported (par, types, varargs != 0, is_params) :
new ParametersImported (par, types, is_params);
}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:77,代码来源:import.cs
示例5: CreateProperty
//
// Returns null when the property is not valid C# property
//
public PropertySpec CreateProperty (PropertyInfo pi, TypeSpec declaringType, MethodSpec get, MethodSpec set)
{
Modifiers mod = 0;
AParametersCollection param = null;
TypeSpec type = null;
if (get != null) {
mod = get.Modifiers;
param = get.Parameters;
type = get.ReturnType;
}
bool is_valid_property = true;
if (set != null) {
if (set.ReturnType.Kind != MemberKind.Void)
is_valid_property = false;
var set_param_count = set.Parameters.Count - 1;
if (set_param_count < 0) {
set_param_count = 0;
is_valid_property = false;
}
var set_type = set.Parameters.Types[set_param_count];
if (mod == 0) {
AParametersCollection set_based_param;
if (set_param_count == 0) {
set_based_param = ParametersCompiled.EmptyReadOnlyParameters;
} else {
//
// Create indexer parameters based on setter method parameters (the last parameter has to be removed)
//
var data = new IParameterData[set_param_count];
var types = new TypeSpec[set_param_count];
Array.Copy (set.Parameters.FixedParameters, data, set_param_count);
Array.Copy (set.Parameters.Types, types, set_param_count);
set_based_param = new ParametersImported (data, types, set.Parameters.HasParams);
}
mod = set.Modifiers;
param = set_based_param;
type = set_type;
} else {
if (set_param_count != get.Parameters.Count)
is_valid_property = false;
if (get.ReturnType != set_type)
is_valid_property = false;
// Possible custom accessor modifiers
if ((mod & Modifiers.AccessibilityMask) != (set.Modifiers & Modifiers.AccessibilityMask)) {
var get_acc = mod & Modifiers.AccessibilityMask;
if (get_acc != Modifiers.PUBLIC) {
var set_acc = set.Modifiers & Modifiers.AccessibilityMask;
// If the accessor modifiers are not same, do extra restriction checks
if (get_acc != set_acc) {
var get_restr = ModifiersExtensions.IsRestrictedModifier (get_acc, set_acc);
var set_restr = ModifiersExtensions.IsRestrictedModifier (set_acc, get_acc);
if (get_restr && set_restr) {
is_valid_property = false; // Neither is more restrictive
}
if (get_restr) {
mod &= ~Modifiers.AccessibilityMask;
mod |= set_acc;
}
}
}
}
}
}
PropertySpec spec = null;
if (!param.IsEmpty) {
var index_name = declaringType.MemberDefinition.GetAttributeDefaultMember ();
if (index_name == null) {
is_valid_property = false;
} else {
if (get != null) {
if (get.IsStatic)
is_valid_property = false;
if (get.Name.IndexOf (index_name, StringComparison.Ordinal) != 4)
is_valid_property = false;
}
if (set != null) {
if (set.IsStatic)
is_valid_property = false;
if (set.Name.IndexOf (index_name, StringComparison.Ordinal) != 4)
is_valid_property = false;
}
}
if (is_valid_property)
spec = new IndexerSpec (declaringType, new ImportedParameterMemberDefinition (pi, type, param, this), type, param, pi, mod);
}
//.........这里部分代码省略.........
开发者ID:Gobiner,项目名称:ILSpy,代码行数:101,代码来源:import.cs
示例6: CreateFullyResolved
public static ParametersCompiled CreateFullyResolved (IParameterData[] parameters, TypeSpec[] types)
{
return new ParametersCompiled (parameters, types);
}
开发者ID:afaerber,项目名称:mono,代码行数:4,代码来源:parameter.cs
示例7: Create
//
// Imports System.Reflection parameters
//
public static AParametersCollection Create (TypeSpec parent, ParameterInfo [] pi, MethodBase method)
{
int varargs = method != null && (method.CallingConvention & CallingConventions.VarArgs) != 0 ? 1 : 0;
if (pi.Length == 0 && varargs == 0)
return ParametersCompiled.EmptyReadOnlyParameters;
TypeSpec [] types = new TypeSpec [pi.Length + varargs];
IParameterData [] par = new IParameterData [pi.Length + varargs];
bool is_params = false;
for (int i = 0; i < pi.Length; i++) {
ParameterInfo p = pi [i];
Parameter.Modifier mod = 0;
Expression default_value = null;
if (p.ParameterType.IsByRef) {
if ((p.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out)
mod = Parameter.Modifier.OUT;
else
mod = Parameter.Modifier.REF;
//
// Strip reference wrapping
//
types [i] = Import.ImportType (p.ParameterType.GetElementType ());
} else if (i == 0 && method.IsStatic && parent.IsStatic && // TODO: parent.Assembly.IsExtension &&
HasExtensionAttribute (method)) {
mod = Parameter.Modifier.This;
types[i] = Import.ImportType (p.ParameterType);
} else {
types[i] = Import.ImportType (p.ParameterType);
if (i >= pi.Length - 2 && types[i] is ArrayContainer) {
var cattrs = CustomAttributeData.GetCustomAttributes (p);
if (cattrs != null && cattrs.Any (l => l.Constructor.DeclaringType == typeof (ParamArrayAttribute))) {
mod = Parameter.Modifier.PARAMS;
is_params = true;
}
}
if (!is_params && p.IsOptional) {
object value = p.DefaultValue;
if (value == Missing.Value) {
default_value = EmptyExpression.Null;
} else if (value == null) {
default_value = new NullLiteral (Location.Null);
} else {
default_value = Constant.CreateConstant (null, Import.ImportType (value.GetType ()), value, Location.Null);
}
}
}
par [i] = new ParameterData (p.Name, mod, default_value);
}
if (varargs != 0) {
par [par.Length - 1] = new ArglistParameter (Location.Null);
types [types.Length - 1] = InternalType.Arglist;
}
return method != null ?
new ParametersImported (par, types, varargs != 0, is_params) :
new ParametersImported (par, types, is_params);
}
开发者ID:afaerber,项目名称:mono,代码行数:66,代码来源:parameter.cs
示例8: ParametersCollection
public ParametersCollection (IParameterData [] param, Type[] types)
{
this.parameters = param;
this.types = types;
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:5,代码来源:parameter.cs
示例9: Create
//
// Imports SRE parameters
//
public static AParametersCollection Create (ParameterInfo [] pi, MethodBase method)
{
if (pi.Length == 0) {
if (method != null && (method.CallingConvention & CallingConventions.VarArgs) != 0)
return new ParametersCollection (new IParameterData [0], Type.EmptyTypes, method, false);
return Parameters.EmptyReadOnlyParameters;
}
Type [] types = new Type [pi.Length];
IParameterData [] par = new IParameterData [pi.Length];
bool is_params = false;
for (int i = 0; i < types.Length; i++) {
types [i] = TypeManager.TypeToCoreType (pi [i].ParameterType);
ParameterInfo p = pi [i];
Parameter.Modifier mod = 0;
if (types [i].IsByRef) {
if ((p.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out)
mod = Parameter.Modifier.OUT;
else
mod = Parameter.Modifier.REF;
//
// Strip reference wrapping
//
types [i] = TypeManager.GetElementType (types [i]);
} else if (i == 0 && TypeManager.extension_attribute_type != null && method != null && method.IsStatic &&
(method.DeclaringType.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute &&
method.IsDefined (TypeManager.extension_attribute_type, false)) {
mod = Parameter.Modifier.This;
} else if (i >= pi.Length - 2 && types [i].IsArray) {
if (p.IsDefined (TypeManager.param_array_type, false)) {
mod = Parameter.Modifier.PARAMS;
is_params = true;
}
}
par [i] = new ParameterData (p.Name, mod);
}
return method != null ?
new ParametersCollection (par, types, method, is_params) :
new ParametersCollection (par, types);
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:48,代码来源:parameter.cs
示例10: Define
public override bool Define ()
{
if (IsGeneric) {
foreach (TypeParameter type_param in TypeParameters) {
if (!type_param.Resolve (this))
return false;
}
foreach (TypeParameter type_param in TypeParameters) {
if (!type_param.DefineType (this))
return false;
}
}
member_cache = new MemberCache (TypeManager.multicast_delegate_type, this);
// FIXME: POSSIBLY make this static, as it is always constant
//
Type [] const_arg_types = new Type [2];
const_arg_types [0] = TypeManager.object_type;
const_arg_types [1] = TypeManager.intptr_type;
const MethodAttributes ctor_mattr = MethodAttributes.RTSpecialName | MethodAttributes.SpecialName |
MethodAttributes.HideBySig | MethodAttributes.Public;
ConstructorBuilder = TypeBuilder.DefineConstructor (ctor_mattr,
CallingConventions.Standard,
const_arg_types);
ConstructorBuilder.DefineParameter (1, ParameterAttributes.None, "object");
ConstructorBuilder.DefineParameter (2, ParameterAttributes.None, "method");
//
// HACK because System.Reflection.Emit is lame
//
IParameterData [] fixed_pars = new IParameterData [] {
new ParameterData ("object", Parameter.Modifier.NONE),
new ParameterData ("method", Parameter.Modifier.NONE)
};
AParametersCollection const_parameters = new ParametersImported (
fixed_pars,
new Type[] { TypeManager.object_type, TypeManager.intptr_type });
TypeManager.RegisterMethod (ConstructorBuilder, const_parameters);
member_cache.AddMember (ConstructorBuilder, this);
ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
//
// Here the various methods like Invoke, BeginInvoke etc are defined
//
// First, call the `out of band' special method for
// defining recursively any types we need:
if (!Parameters.Resolve (this))
return false;
//
// Invoke method
//
// Check accessibility
foreach (Type partype in Parameters.Types){
if (!IsAccessibleAs (partype)) {
Report.SymbolRelatedToPreviousError (partype);
Report.Error (59, Location,
"Inconsistent accessibility: parameter type `{0}' is less accessible than delegate `{1}'",
TypeManager.CSharpName (partype),
GetSignatureForError ());
return false;
}
}
ReturnType = ReturnType.ResolveAsTypeTerminal (this, false);
if (ReturnType == null)
return false;
ret_type = ReturnType.Type;
if (!IsAccessibleAs (ret_type)) {
Report.SymbolRelatedToPreviousError (ret_type);
Report.Error (58, Location,
"Inconsistent accessibility: return type `" +
TypeManager.CSharpName (ret_type) + "' is less " +
"accessible than delegate `" + GetSignatureForError () + "'");
return false;
}
CheckProtectedModifier ();
if (RootContext.StdLib && TypeManager.IsSpecialType (ret_type)) {
Method.Error1599 (Location, ret_type, Report);
return false;
}
TypeManager.CheckTypeVariance (ret_type, Variance.Covariant, this);
//
// We don't have to check any others because they are all
// guaranteed to be accessible - they are standard types.
//.........这里部分代码省略.........
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:101,代码来源:delegate.cs
示例11: Create
//
// Imports SRE parameters
//
public static AParametersCollection Create (ParameterInfo [] pi, MethodBase method)
{
int varargs = method != null && (method.CallingConvention & CallingConventions.VarArgs) != 0 ? 1 : 0;
if (pi.Length == 0 && varargs == 0)
return ParametersCompiled.EmptyReadOnlyParameters;
Type [] types = new Type [pi.Length + varargs];
IParameterData [] par = new IParameterData [pi.Length + varargs];
bool is_params = false;
PredefinedAttribute extension_attr = PredefinedAttributes.Get.Extension;
PredefinedAttribute param_attr = PredefinedAttributes.Get.ParamArray;
for (int i = 0; i < pi.Length; i++) {
types [i] = TypeManager.TypeToCoreType (pi [i].ParameterType);
ParameterInfo p = pi [i];
Parameter.Modifier mod = 0;
Expression default_value = null;
if (types [i].IsByRef) {
if ((p.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out)
mod = Parameter.Modifier.OUT;
else
mod = Parameter.Modifier.REF;
//
// Strip reference wrapping
//
types [i] = TypeManager.GetElementType (types [i]);
} else if (i == 0 && extension_attr.IsDefined && method != null && method.IsStatic &&
(method.DeclaringType.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute &&
method.IsDefined (extension_attr.Type, false)) {
mod = Parameter.Modifier.This;
} else {
if (i >= pi.Length - 2 && types[i].IsArray) {
if (p.IsDefined (param_attr.Type, false)) {
mod = Parameter.Modifier.PARAMS;
is_params = true;
}
}
if (!is_params && p.IsOptional) {
object value = p.DefaultValue;
if (value == Missing.Value) {
default_value = EmptyExpression.Null;
} else if (value == null) {
default_value = new NullLiteral (Location.Null);
} else {
default_value = Constant.CreateConstant (value.GetType (), value, Location.Null);
}
}
}
par [i] = new ParameterData (p.Name, mod, default_value);
}
if (varargs != 0) {
par [par.Length - 1] = new ArglistParameter (Location.Null);
types [types.Length - 1] = InternalType.Arglist;
}
return method != null ?
new ParametersImported (par, types, varargs != 0, is_params) :
new ParametersImported (par, types);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:67,代码来源:parameter.cs
示例12: ParametersImported
public ParametersImported (IParameterData [] param, Type[] types)
{
this.parameters = param;
this.types = types;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:5,代码来源:parameter.cs
示例13: CreateParameters
//
// Imports System.Reflection parameters
//
AParametersCollection CreateParameters (TypeSpec parent, ParameterInfo[] pi, MethodBase method)
{
int varargs = method != null && (method.CallingConvention & CallingConventions.VarArgs) != 0 ? 1 : 0;
if (pi.Length == 0 && varargs == 0)
return ParametersCompiled.EmptyReadOnlyParameters;
TypeSpec[] types = new TypeSpec[pi.Length + varargs];
IParameterData[] par = new IParameterData[pi.Length + varargs];
bool is_params = false;
for (int i = 0; i < pi.Length; i++) {
ParameterInfo p = pi[i];
Parameter.Modifier mod = 0;
Expression default_value = null;
if (p.ParameterType.IsByRef) {
if ((p.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out)
mod = Parameter.Modifier.OUT;
else
mod = Parameter.Modifier.REF;
//
// Strip reference wrapping
//
var el = p.ParameterType.GetElementType ();
types[i] = ImportType (el, p, 0); // TODO: 1 to be csc compatible
} else if (i == 0 && method.IsStatic && parent.IsStatic && parent.MemberDefinition.DeclaringAssembly.HasExtensionMethod &&
HasExtensionAttribute (CustomAttributeData.GetCustomAttributes (method)) != null) {
mod = Parameter.Modifier.This;
types[i] = ImportType (p.ParameterType);
} else {
types[i] = ImportType (p.ParameterType, p, 0);
if (i >= pi.Length - 2 && types[i] is ArrayContainer) {
if (HasAttribute (CustomAttributeData.GetCustomAttributes (p), typeof (ParamArrayAttribute))) {
mod = Parameter.Modifier.PARAMS;
is_params = true;
}
}
if (!is_params && p.IsOptional) {
object value = p.RawDefaultValue;
var ptype = types[i];
if (((p.Attributes & ParameterAttributes.HasDefault) != 0 && ptype.Kind != MemberKind.TypeParameter)) {
//
// Use value type as int constant can be used for object parameter type
//
var dtype = value == null ? ptype : ImportType (value.GetType ());
default_value = Constant.CreateConstant (null, dtype, value, Location.Null);
} else if (value == Missing.Value) {
default_value = EmptyExpression.MissingValue;
} else {
if (ptype == TypeManager.decimal_type)
default_value = ReadDecimalConstant (CustomAttributeData.GetCustomAttributes (p));
if (default_value == null)
default_value = new DefaultValueExpression (new TypeExpression (ptype, Location.Null), Location.Null);
}
}
}
par[i] = new ParameterData (p.Name, mod, default_value);
}
if (varargs != 0) {
par[par.Length - 1] = new ArglistParameter (Location.Null);
types[types.Length - 1] = InternalType.Arglist;
}
return method != null ?
new ParametersImported (par, types, varargs != 0, is_params) :
new ParametersImported (par, types, is_params);
}
开发者ID:davidwaters,项目名称:mono,代码行数:75,代码来源:import.cs
注:本文中的IParameterData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论