public DataBinder(System.Action <T> validateCallback, System.Action <T> bindCallback, System.Action <T> unbindCallback) { self = this; OnValidateData = validateCallback; OnBindData = bindCallback; OnUnbindData = unbindCallback; }
/// <summary> /// Subscribe binder to events receiving. /// </summary> /// <param name="binder">Binder instance.</param> public void Subscribe(IDataBinder binder) { if (binder == null) { throw new ArgumentException("binder"); } if (string.IsNullOrEmpty(binder.BindedSource)) { throw new ArgumentException("binder.Source"); } if (string.IsNullOrEmpty(binder.BindedProperty)) { throw new ArgumentException("binder.Property"); } var holder = GetSource(binder.BindedSource, true); BindedPropertyInfo propInfo; if (!holder.Properties.TryGetValue(binder.BindedProperty, out propInfo)) { propInfo = new BindedPropertyInfo(); holder.Properties[binder.BindedProperty] = propInfo; } if (!propInfo.Listeners.Contains(binder)) { propInfo.Listeners.Add(binder); } }
private void EnsureBinderExists() { if (binder == null) { binder = CreateBinder(); } }
static void Bench(IDataBinder <Record> binder, DbDataReader reader) { while (reader.Read()) { var item = new Record(); binder.Bind(reader, item); } }
/// <summary> /// Sets the binder for a slot. /// </summary> /// <param name="slot">The slot.</param> /// <param name="binder">The binder.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="slot"/> /// or <paramref name="binder"/> is null.</exception> public void SetSlotBinder(ISlotInfo slot, IDataBinder binder) { if (slot == null) throw new ArgumentNullException("slot"); if (binder == null) throw new ArgumentNullException("binder"); slotBinders[slot] = binder; }
public void Dispose() { Data = null; mRefresh = false; OnValidateData = null; OnBindData = null; OnUnbindData = null; self = null; }
public void Init() { binder = new DataBinder(); builder = new TreeBuilder(); CultureInfo en = CultureInfo.CreateSpecificCulture("en"); Thread.CurrentThread.CurrentCulture = en; Thread.CurrentThread.CurrentUICulture = en; }
public void Init() { binder = new DataBinder(); builder = new TreeBuilder(); binder.Validator = new ValidatorRunner(new CachedValidationRegistry()); CultureInfo en = CultureInfo.CreateSpecificCulture("en"); Thread.CurrentThread.CurrentCulture = en; Thread.CurrentThread.CurrentUICulture = en; }
/// <summary> /// Sets the binder for a slot. /// </summary> /// <param name="slot">The slot.</param> /// <param name="binder">The binder.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="slot"/> /// or <paramref name="binder"/> is null.</exception> public void SetSlotBinder(ISlotInfo slot, IDataBinder binder) { if (slot == null) { throw new ArgumentNullException("slot"); } if (binder == null) { throw new ArgumentNullException("binder"); } slotBinders[slot] = binder; }
/// <summary> /// Binds the model object using a castle IDataBinder /// </summary> /// <param name="controllerContext"></param> /// <param name="bindingContext">The current binding context</param> /// <returns>A ModelBinderResult containing the bound object</returns> public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { IDataBinder binder = LocateBinder(controllerContext); string modelName = Prefix ?? bindingContext.ModelName; var tree = new TreeBuilder().BuildSourceNode(GetStore(controllerContext)); if (tree.GetChildNode(modelName) == null) { return(null); } object instance = binder.BindObject(bindingContext.ModelType, modelName, Exclude, null, tree); return(instance); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { IDataBinder dg = context.Instance as IDataBinder; if (dg != null) { //field list editing dlgPropFields dlg1 = dg.GetFieldsDialog(); if (dlg1 != null) { if (edSvc.ShowDialog(dlg1) == System.Windows.Forms.DialogResult.OK) { dg.SetFieldsAfterFieldsDialog(dlg1.fields); } } } else { EasyQuery qry = context.Instance as EasyQuery; if (qry != null) { //field list editing dlgPropFields dlg1 = qry.GetFieldsDialog(); if (dlg1 != null) { if (edSvc.ShowDialog(dlg1) == System.Windows.Forms.DialogResult.OK) { value = dlg1.fields; } } } } } } return(value); }
public void TypeConverterBinding() { var args = new NameValueCollection(); args.Add("Comp.Type1", "validvalue"); var instance = (Comp)binder.BindObject(typeof(Comp), "Comp", builder.BuildSourceNode(args)); Assert.IsNotNull(instance); Assert.IsNotNull(instance.Type1); Assert.IsNull(instance.Type2); args = new NameValueCollection(); args.Add("Comp.Nonsense", "validvalue"); binder = new DataBinder(); instance = (Comp)binder.BindObject(typeof(Comp), "Comp", builder.BuildSourceNode(args)); Assert.IsNotNull(instance); Assert.IsNull(instance.Type1); Assert.IsNull(instance.Type2); }
/// <summary> /// Unsubscribe binder from events receiving. /// </summary> /// <param name="binder">Binder instance.</param> public void Unsubscribe(IDataBinder binder) { if (binder == null || string.IsNullOrEmpty(binder.BindedSource) || string.IsNullOrEmpty(binder.BindedProperty)) { return; } var holder = GetSource(binder.BindedSource); if (holder != null) { BindedPropertyInfo propInfo; if (holder.Properties.TryGetValue(binder.BindedProperty, out propInfo)) { var idx = propInfo.Listeners.IndexOf(binder); if (idx != -1) { propInfo.Listeners.RemoveAt(idx); } } } }
/// <summary> /// Binds the instance errors. /// </summary> /// <param name="validatorExposer">The validator exposer.</param> /// <param name="binder">The binder.</param> /// <param name="instance">The instance.</param> protected virtual void BindInstanceErrors(IValidatorAccessor validatorExposer, IDataBinder binder, object instance) { if (instance != null) { validatorExposer.BoundInstanceErrors[instance] = binder.ErrorList; } }
/// <summary> /// Configures the validator. /// </summary> /// <param name="validatorExposer">The validator exposer.</param> /// <param name="binder">The binder.</param> protected virtual void ConfigureValidator(IValidatorAccessor validatorExposer, IDataBinder binder) { if (validate && validatorExposer == null) { throw new MonoRailException("DataBind wants to validate, but controller does not seem to implement IValidatorAccessor interface"); } if (validate) { binder.Validator = validatorExposer.Validator; } else { binder.Validator = null; } }
public void Evaluate(IDataBinder reader, IDataBinder writer) { throw new NotImplementedException(); }
public IlExpressionEmitNodeVisitor(IDataBinder dataBinder, IHelperBinder helperBinder) { _dataBinder = dataBinder; }
/// <summary> /// Initializes a new instance of the <see cref="WizardStepPage"/> class. /// </summary> /// <param name="binder">The binder.</param> public WizardStepPage(IDataBinder binder) : base(binder) { }
public void Init() { binder = new DataBinder(); }
/// <remarks> /// The optimization relies on two graph-to-graph transformations. /// First, the automatic differentiation which provides parameter /// updates to be obtained from every single input. Second, the /// minibatching which provides a more granular and more efficient /// way to compute the parameter updates. /// </remarks> public Flow Optimize(Graph graph, IDataBinder dataSource) { throw new NotImplementedException(); }
/// <summary> /// Populates the validator error summary. /// </summary> /// <param name="validatorExposer">The validator exposer.</param> /// <param name="binder">The binder.</param> /// <param name="instance">The instance.</param> protected virtual void PopulateValidatorErrorSummary(IValidatorAccessor validatorExposer, IDataBinder binder, object instance) { if (validate) { validatorExposer.PopulateValidatorErrorSummary(instance, binder.GetValidationSummary(instance)); } }
/// <summary> /// Populates the validator error summary. /// </summary> /// <param name="controller">The controller.</param> /// <param name="binder">The binder.</param> /// <param name="instance">The instance.</param> protected void PopulateValidatorErrorSummary(SmartDispatcherController controller, IDataBinder binder, object instance) { if (validate) { controller.PopulateValidatorErrorSummary(instance, binder); } }
public void Add(IDataBinder db) { binderList.Add(db); }
public BaseController(IDataBinder binder) : base(binder) { }
/// <summary> /// Binds the instance errors. /// </summary> /// <param name="controller">The controller.</param> /// <param name="binder">The binder.</param> /// <param name="instance">The instance.</param> protected void BindInstanceErrors(SmartDispatcherController controller, IDataBinder binder, object instance) { if (instance != null) { controller.BoundInstanceErrors[instance] = binder.ErrorList; } }
/// <summary> /// Configures the validator. /// </summary> /// <param name="controller">The controller.</param> /// <param name="binder">The binder.</param> protected void ConfigureValidator(SmartDispatcherController controller, IDataBinder binder) { if (validate) { binder.Validator = controller.Validator; } else { binder.Validator = null; } }
public void TypeConverterBinding() { var args = new NameValueCollection(); args.Add("Comp.Type1", "validvalue"); var instance = (Comp) binder.BindObject(typeof (Comp), "Comp", builder.BuildSourceNode(args)); Assert.IsNotNull(instance); Assert.IsNotNull(instance.Type1); Assert.IsNull(instance.Type2); args = new NameValueCollection(); args.Add("Comp.Nonsense", "validvalue"); binder = new DataBinder(); instance = (Comp) binder.BindObject(typeof (Comp), "Comp", builder.BuildSourceNode(args)); Assert.IsNotNull(instance); Assert.IsNull(instance.Type1); Assert.IsNull(instance.Type2); }
/// <summary> /// Initializes a new instance of the <see cref="SmartDispatcherController"/> class. /// </summary> /// <param name="binder">The binder.</param> protected SmartDispatcherController(IDataBinder binder) { this.binder = binder; }
public EmitNodeVisitor(IDataBinder dataBinder, IHelperBinder helperBinder) : this(new EmitExpressionVisitor(dataBinder, helperBinder)) { }
public DataBinder() { self = this; }