/// <summary> /// Creates an object binding for the given path. /// </summary> /// <typeparam name="InputType">Type that is received by the created object binding.</typeparam> /// <typeparam name="OutputType">Type that is returned by the created object binding.</typeparam> /// <param name="inputObject">Object that is bound.</param> /// <param name="fieldName">Name of the databinding that will be used for path creation.</param> /// <returns>Created binding's setup class.</returns> public FieldBasedBindingSetup <InputType, OutputType> Bind <InputType, OutputType>(InputType inputObject, string fieldName) { FieldBasedBinding <InputType, OutputType> newBinding = new FieldBasedBinding <InputType, OutputType>(inputObject); PathElement pe = new PathElement(fieldName); newBinding.LocalPath = pe; AddBinding(newBinding); return(new FieldBasedBindingSetup <InputType, OutputType>(newBinding)); }
/// <summary> /// Creates an object binding for the given path. Will automatically create default getter & setter. /// </summary> /// <remarks> /// This is shortcut for the fully type specified version. /// </remarks> /// <typeparam name="InputOutputType">Type of in- and output of the created object binding.</typeparam> /// <param name="inputObject">Object that is bound.</param> /// <param name="fieldName">Name of the databinding that will be used for path creation.</param> /// <returns>Created binding's setup class.</returns> public FieldBasedBindingSetup <InputOutputType, InputOutputType> Bind <InputOutputType>(InputOutputType inputObject, string fieldName) { FieldBasedBinding <InputOutputType, InputOutputType> newBinding = new FieldBasedBinding <InputOutputType, InputOutputType>(inputObject); // Automatically create setter / getter newBinding.SetGetter((val) => val); newBinding.SetSetter((ref InputOutputType val, InputOutputType newVal) => val = newVal); PathElement pe = new PathElement(fieldName); newBinding.LocalPath = pe; AddBinding(newBinding); return(new FieldBasedBindingSetup <InputOutputType, InputOutputType>(newBinding)); }