Beispiel #1
0
 static void DefaultUpdateTarget(IPropertyBinding binding, ChangeSource change)
 {
     if (!binding.Target.IsReadOnly)
     {
         binding.Target.Value = binding.Source.Value;
     }
 }
Beispiel #2
0
 public void ParameterChanged(IPropertyBinding parameter)
 {
     if (!this.modifiedParameters.Contains(parameter))
     {
         this.modifiedParameters.Add(parameter);
     }
 }
        public static string GetDebugInfo(this IPropertyBinding binding)
        {
            var builder = new StringBuilder();

            builder.AppendFormat("{0}------------------------------------ PropertyBinding ------------------------------------{1}", CodeInterfaceExtensions.Prefix, CodeInterfaceExtensions.DoubleSuffix);
            builder.AppendFormat("{0}Name: {1}{2}", CodeInterfaceExtensions.Prefix, binding.PropertyBindingName, CodeInterfaceExtensions.Suffix);
            builder.AppendFormat("{0}BindingMode: {1}{2}", CodeInterfaceExtensions.Prefix, Enum <BindingMode> .GetName(binding.BindingMode), CodeInterfaceExtensions.Suffix);

            if (binding.BindingSource is IBindingSource)
            {
                var bindingSource = (IBindingSource)binding.BindingSource;

                builder.AppendFormat("{0}BindingSourceType: BindingSource{1}", CodeInterfaceExtensions.Prefix, CodeInterfaceExtensions.Suffix);
                builder.AppendFormat("{0}IsSearchable: {1}{2}", CodeInterfaceExtensions.Prefix, bindingSource.IsSearchable ? "true" : "false", CodeInterfaceExtensions.Suffix);

                if (binding.Property != null)
                {
                    builder.AppendFormat("{0}{1}****************** BindingProperty ******************{2}", CodeInterfaceExtensions.NewLine, CodeInterfaceExtensions.Prefix, CodeInterfaceExtensions.DoubleSuffix);
                    builder.Append(binding.Property.GetDebugInfo());
                    builder.AppendFormat("{0}{1}*****************************************************{2}", CodeInterfaceExtensions.NewLine, CodeInterfaceExtensions.Prefix, CodeInterfaceExtensions.DoubleSuffix);
                }

                builder.AppendFormat("{0}{1}****************** BindingAttribute ******************{2}", CodeInterfaceExtensions.NewLine, CodeInterfaceExtensions.Prefix, CodeInterfaceExtensions.DoubleSuffix);
                builder.Append(bindingSource.BindingAttribute.GetDebugInfo());
                builder.AppendFormat("{0}{1}*****************************************************{2}", CodeInterfaceExtensions.NewLine, CodeInterfaceExtensions.Prefix, CodeInterfaceExtensions.DoubleSuffix);
            }
            else
            {
                Debugger.Break();
            }

            builder.AppendFormat("{0}{1}----------------------------------------------------------------------------------{2}", CodeInterfaceExtensions.NewLine, CodeInterfaceExtensions.Prefix, CodeInterfaceExtensions.Suffix);

            return(builder.ToString());
        }
