public FallbackCreateInstance ( |
||
target | The target of the dynamic create operation. | |
args | The arguments of the dynamic create operation. | |
return |
public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { var constructors = ReflType.GetConstructors(); var ctors = constructors.Where(c => c.GetParameters().Length == args.Length); var res = new List<ConstructorInfo>(); foreach (var c in ctors) { if (RuntimeHelpers.ParametersMatchArguments(c.GetParameters(), args)) { res.Add(c); } } if (res.Count == 0) { // Binders won't know what to do with TypeModels, so pass the // RuntimeType they represent. The binder might not be Sympl's. return binder.FallbackCreateInstance( RuntimeHelpers.GetRuntimeTypeMoFromModel(this), args); } // For create instance of a TypeModel, we can create a instance // restriction on the MO, hence the true arg. var restrictions = RuntimeHelpers.GetTargetArgsRestrictions(this, args, true); var ctorArgs = RuntimeHelpers.ConvertArguments(args, res[0].GetParameters()); return new DynamicMetaObject( // Creating an object, so don't need EnsureObjectResult. Expression.New(res[0], ctorArgs), restrictions); }
public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { Fallback fallback = null; if (!this.IsOverridden("TryCreateInstance")) { return(base.BindCreateInstance(binder, args)); } if (fallback == null) { fallback = e => binder.FallbackCreateInstance(this, args, e); } return(this.CallMethodWithResult("TryCreateInstance", binder, GetArgArray(args), fallback)); }
/// <summary> /// Performs the binding of the dynamic create instance operation. /// </summary> /// <param name="binder">An instance of the <see cref="CreateInstanceBinder"/> that represents the details of the dynamic operation.</param> /// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the create instance operation.</param> /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns> public virtual DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { ContractUtils.RequiresNotNull(binder, "binder"); return(binder.FallbackCreateInstance(this, args)); }
public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { if (IsOverridden("TryCreateInstance")) { return CallMethodWithResult("TryCreateInstance", binder, DynamicMetaObject.GetExpressions(args), (e) => binder.FallbackCreateInstance(this, args, e)); } return base.BindCreateInstance(binder, args); }
public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { if (IsOverridden("TryCreateInstance")) { return(CallMethodWithResult("TryCreateInstance", binder, DynamicMetaObject.GetExpressions(args), (e) => binder.FallbackCreateInstance(this, args, e))); } return(base.BindCreateInstance(binder, args)); }
/// <summary> /// Performs the binding of the dynamic create instance operation. /// </summary> /// <param name="binder">An instance of the <see cref="CreateInstanceBinder"/> that represents the details of the dynamic operation.</param> /// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the create instance operation.</param> /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns> public virtual DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackCreateInstance(this, args); }
/// <summary> /// Performs the binding of the dynamic create instance operation. /// </summary> /// <param name="binder">An instance of the <see cref="CreateInstanceBinder"/> that represents the details of the dynamic operation.</param> /// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the create instance operation.</param> /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns> public virtual DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { ArgumentNullException.ThrowIfNull(binder); return(binder.FallbackCreateInstance(this, args)); }
public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { Fallback fallback = null; if (!this.IsOverridden("TryCreateInstance")) { return base.BindCreateInstance(binder, args); } if (fallback == null) { fallback = e => binder.FallbackCreateInstance(this, args, e); } return this.CallMethodWithResult("TryCreateInstance", binder, GetArgArray(args), fallback); }
/// <summary> /// Performs the binding of the dynamic create instance operation. /// </summary> /// <param name="binder"> /// An instance of the <see cref="T:System.Dynamic.CreateInstanceBinder" /> that represents the details of the dynamic operation. /// </param> /// <param name="args"> /// An array of <see cref="T:System.Dynamic.DynamicMetaObject" /> instances - arguments to the create instance operation. /// </param> /// <returns> /// The new <see cref="T:System.Dynamic.DynamicMetaObject" /> representing the result of the binding. /// </returns> public override DynamicMetaObject BindCreateInstance( CreateInstanceBinder binder, DynamicMetaObject[] args ) { return ApplyBinding( meta => meta.BindCreateInstance( binder, args ), ( target, errorSuggestion ) => binder.FallbackCreateInstance( target, args, errorSuggestion ) ); }
public override DynamicMetaObject BindCreateInstance( CreateInstanceBinder binder, DynamicMetaObject[] args ) { return binder.FallbackCreateInstance( _baseMetaObject, args, AddTypeRestrictions( _metaObject.BindCreateInstance( binder, args ) ) ); }