本文整理汇总了C#中System.Reflection.Binder类的典型用法代码示例。如果您正苦于以下问题:C# Binder类的具体用法?C# Binder怎么用?C# Binder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Binder类属于System.Reflection命名空间,在下文中一共展示了Binder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InternalInvoke
internal Object InternalInvoke(Object obj,BindingFlags invokeAttr,Binder binder, Object[] parameters,CultureInfo culture, bool verifyAccess)
{
// Do they want us to process Default Values?
if (parameters != null && parameters.Length > 0) {
int length = parameters.Length;
ParameterInfo[] p = null;
for (int i=0;i<length;i++) {
// if the parameter is missing we need to get a default value.
if (parameters[i] == Type.Missing) {
if (p == null) {
p = GetParameters();
// If the parameters and the number of parameters passed are
// not the same then we need to exit.
if (p.Length != length)
throw new ArgumentException(Environment.GetResourceString("Arg_ParmCnt"),"parameters");
}
if (p[i].DefaultValue == System.DBNull.Value)
throw new ArgumentException(Environment.GetResourceString("Arg_VarMissNull"),"parameters");
parameters[i] = p[i].DefaultValue;
}
}
BCLDebug.Assert(this!=null, "[RuntimeMethodInfo.Invoke]this!=null");
Object[] args = new Object[length];
for (int index = 0; index < length; index++)
args[index] = parameters[index];
Object retValue = InternalInvoke(obj,invokeAttr,binder,args,culture,binder == Type.DefaultBinder, null, verifyAccess);
for (int index = 0; index < length; index++)
parameters[index] = args[index];
return retValue;
}
return InternalInvoke(obj,invokeAttr,binder,parameters,culture,binder == Type.DefaultBinder, null, verifyAccess);
}
示例2: LocalFunctionSymbol
public LocalFunctionSymbol(
Binder binder,
Symbol containingSymbol,
LocalFunctionStatementSyntax syntax)
{
_syntax = syntax;
_containingSymbol = containingSymbol;
_declarationModifiers =
DeclarationModifiers.Private |
DeclarationModifiers.Static |
syntax.Modifiers.ToDeclarationModifiers();
var diagnostics = DiagnosticBag.GetInstance();
if (_syntax.TypeParameterList != null)
{
binder = new WithMethodTypeParametersBinder(this, binder);
_typeParameters = MakeTypeParameters(diagnostics);
}
else
{
_typeParameters = ImmutableArray<TypeParameterSymbol>.Empty;
}
if (IsExtensionMethod)
{
diagnostics.Add(ErrorCode.ERR_BadExtensionAgg, Locations[0]);
}
_binder = binder;
_refKind = (syntax.ReturnType.Kind() == SyntaxKind.RefType) ? RefKind.Ref : RefKind.None;
_diagnostics = diagnostics.ToReadOnlyAndFree();
}
示例3: InvokeMember
public static object InvokeMember(
string file,
string type,
string member,
BindingFlags invokeAttr,
Binder binder,
params object[] args
)
{
object result = null;
try
{
AppDomain domain = null;
try
{
domain = AppDomain.CreateDomain(DomainName);
DynamicInvokeMember loader = (DynamicInvokeMember)domain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(DynamicInvokeMember).FullName);
result = loader.InvokeMemberInternal(file, type, member, invokeAttr, binder, args);
}
catch { throw; }
finally
{
if (domain != null)
{
AppDomain.Unload(domain);
}
}
}
catch { throw; }
return result;
}
示例4: GetValue
public override Object GetValue(Object obj,BindingFlags invokeAttr,Binder binder,Object[] index,CultureInfo culture)
{
MethodInfo m = InternalGetter(true, false);
if (m == null)
throw new ArgumentException(System.Environment.GetResourceString("Arg_GetMethNotFnd"));
return m.Invoke(obj,invokeAttr,binder,index,culture);
}
示例5: Invoke
public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, System.Globalization.CultureInfo culture)
{
Type[] args = new Type[parameters.Length];
for (var i = 0; i < args.Length; i++)
args[i] = parameters[i] as Type;
return TypeProxy.GetConstructor(target.MakeGenericType(args));
}
示例6: CheckArguments
internal object[] CheckArguments(object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
{
int num = (parameters != null) ? parameters.Length : 0;
object[] objArray = new object[num];
ParameterInfo[] parametersNoCopy = null;
for (int i = 0; i < num; i++)
{
object defaultValue = parameters[i];
RuntimeType type = sig.Arguments[i];
if (defaultValue == Type.Missing)
{
if (parametersNoCopy == null)
{
parametersNoCopy = this.GetParametersNoCopy();
}
if (parametersNoCopy[i].DefaultValue == DBNull.Value)
{
throw new ArgumentException(Environment.GetResourceString("Arg_VarMissNull"), "parameters");
}
defaultValue = parametersNoCopy[i].DefaultValue;
}
objArray[i] = type.CheckValue(defaultValue, binder, culture, invokeAttr);
}
return objArray;
}
示例7: CreateInstance
/// <include file='doc\Activator.uex' path='docs/doc[@for="Activator.CreateInstance1"]/*' />
static public Object CreateInstance(Type type,
BindingFlags bindingAttr,
Binder binder,
Object[] args,
CultureInfo culture,
Object[] activationAttributes)
{
if (type == null)
throw new ArgumentNullException("type");
if (type is System.Reflection.Emit.TypeBuilder)
throw new NotSupportedException(Environment.GetResourceString( "NotSupported_CreateInstanceWithTypeBuilder" ));
// If they didn't specify a lookup, then we will provide the default lookup.
if ((bindingAttr & (BindingFlags) LookupMask) == 0)
bindingAttr |= Activator.ConstructorDefault;
try {
RuntimeType rt = (RuntimeType) type.UnderlyingSystemType;
return rt.CreateInstanceImpl(bindingAttr,binder,args,culture,activationAttributes);
}
catch (InvalidCastException) {
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),"type");
}
}
示例8:
PropertyInfo IReflect.GetProperty(string name, BindingFlags bindingAttr,
Binder binder, Type returnType, Type[] types,
ParameterModifier[] modifiers)
{
return this.GetType().GetProperty(name, bindingAttr, binder,
returnType, types, modifiers);
}
示例9: GetValue
public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
{
if (this.OnGetValue != null)
{
return this.OnGetValue(this, obj);
}
return null;
}
示例10: GetPropertyImpl
protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
{
PropertyInfo info = base.GetPropertyImpl(name, bindingAttr, binder, returnType, types, modifiers);
if (name == "ItemTemplate")
info = new FakePropertyInfo(info, this.listViewItemType);
return info;
}
示例11: InvokeMember
internal object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)
{
Type type = base.GetType();
if (!type.IsCOMObject)
{
throw new InvalidOperationException(Environment.GetResourceString("Arg_InvokeMember"));
}
return type.InvokeMember(name, invokeAttr, binder, this, args, modifiers, culture, namedParameters);
}
示例12: GetValue
public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
{
if (index !=null && index.Length > 0)
{
return Impromptu.InvokeGetIndex(obj, index);
}
return _cachedGet.Invoke(obj);
}
示例13: Invoke
public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
if (parameters[0] == null)
{
return Activator.CreateInstance(base.resultType);
}
object operandValue = base.actualMethod.Invoke(null, invokeAttr, binder, parameters, culture);
return Executor.AdjustType(base.actualMethod.ReturnType, operandValue, base.resultType);
}
示例14: Invoke
public override object Invoke(
object obj,
BindingFlags invokeAttr,
Binder binder,
object[] parameters,
CultureInfo culture)
{
throw new NotImplementedException();
}
示例15: GetMethodValidated
internal static MethodInfo GetMethodValidated(this Type type, string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
{
MethodInfo mi = type.GetMethod(name, bindingAttr, binder, types, modifiers);
if (!mi.MatchesArgumentTypes(types))
{
return null;
}
return mi;
}