Beispiel #4
0
 public ProductsPeek()
     : base(typeof(ProductCollectionViewModel))
 {
     InitializeComponent();
     entitiesBinding = mvvmContext.SetBinding(gridControl, g => g.DataSource, "Entities");
     presenterCore   = CreatePresenter();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseSettingViewModel{TValue}"/> class.
        /// </summary>
        /// <param name="binding">The underlying PropertyBinding.</param>
        protected BaseSettingViewModel(IPropertyBinding <TValue> binding)
        {
            this.binding = binding;

            this.binding.ValueChanged += this.Binding_ValueChanged;
            this.Name = binding.Name;
        }
Beispiel #6
0
 public void AddBinding(IPropertyBinding binding)
 {
     if (!this.bindings.Contains(binding))
     {
         this.bindings.Add((IListBinding <Type>)binding);
     }
 }
Beispiel #7
0
 public OneWayPropertyBinding(IPropertyBinding <TSource, TTarget, TTargetProperty> propertyBinding, Expression <Func <TSource, TSourceProperty> > sourcePropertyExpression) :
     base(propertyBinding)
 {
     this.sourcePropertyExpression = sourcePropertyExpression;
     this.getSourceProperty        = sourcePropertyExpression.Compile();
     this.sourceRootNode           = sourcePropertyExpression.AsObservedNode();
     this.sourceRootNode.Observe(this.Source, this.OnSourceChanged);
 }
Beispiel #8
0
        public static PropertyBindingSourceBuilder <T> Property <T>(this BindingList list,
                                                                    IPropertyBinding binding)
        {
            var builder = Create <T>(binding);

            list.Add(builder.Binding);
            return(builder);
        }
Beispiel #9
0
        private static void AssertCustomSymbol(IPropertyBinding binding, IAssertionToolbox toolbox)
        {
            toolbox.BindingSet.RunBindingInitializer();
            var expected = toolbox.RunDefaultAssertions(binding);
            var text     = binding.Target.GetValue("_text");

            Assert.That(text, Is.EqualTo(expected));
        }
Beispiel #10
0
 public void InternalSet(Type obj, IPropertyBinding binding)
 {
     this._value = obj;
     for (int j = this.bindings.Count - 1; j >= 0; j = Math.Min(this.bindings.Count - 1, j - 1))
     {
         IPropertyBinding b = this.bindings[j];
         if (b != binding)
         {
             b.OnChanged(this);
         }
     }
 }
        public TwoWayPropertyBinding(IPropertyBinding <TSource, TTarget, TTargetProperty> propertyBinding, Expression <Func <TSource, TSourceProperty> > sourcePropertyExpression) :
            base(propertyBinding)
        {
            Check.NotNull(sourcePropertyExpression, nameof(sourcePropertyExpression));

            this.isBinding      = false;
            this.sourceProperty = sourcePropertyExpression.GetBindingExpression(this.Source);
            this.sourceRootNode = sourcePropertyExpression.AsObservedNode();
            this.sourceRootNode.Observe(this.Source, this.OnSourceChanged);

            this.targetPropertyChangedWeakEventHandler = this.CreateHandlerForFirstExistingEvent(this.Target, this.targetProperty.Name + "Changed", "EditingDidEnd", "ValueChanged", "Changed");
        }
        public FallbackSettingsViewModel(IElement element)
        {
            this.Element = element;

            this.Settings = new ObservableCollection <ISettingViewModel>(element.GetPropertyBindings().Select <IPropertyBinding, ISettingViewModel>(
                                                                             bind =>
                                                                             bind switch
            {
                IPropertyBinding <string> b => (ISettingViewModel) new StringSettingViewModel(b),
                IPropertyBinding <double> b => (ISettingViewModel) new DoubleSettingViewModel(b),
                IPropertyBinding <int> b => (ISettingViewModel) new IntSettingViewModel(b),
                IPropertyBinding b => new ObjectSettingsViewModel(b)
            }));
Beispiel #13
0
            public IPropertyBinding AddInstanceMatrixParameter(string name)
            {
                IPropertyBinding binding = null;

                if (this.parameters.TryGetValue(name, out binding))
                {
                    return(binding);
                }

                binding = new Binding <Matrix[]>(this.GetMatrixArrayParameter(name), () => this.instances.Select(x => x.getParameterValue <Matrix>(name)).ToArray());
                this.parameters.Add(name, binding);
                this.Add(binding);
                return(binding);
            }
 public Quotes()
     : base(typeof(QuoteCollectionViewModel))
 {
     InitializeComponent();
     ConfigurePivot();
     CollectionUIViewModel = DevExpress.Mvvm.POCO.ViewModelSource.Create <CollectionUIViewModel>();
     //
     entitiesBinding = mvvmContext.SetBinding(pivotGridControl, p => p.DataSource, "Entities");
     OnReloadEntities();
     ViewModel.Reload += ViewModel_Reload;
     ViewModel.EntitiesCountChanged += ViewModel_EntitiesCountChanged;
     //
     BindCommands();
     //
     InitViewKind();
     InitViewLayout();
     InitEditors();
 }
Beispiel #15
0
        public Property <Matrix> GetMatrixParameter(string name)
        {
            IProperty test = null;

            if (this.parameters.TryGetValue(name, out test))
            {
                return((Property <Matrix>)test);
            }

            Property <Matrix> result = new Property <Matrix>();

            this.parameters.Add(name, result);

            IPropertyBinding parameter = this.model.AddInstanceMatrixParameter(name);

            this.Add(new SetBinding <Matrix>(result, delegate(Matrix value)
            {
                this.model.ParameterChanged(parameter);
            }));
            return(result);
        }
        public object RunDefaultAssertions(IPropertyBinding binding)
        {
            object expected;
            var    bindingAttribute = binding.BindingAttribute;

            if (bindingAttribute.BindingType == BindingType.OneTime)
            {
                expected = SetRandomValue(binding.Source, bindingAttribute.Converter);
                BindingSet.RunBindingInitializer();
                AssertValue(binding.Target, expected, bindingAttribute.Converter);
            }
            else
            {
                switch (bindingAttribute.BindingType)
                {
                case BindingType.OneWay:
                    expected = AssertOneWay(binding);
                    break;

                case BindingType.TwoWay:
                    AssertOneWay(binding);
                    expected = AssertOneWayFromTarget(binding);
                    break;

                case BindingType.OneWayFromTarget:
                    expected = AssertOneWayFromTarget(binding);
                    break;

                default:
                    throw new NotSupportedException(
                              $"TestFramework does not support {nameof(BindingType)} {bindingAttribute.BindingType}");
                }
            }

            return(expected);
        }
 public static bool UpdatesTarget(this IPropertyBinding binding)
 {
     return(binding.UpdateTargetAction != DoNotUpdate);
 }
 public static void DontUpdateSource(this IPropertyBinding binding)
 {
     binding.UpdateSourceAction = DoNotUpdate;
 }
 public static bool UpdatesSource(this IPropertyBinding binding)
 {
     return(binding.UpdateSourceAction != DoNotUpdate);
 }
 public void Visit(IPropertyBinding binding) => PropertyCounter++;
 public static void DontUpdateTarget(this IPropertyBinding binding)
 {
     binding.UpdateTargetAction = DoNotUpdate;
 }
Beispiel #22
0
 /// <summary>
 /// 增加绑定
 /// </summary>
 /// <param name="binding">绑定结果</param>
 protected virtual void AddBinding(IPropertyBinding binding)
 {
     _BindingList.Add(binding);
 }
Beispiel #23
0
 /// <summary>
 /// 增加绑定
 /// </summary>
 /// <param name="controlName">控件名</param>
 /// <param name="binding">绑定结果</param>
 protected virtual void AddBinding(string controlName, IPropertyBinding binding)
 {
     _BindingList2.Add(controlName, binding);
 }
 public SourceBinding(IPropertyBinding binding)
 {
     this.binding = binding ?? throw new ArgumentNullException(nameof(binding));
 }
 public override void Visit(IPropertyBinding binding)
 {
     RunDefaultAssertions(binding);
 }
 static void DoNotUpdate(IPropertyBinding binding, ChangeSource source)
 {
 }
Beispiel #27
0
 public void RemoveBinding(IPropertyBinding binding)
 {
     this.bindings.Remove(binding);
 }
Beispiel #28
0
 public void AddBinding(IPropertyBinding binding)
 {
     this.bindings.Add(binding);
 }
 public CollectionBinding(IPropertyBinding <TSource, TTarget, IEnumerable <TItem> > propertyBinding, Expression <Func <TSource, IEnumerable <TItem> > > itemsSourcePropertyExpression) :
     base(propertyBinding, itemsSourcePropertyExpression)
 {
     this.WithConverter <IdentityConverter <IEnumerable <TItem> > >();
 }
Beispiel #30
0
 public void RemoveBinding(IPropertyBinding binding)
 {
     this.bindings.Remove((IListBinding <Type>)binding);
 }