Пример #1
0
        public void Add(ClientMethodCall method)
        {
            var key = method.GetKey();

            if (_keySet.ContainsKey(key))
            {
                _list.Remove(_keySet[key]);
            }
            _keySet[key] = method;
            _list.Add(method);
        }
Пример #2
0
        /// <summary>
        /// The function is responsible for binding a source objects property to a target objects property. Both properties have to have the usual qooxdoo getter and setter. The source property also needs to fire change-events on every change of its value. Please keep in mind, that this binding is unidirectional. If you need a binding in both directions, you have to use two of this bindings.
        /// It’s also possible to bind some kind of a hierarchy as a source. This means that you can separate the source properties with a dot and bind by that the object referenced to this property chain. Example with an object ‘a’ which has object ‘b’ stored in its ‘child’ property. Object b has a string property named abc:
        ///
        /// qx.data.SingleValueBinding.bind(a, "child.abc", textfield, "value");
        ///
        /// In that case, if the property abc of b changes, the textfield will automatically contain the new value. Also if the child of a changes, the new value (abc of the new child) will be in the textfield.
        /// There is also a possibility of binding an array. Therefore the array  qx.data.IListData is needed because this array has change events which the native does not. Imagine a qooxdoo object a which has a children property containing an array holding more of its own kind. Every object has a name property as a string.
        ///
        /// var svb = qx.data.SingleValueBinding;
        /// // bind the first child's name of 'a' to a textfield
        /// svb.bind(a, "children[0].name", textfield, "value");
        /// // bind the last child's name of 'a' to a textfield
        /// svb.bind(a, "children[last].name", textfield2, "value");
        /// // also deeper bindings are possible
        /// svb.bind(a, "children[0].children[0].name", textfield3, "value");
        ///
        /// As you can see in this example, the abc property of a’s b will be bound to the textfield. If now the value of b changed or even the a will get a new b, the binding still shows the right value.
        /// </summary>
        /// <param name="sourcePropertyChain">The property chain which represents the source property.</param>
        /// <param name="targetObject">The object which the source should be bind to.</param>
        /// <param name="targetProperty">The property chain to the target object.</param>
        /// <param name="options">A map containing the options.
        /// •  converter: A converter function which takes four parameters and should return the converted value.
        /// 1.	The data to convert
        /// 2.	The corresponding model object, which is only set in case of the use of an controller.
        /// 3.	The source object for the binding
        /// 4.	The target object.
        /// If no conversion has been done, the given value should be returned. e.g. a number to boolean converter function(data, model, source, target) {return data > 100;}
        /// •  onUpdate: A callback function can be given here. This method will be called if the binding was updated successful. There will be three parameter you do get in that method call.
        /// 1.	The source object
        /// 2.	The target object
        /// 3.	The data
        /// Here is a sample: onUpdate : function(source, target, data) {...}
        /// •  onSetFail: A callback function can be given here. This method will be called if the set of the value fails.
        /// •  ignoreConverter: A string which will be matched using the current property chain. If it matches, the converter will not be called.
        /// </param>
        /// <returns></returns>
        public object Bind(string sourcePropertyChain, qxDotNet.Core.Object targetObject, string targetProperty, Map options = null)
        {
            var b = new BindingInfo();

            b.sourceProperty = sourcePropertyChain;
            b.target         = targetObject;
            b.targetProperty = targetProperty;
            b.options        = options;
            var key = b.getKey();

            _bindings[key] = b;
            var c = new ClientMethodCall("bind")
                    .SetKeyParameter(b.sourceProperty)
                    .SetKeyParameter(b.target)
                    .SetKeyParameter(b.targetProperty);

            if (b.options != null)
            {
                c.SetParameter(b.options);
            }
            CallClientMethod(c);
            return(b);
        }
Пример #3
0
 internal void CallClientMethod(ClientMethodCall method)
 {
     _newMethods.Add(method);
 }