Ejemplo n.º 1
0
		public void Deny_Unrestricted ()
		{
			DataBinding db = new DataBinding ("property", typeof (string), String.Empty);

			db.Expression = "expression";
			Assert.AreEqual ("expression", db.Expression, "Expression");
			Assert.AreEqual ("property", db.PropertyName, "PropertyName");
			Assert.AreEqual (typeof (string), db.PropertyType, "PropertyType");

			Assert.IsTrue (db.Equals (db), "Equals");
			Assert.IsTrue (db.GetHashCode () != 0, "GetHashCode"); // likely
		}
        /// <summary>
        ///    <para>
        ///       Gets the selected data source component from the component's container.
        ///    </para>
        /// </summary>
        /// <returns>
        ///    <para>
        ///       An IEnumerable with the
        ///       selected data source, or <see langword='null'/> if a data source is not found, or if a data
        ///       source with the same name does not exist.
        ///    </para>
        /// </returns>
        /// <seealso cref='System.Web.UI.Design.IDataSourceProvider'/>
        public Object GetSelectedDataSource()
        {
            Object selectedDataSource = null;

            DataBinding binding = DataBindings[_dataSourcePropertyName];

            if (binding != null)
            {
                selectedDataSource = DesignTimeData.GetSelectedDataSource(_objectList, binding.Expression);
            }

            return(selectedDataSource);
        }
        /// <include file='doc\BaseDataListDesigner.uex' path='docs/doc[@for="BaseDataListDesigner.GetSelectedDataSource"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Gets the selected data source component from the component's container.
        ///    </para>
        /// </devdoc>
        public object GetSelectedDataSource()
        {
            object selectedDataSource = null;

            DataBinding binding = DataBindings["DataSource"];

            if (binding != null)
            {
                selectedDataSource = DesignTimeData.GetSelectedDataSource(bdl, binding.Expression);
            }

            return(selectedDataSource);
        }
        public IEnumerable GetResolvedSelectedDataSource()
        {
            IEnumerable selectedDataSource = null;

            DataBinding binding = DataBindings[_dataSourcePropertyName];

            if (binding != null)
            {
                selectedDataSource = DesignTimeData.GetSelectedDataSource(_objectList, binding.Expression, DataMember);
            }

            return(selectedDataSource);
        }
        /// <include file='doc\BaseDataListDesigner.uex' path='docs/doc[@for="BaseDataListDesigner.GetResolvedSelectedDataSource"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public IEnumerable GetResolvedSelectedDataSource()
        {
            IEnumerable selectedDataSource = null;

            DataBinding binding = DataBindings["DataSource"];

            if (binding != null)
            {
                selectedDataSource = DesignTimeData.GetSelectedDataSource(bdl, binding.Expression, DataMember);
            }

            return(selectedDataSource);
        }
 public DesignTimeDataBinding(PropertyDescriptor propDesc, string field, string format, bool twoWayBinding)
 {
     this._field = field;
     this._format = format;
     if (twoWayBinding)
     {
         this._expression = CreateBindExpression(field, format);
     }
     else
     {
         this._expression = CreateEvalExpression(field, format);
     }
     this._parsed = true;
     this._twoWayBinding = twoWayBinding;
     this._runtimeDataBinding = new DataBinding(propDesc.Name, propDesc.PropertyType, this._expression);
 }
Ejemplo n.º 7
0
		[Test] public void ChangeTest ()
		{
			DataBindingCollection a = new DataBindingCollection ();
			a.Changed += delegate {
				changed = true;
			};

			DataBinding b = new DataBinding ("a", typeof (DataBindingCollectionTest), "b");
			a.Add (b);
			Assert.AreEqual (true, changed, "DB1");
			changed = false;

			a.Clear ();
			Assert.AreEqual (false, changed, "DB2");
			
			a.Remove (b);
			Assert.AreEqual (true, changed, "DB3");
		}
		public void Add (DataBinding binding)
		{
			list.Add (binding.PropertyName, binding);
			RaiseChanged ();
		}
 public void Remove(DataBinding binding)
 {
 }
 public DesignTimeDataBinding(PropertyDescriptor propDesc, string expression)
 {
     this._expression = expression;
     this._runtimeDataBinding = new DataBinding(propDesc.Name, propDesc.PropertyType, expression);
 }
 public DesignTimeDataBinding(DataBinding runtimeDataBinding)
 {
     this._runtimeDataBinding = runtimeDataBinding;
 }
 public void Add(DataBinding binding)
 {
 }
		public void Add (DataBinding binding)
		{
			list.Add (binding.PropertyName, binding);
		}
 public void Remove(DataBinding binding)
 {
     Contract.Requires(binding != null);
 }
 /// <devdoc>
 /// </devdoc>
 public void Remove(DataBinding binding) {
     Remove(binding.PropertyName, true);
 }
        /// <devdoc>
        /// </devdoc>
        public void Add(DataBinding binding) {
            bindings[binding.PropertyName] = binding;
            RemovedBindingsTable.Remove(binding.PropertyName);

            OnChanged();
        }
Ejemplo n.º 17
0
		public void FixtureSetUp ()
		{
			db = new DataBinding ("property", typeof (string), "");
		}
 public void Add(DataBinding binding)
 {
     this.bindings[binding.PropertyName] = binding;
     this.RemovedBindingsTable.Remove(binding.PropertyName);
     this.OnChanged();
 }
