public ImmutableArray <BoundValues> GetValues(BoundProperty currentProperty = null, BoundProperty rootProperty = null, CancellationToken cancellationToken = default) { ArrayBuilder <BoundValues> values = ArrayBuilder <BoundValues> .GetInstance(); this.AddValues(values, currentProperty, rootProperty, cancellationToken); return(values.ToImmutableAndFree()); }
public override void ConvertProperty(BoundProperty from, BoundProperty to) { //var vec = from.Get<Vector3>(); // //to.Set<int>( (int)vec.magnitude ); //base.ConvertProperty() }
public void WhenExistingLegacyRawValueExists_ThenAutomaticallyUpgradesToBindingValue() { var value = "Foo"; var property = new BoundProperty("Name", () => value, s => value = s); Assert.Equal("Foo", property.Settings.Value); Assert.True(value.Trim().StartsWith("{")); }
/// <summary> /// Clear property value /// </summary> /// <param name="notClearProperty">Property which not clear fast filter row</param> public void ClearValue(FieldDescription?notClearProperty) { if (!notClearProperty.HasValue || !BoundProperty.Equals(notClearProperty)) { _isClearing = true; Value = null; } }
public void WhenChangingSettingsValue_ThenAutomaticallySerializesValue() { var value = ""; var property = new BoundProperty("Name", () => value, s => value = s); property.Settings.Value = "Hello"; Assert.NotEqual("", value); }
/// <summary> /// Converts the WinForm control into WiX custom UI control <see cref="T:WixSharp.Control" />. /// </summary> /// <returns> /// Instance of the WixSharp.Control. /// </returns> /// <exception cref="System.ApplicationException">WixTextBox (' + control.Id + ') must have BoundProperty set to non-empty value.</exception> public virtual Wix.Controls.Control ToWControl() { Wix.Controls.Control control = this.ConvertToWControl(ControlType.Edit); if (BoundProperty.IsEmpty()) { throw new ApplicationException("WixTextBox ('" + control.Id + "') must have BoundProperty set to non-empty value."); } return(control); }
public WaveKeyframeDataBinding( BoundProperty boundProperty, BindingMode bindingMode, float srcFrom, float srcTo, float targetFrom, float targetTo ) { m_property = boundProperty; m_mode = bindingMode; m_sourceFrom = srcFrom; m_sourceTo = srcTo; m_targetFrom = targetFrom; m_targetTo = targetTo; }
public void WhenReassigningSettings_ThenSavesNewValue() { var value = ""; var property = new BoundProperty("Name", () => value, s => value = s); var settings = property.Settings; property.Settings = new PropertyBindingSettings { Name = "Name", Value = "Hello" }; Assert.NotEqual("", value); }
/// <inheritdoc /> public void UnbindProperty(BoundProperty obj) { var keys = mPropertyMap .Where(x => ReferenceEquals(x.Value.Target, obj)) .Select(x => x.Key) .ToArray(); foreach (int key in keys) { mPropertyMap.Remove(key); } }
void Ex05() { Given("a property whose type is BoundProperty", () => BoundProperty1 = BoundProperty <int> .Of(1)); Given("a property whose type is BoundProperty", () => BoundProperty2 = BoundProperty <int> .Of(2)); Given("a property whose type is BoundProperty", () => BoundProperty3 = BoundProperty <int> .Of(3)); When("the property binds the given three properties with a converter that converts to the sum of these values", () => Property.Bind(context => (context.GetValueAt <int>(0) + context.GetValueAt <int>(1) + context.GetValueAt <int>(2)).ToString(), BoundProperty1, BoundProperty2, BoundProperty3) ); Then("the value of the property should be the changed value", () => Property.Value == "6"); Then("the value of the first property should not be changed", () => BoundProperty1.Value == 1); Then("the value of the second property should not be changed", () => BoundProperty2.Value == 2); Then("the value of the third property should not be changed", () => BoundProperty3.Value == 3); }
void Ex01() { Given("a property whose value is null", () => Property = new ObservableProperty <string?>(null)); Given("a BoundProperty that binds a given property", () => BoundProperty = BoundProperty <string?> .By(Property)); When("the BoundProperty value changing handler is added", () => BoundProperty.PropertyValueChanging += (_, e) => { OldPropertyValue = e.OldValue; NewPropertyValue = e.NewValue; }); When("the value of the property is changed", () => Property.Value = "Changed"); Then("the old value of the property value changing handler should be the previous value", () => OldPropertyValue == null); Then("the new value of the property value changing handler should be the changed value", () => NewPropertyValue == "Changed"); Then("the value of the BoundProperty should be the changed value", () => Property.Value == "Changed"); }
public ImmutableArray <BoundValues> GetChildValues(BoundProperty currentProperty = null, BoundProperty rootProperty = null, CancellationToken cancellationToken = default) { ArrayBuilder <BoundValues> values = ArrayBuilder <BoundValues> .GetInstance(); foreach (var child in this.ChildBoundNodes) { if (cancellationToken.IsCancellationRequested) { return(ImmutableArray <BoundValues> .Empty); } child.AddValues(values, currentProperty, rootProperty, cancellationToken); } return(values.ToImmutableAndFree()); }
void Ex02() { Given("a property whose value is not null", () => Property = ObservableProperty <string?> .Of("Test")); Given("a BoundProperty that binds a given property", () => BoundProperty = BoundProperty <string?> .By(Property)); When("the property value changing handler in which the value changing is canceled is added", () => Property.PropertyValueChanging += (_, e) => e.Disable()); When("the property value changed handler is added", () => Property.PropertyValueChanged += (_, e) => { OldPropertyValue = e.OldValue; NewPropertyValue = e.NewValue; }); When("the value of the property is changed", () => Property.Value = "Changed"); Then("the property changed event handler should not be called", () => OldPropertyValue == null && NewPropertyValue == null); Then("the value of the BoundProperty should not be changed", () => BoundProperty.Value == "Test"); }
public void WhenReassigningSettings_ThenDetachesChangesFromOlder() { var value = ""; var property = new BoundProperty("Name", () => value, s => value = s); var settings = property.Settings; property.Settings = new PropertyBindingSettings { Name = "Name", Value = "Hello" }; settings.Value = "Foo"; Assert.False(value.Contains("Foo")); }
/// <summary> /// Converts the WinForm control into WiX custom UI control <see cref="T:WixSharp.Control" />. /// </summary> /// <returns> /// Instance of the WixSharp.Control. /// </returns> /// <exception cref="System.ApplicationException">WixCheckBox (' + control.Id + ') must have BoundProperty set to non-empty value.</exception> public virtual Wix.Controls.Control ToWControl() { Wix.Controls.Control control = this.ConvertToWControl(ControlType.CheckBox); //It is tempting to allow WiX compiler report the problem. However WiX is not reliable with the error reporting. //For example it does it for "CheckBox" but not for "Edit" //Note that control.Name is a better identity value than this.Name, which can be empty. if (BoundProperty.IsEmpty()) { throw new ApplicationException("WixCheckBox ('" + control.Id + "') must have BoundProperty set to non-empty value."); } if (!CheckBoxValue.IsEmpty()) { control.AttributesDefinition += ";CheckBoxValue=" + CheckBoxValue; } return(control); }
public void InitializeContext() { this.property = new BoundProperty("Property", () => this.Property, s => this.Property = s); }
private void GetFromRoute <TRequest>(TRequest mediatorRequest, RouteValueDictionary routeParams, BoundProperty property) { if (routeParams.ContainsKey(property.Name)) { GetSetter(property.Property).SetValue(property.Property, mediatorRequest, routeParams[property.Name].ToString()); } }
public BoundPropertySpec_Binding_OneWay() { Property1 = BoundProperty <string> .Of("Test1"); Property2 = ObservableProperty <string> .Of("Test2"); }
/// <summary> /// Converts the specified value to the bound property. /// </summary> /// <typeparam name="T">The type of the property value.</typeparam> /// <param name="target">The object that is converted to the bound property.</param> /// <returns>The instance of the <see cref="BoundProperty{T}"/> class.</returns> public static BoundProperty <T> ToBoundProperty <T>(this T target) => BoundProperty <T> .Of(target);
public virtual void AddValues(ArrayBuilder <BoundValues> values, BoundProperty currentProperty = null, BoundProperty rootProperty = null, CancellationToken cancellationToken = default) { }
public BoundPropertySpec_Binding_OneWayWithConverter() { Property1 = BoundProperty <string> .Of("Test1"); Property2 = ObservableProperty <int> .Of(3); }
public void WhenInitializingSettings_ThenHasPropertyName() { var property = new BoundProperty("Name", () => "", s => { }); Assert.Equal("Name", property.Settings.Name); }
private void GetFromQuery <TRequest>(TRequest mediatorRequest, IQueryCollection queryString, BoundProperty property) { if (queryString.ContainsKey(property.Name)) { GetSetter(property.Property).SetValue(property.Property, mediatorRequest, queryString[property.Name].ToString()); } }
public BoundPropertySpec_Binding_MultiBinding() { Property = BoundProperty <string> .Of("Test1"); }
public void WhenValueIsEmpty_ThenSettingsInitializedEmpty() { var property = new BoundProperty("Name", () => "", s => { }); Assert.Equal("", property.Settings.Value); }
/// <inheritdoc /> public void BindProperty(int hash, BoundProperty prop) { mPropertyMap[hash] = new WeakReference(prop); }
private void GetFromForm <TRequest>(TRequest mediatorRequest, IFormCollection form, BoundProperty property) { if (typeof(IEnumerable <IFormFile>).IsAssignableFrom(property.Property.PropertyType)) { property.Property.SetValue(mediatorRequest, form.Files ?? (IFormFileCollection) new List <IFormFile>()); } else { if (form.ContainsKey(property.Name)) { GetSetter(property.Property).SetValue(property.Property, mediatorRequest, form[property.Name].ToString()); } } }