Ejemplo n.º 19
0
 public void Add(DataBinding binding)
 {
     list.Add(binding.PropertyName, binding);
     RaiseChanged();
 }
 public void Add(DataBinding binding)
 {
 }
Ejemplo n.º 21
0
        /*
         * Set all the properties we have on the passed in object
         * This is not called when generating code for compiling... it is
         * used in design-mode, and at runtime when the user calls Page.ParseControl
         */
        internal void SetProperties(object obj)
        {
            Debug.Assert(_fInDesigner, "Expected to be running in design mode.");

            object[] parameters = new object[1];

            IAttributeAccessor    attributeAccessor = null;
            DataBindingCollection dataBindings      = null;

            if (_fDataBound && (_entries.Count != 0))
            {
                Debug.Assert(obj is Control, "SetProperties on databindings PropertySetter should only be called for controls.");
                dataBindings = ((IDataBindingsAccessor)obj).DataBindings;
            }

            // Get the supported attribute interfaces
            if (_fSupportsAttributes)
            {
                attributeAccessor = (IAttributeAccessor)obj;
            }

            IEnumerator en = _entries.GetEnumerator();

            while (en.MoveNext())
            {
                PropertySetterEntry entry = (PropertySetterEntry)en.Current;

                if (entry._propType == null)
                {
                    if (entry._fItemProp)
                    {
                        try {
                            object objValue = entry._builder.BuildObject();
                            parameters[0] = objValue;

                            MethodInfo methodInfo = _objType.GetMethod("Add", BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static,
                                                                       null /*binder*/, new Type[] { objValue.GetType() }, null /*modifiers*/);
                            Util.InvokeMethod(methodInfo, obj, parameters);
                        }
                        catch (Exception) {
                            throw new HttpException(
                                      HttpRuntime.FormatResourceString(SR.Cannot_add_value_not_collection, entry._value));
                        }
                    }
                    else
                    {
                        // If there is no property, use SetAttribute
                        if (attributeAccessor != null)
                        {
                            attributeAccessor.SetAttribute(entry._name, entry._value);
                        }
                    }
                }
                else
                {
                    // Use the propinfo to set the prop
                    // Use either _propValue or _builder, whichever is set
                    if (entry._propValue != null)
                    {
                        try {
                            PropertyMapper.SetMappedPropertyValue(obj, entry._name, entry._propValue);
                        }
                        catch (Exception e) {
                            throw new HttpException(
                                      HttpRuntime.FormatResourceString(SR.Cannot_set_property,
                                                                       entry._value, entry._name), e);
                        }
                    }
                    else if (entry._builder != null)
                    {
                        if (entry._fReadOnlyProp)
                        {
                            // a complex property is allowed to be readonly
                            try {
                                object objValue;

                                // Get the property since its readonly
                                MethodInfo methodInfo = entry._propInfo.GetGetMethod();
                                objValue = Util.InvokeMethod(methodInfo, obj, null);

                                // now we need to initialize this property
                                entry._builder.InitObject(objValue);
                            }
                            catch (Exception e) {
                                throw new HttpException(
                                          HttpRuntime.FormatResourceString(SR.Cannot_init, entry._name), e);
                            }
                        }
                        else
                        {
                            try {
                                object objValue = entry._builder.BuildObject();
                                parameters[0] = objValue;

                                // Set the property
                                MethodInfo methodInfo = entry._propInfo.GetSetMethod();
                                Util.InvokeMethod(methodInfo, obj, parameters);
                            }
                            catch (Exception e) {
                                throw new HttpException(
                                          HttpRuntime.FormatResourceString(SR.Cannot_set_property,
                                                                           entry._value, entry._name), e);
                            }
                        }
                    }
                    else if (dataBindings != null)
                    {
                        DataBinding binding = new DataBinding(entry._name, entry._propType, entry._value.Trim());

                        dataBindings.Add(binding);
                    }
                    else
                    {
                        Debug.Assert(false, "'" + entry._value + "' failed to be set on property '" + entry._name + "'.");
                    }
                }
            }
        }
		public void Remove (DataBinding binding)
		{
			string key = binding.PropertyName;
			Remove (key);
		}
 public void Remove(DataBinding binding)
 {
 }
 /// <include file='doc\DataBindingCollection.uex' path='docs/doc[@for="DataBindingCollection.Add"]/*' />
 /// <devdoc>
 /// </devdoc>
 public void Add(DataBinding binding)
 {
     bindings[binding.PropertyName] = binding;
     RemovedBindingsTable.Remove(binding.PropertyName);
 }
 /// <include file='doc\DataBindingCollection.uex' path='docs/doc[@for="DataBindingCollection.Remove1"]/*' />
 /// <devdoc>
 /// </devdoc>
 public void Remove(DataBinding binding)
 {
     Remove(binding.PropertyName, true);
 }
Ejemplo n.º 26
0
        public void Remove(DataBinding binding)
        {
            string key = binding.PropertyName;

            Remove(key);
        }
 public void Remove (DataBinding binding)
 {
   Contract.Requires (binding != null);
 }