public override IEnumerable<IPropertyDescriptor> GetProperties(Type type, object container)
		{
			return innerTypeDescriptor.GetProperties(type, container)
				.Where(p => p.GetCustomAttribute<YamlIgnoreAttribute>() == null)
				.Select(p =>
				{
					var descriptor = new PropertyDescriptor(p);

					var alias = p.GetCustomAttribute<YamlAliasAttribute>();
					if (alias != null)
					{
						descriptor.Name = alias.Alias;
					}

					var member = p.GetCustomAttribute<YamlMemberAttribute>();
					if (member != null)
					{
						if (member.SerializeAs != null)
						{
							descriptor.TypeOverride = member.SerializeAs;
						}
					}

					return (IPropertyDescriptor)descriptor;
				});
		}
Esempio n. 2
0
		public void Initialize (PropertyDescriptor prop)
		{
			if (prop.PropertyType != typeof(int))
				throw new ApplicationException ("OptIntRange editor does not support editing values of type " + prop.PropertyType);

			double min = (double) Int32.MinValue;
			double max = (double) Int32.MaxValue;
			
			if (omin == null)
				omin = prop.Minimum;
			if (omax == null)
				omax = prop.Maximum;
			
			if (omin != null)
				min = (double) Convert.ChangeType (omin, typeof(double));
			if (omax != null)
				max = (double) Convert.ChangeType (omax, typeof(double));
			
			check = new Gtk.CheckButton ();
			check.Show ();
			check.Toggled += check_Toggled;
			PackStart (check, false, false, 0);

			spin = new Gtk.SpinButton (min, max, 1.0);
			spin.Show ();
			spin.HasFrame = false;
			spin.ValueChanged += spin_ValueChanged;
			PackStart (spin, true, true, 0);
		}
Esempio n. 3
0
		protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
		{
			if (prop.Name == "Alpha" && Alpha == -1)
				return;
			else
				base.GeneratePropertySet (ctx, var, prop);
		}
Esempio n. 4
0
		/// <summary>
		/// Initializes a new instance of the <see cref="PropertyDescriptor"/> class
		/// with an existing property descriptor.
		/// </summary>
		/// <param name="other">The other descriptor.</param>
		public PropertyDescriptor(PropertyDescriptor other)
		{
			property = other.property;
			AddKeyBuilders(other.keyBuilders);
			AddGetters(other.getters);
			AddSetters(other.setters);
		}
 /// <summary>
 ///     Creates a new ExtenderProvidedPropertyAttribute.
 /// </summary>
 internal static ExtenderProvidedPropertyAttribute Create(PropertyDescriptor extenderProperty, Type receiverType, IExtenderProvider provider)
 {
     ExtenderProvidedPropertyAttribute e = new ExtenderProvidedPropertyAttribute();
     e._extenderProperty = extenderProperty;
     e._receiverType = receiverType;
     e._provider = provider;
     return e;
 }
Esempio n. 6
0
        public override bool DefineOwnProperty(string propertyName, PropertyDescriptor desc, bool throwOnError)
        {
            if (throwOnError)
            {
                throw new JavaScriptException(Engine.TypeError, "Can't define a property of a NamespaceReference");
            }

            return false;
        }
Esempio n. 7
0
 public PropertyDescriptor(PropertyDescriptor descriptor)
 {
     Get = descriptor.Get;
     Set = descriptor.Set;
     Value = descriptor.Value;
     Enumerable = descriptor.Enumerable;
     Configurable = descriptor.Configurable;
     Writable = descriptor.Writable;
 }
		bool IDictionaryPropertySetter.SetPropertyValue(
			IDictionaryAdapterFactory factory, IDictionary dictionary,
			string key, ref object value, PropertyDescriptor property)
		{
			if (value != null)
			{
				value = GetPropertyAsString(property, value);
			}
			return true;
		}
Esempio n. 9
0
		public override void Initialize (PropertyDescriptor prop)
		{
			base.Initialize (prop);
			
			entry = new Gtk.Entry ();
			entry.HasFrame = false;
			entry.Show ();
			entry.Changed += EntryChanged;
			Add (entry);
		}
		private void ApplyValidationRules(IDictionaryAdapter dictionaryAdapter, IEnumerable<IValidationRule> rules,
										  PropertyDescriptor property, object propertyValue, IList<String> errors)
		{
			if (rules != null)
			{
				foreach (var rule in rules)
				{
					rule.Apply(dictionaryAdapter, property, propertyValue, errors);
				}
			}
		}
		protected void NotifyPropertyChanged(PropertyDescriptor property, object oldValue, object newValue)
		{
			if (property.SuppressNotifications)
				return;

			var propertyChanged = PropertyChanged;
			if (propertyChanged == null)
				return;

			propertyChanged(this, new PropertyChangedEventArgsEx(property.PropertyName, oldValue, newValue));
		}
		private List<Expression> BuildColumnConstraints(PropertyDescriptor propertyDescriptor, PropertyDescriptor foreignKeyReferencingProperty)
		{
			var retval = new List<Expression>();

			if (foreignKeyReferencingProperty != null)
			{
				var valueRequiredAttribute = foreignKeyReferencingProperty.ValueRequiredAttribute;

				if (foreignKeyReferencingProperty.HasUniqueAttribute && foreignKeyReferencingProperty.UniqueAttribute.Unique)
				{
					retval.Add(new SqlSimpleConstraintExpression(SqlSimpleConstraint.Unique));
				}

				if (valueRequiredAttribute != null && valueRequiredAttribute.Required)
				{
					retval.Add(new SqlSimpleConstraintExpression(SqlSimpleConstraint.NotNull));
				}
			}
			else
			{
				if (propertyDescriptor.PropertyType.IsNullableType() || !propertyDescriptor.PropertyType.IsValueType)
				{
					var valueRequiredAttribute = propertyDescriptor.ValueRequiredAttribute;

					if (valueRequiredAttribute != null && valueRequiredAttribute.Required)
					{
						retval.Add(new SqlSimpleConstraintExpression(SqlSimpleConstraint.NotNull));
					}
				}
				else
				{
					retval.Add(new SqlSimpleConstraintExpression(SqlSimpleConstraint.NotNull));
				}

				if (propertyDescriptor.IsAutoIncrement && propertyDescriptor.PropertyType.IsIntegerType(true))
				{
					retval.Add(new SqlSimpleConstraintExpression(SqlSimpleConstraint.AutoIncrement, value: new object[] { propertyDescriptor.AutoIncrementAttribute.Seed, propertyDescriptor.AutoIncrementAttribute.Step }));
				}

				if (propertyDescriptor.HasUniqueAttribute && propertyDescriptor.UniqueAttribute.Unique)
				{
					retval.Add(new SqlSimpleConstraintExpression(SqlSimpleConstraint.Unique));
				}
				
				var defaultValueAttribute = propertyDescriptor.DefaultValueAttribute;

				if (defaultValueAttribute != null)
				{
					retval.Add(new SqlSimpleConstraintExpression(SqlSimpleConstraint.DefaultValue, null, defaultValueAttribute.Value));
				}
			}

			return retval;
		}
		public string Validate(IDictionaryAdapter dictionaryAdapter, PropertyDescriptor property)
		{
			List<String> errors = new List<string>();
			var globalRules = AttributesUtil.GetTypeAttributes<IValidationRule>(dictionaryAdapter.Meta.Type);

			var propertyRules = AttributesUtil.GetAttributes<IValidationRule>(property.Property);
			var propertyValue = dictionaryAdapter.GetProperty(property.PropertyName, true);
			ApplyValidationRules(dictionaryAdapter, propertyRules, property, propertyValue, errors);
			ApplyValidationRules(dictionaryAdapter, globalRules, property, propertyValue, errors);

			return String.Join(Environment.NewLine, errors.ToArray());
		}
Esempio n. 14
0
		public void Initialize (PropertyDescriptor prop)
		{
			if (!prop.PropertyType.IsEnum)
				throw new ApplicationException ("Flags editor does not support editing values of type " + prop.PropertyType);
				
			property = prop.Label;
			Spacing = 3;

			// For small enums, the editor is a list of checkboxes inside a frame
			// For large enums (>5), use a selector dialog.

			enm = Registry.LookupEnum (prop.PropertyType.FullName);
			
			if (enm.Values.Length < 6) 
			{
				Gtk.VBox vbox = new Gtk.VBox (true, 3);

				flags = new Hashtable ();

				foreach (Enum value in enm.Values) {
					EnumValue eval = enm[value];
					if (eval.Label == "")
						continue;

					Gtk.CheckButton check = new Gtk.CheckButton (eval.Label);
					check.TooltipText = eval.Description;
					uint uintVal = (uint) Convert.ToInt32 (eval.Value);
					flags[check] = uintVal;
					flags[uintVal] = check;
					
					check.Toggled += FlagToggled;
					vbox.PackStart (check, false, false, 0);
				}

				Gtk.Frame frame = new Gtk.Frame ();
				frame.Add (vbox);
				frame.ShowAll ();
				PackStart (frame, true, true, 0);
			} 
			else 
			{
				flagsLabel = new Gtk.Entry ();
				flagsLabel.IsEditable = false;
				flagsLabel.HasFrame = false;
				flagsLabel.ShowAll ();
				PackStart (flagsLabel, true, true, 0);
				
				Gtk.Button but = new Gtk.Button ("...");
				but.Clicked += OnSelectFlags;
				but.ShowAll ();
				PackStart (but, false, false, 0);
			}
		}
Esempio n. 15
0
		public void Initialize (PropertyDescriptor descriptor)
		{
			store = new ListStore (typeof(Pixbuf), typeof(string));
			Model = store;
			store.SetSortColumnId (1, SortType.Ascending);
			CellRendererPixbuf crp = new CellRendererPixbuf ();
			CellRendererText crt = new CellRendererText ();
			PackStart (crp, false);
			PackStart (crt, true);
			SetAttributes (crp, "pixbuf", 0);
			SetAttributes (crt, "text", 1);
		}
Esempio n. 16
0
		protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
		{
			if (prop.Name == "Group") {
				CodeExpression groupExp = GroupManager.GenerateGroupExpression (ctx, (Gtk.Widget) Wrapped);
				ctx.Statements.Add (
					new CodeAssignStatement (
						new CodePropertyReferenceExpression (var, "Group"),
						groupExp)
				);
			}
			else
				base.GeneratePropertySet (ctx, var, prop);
		}
		protected bool NotifyPropertyChanging(PropertyDescriptor property, object oldValue, object newValue)
		{
			if (property.SuppressNotifications)
				return true;

			var propertyChanging = PropertyChanging;
			if (propertyChanging == null)
				return true;

			var args = new PropertyChangingEventArgsEx(property.PropertyName, oldValue, newValue);
			propertyChanging(this, args);
			return !args.Cancel;
		}
        private IEnumerable<Attribute> GetFieldMetadata(PropertyDescriptor fieldProperty) {

            if (AssociatedMetadataType != null) {
                MemberTypes allowedMemberTypes = MemberTypes.Property | MemberTypes.Field;
                foreach (MemberInfo buddyMember in AssociatedMetadataType.GetMembers()) {
                    if ((buddyMember.MemberType & allowedMemberTypes) != 0 && PropertyMatches(fieldProperty, buddyMember)) {
                        foreach (Attribute attribute in buddyMember.GetCustomAttributes(false)) {
                            yield return attribute;
                        }
                        yield break;
                    }
                }
            }
        }
Esempio n. 19
0
		public void Initialize (PropertyDescriptor prop)
		{
			propType = prop.PropertyType;
			
			double min, max;
			
			switch (Type.GetTypeCode (propType)) {
				case TypeCode.Int16:
					min = (double) Int16.MinValue;
					max = (double) Int16.MaxValue;
					break;
				case TypeCode.UInt16:
					min = (double) UInt16.MinValue;
					max = (double) UInt16.MaxValue;
					break;
				case TypeCode.Int32:
					min = (double) Int32.MinValue;
					max = (double) Int32.MaxValue;
					break;
				case TypeCode.UInt32:
					min = (double) UInt32.MinValue;
					max = (double) UInt32.MaxValue;
					break;
				case TypeCode.Int64:
					min = (double) Int64.MinValue;
					max = (double) Int64.MaxValue;
					break;
				case TypeCode.UInt64:
					min = (double) UInt64.MinValue;
					max = (double) UInt64.MaxValue;
					break;
				case TypeCode.Byte:
					min = (double) Byte.MinValue;
					max = (double) Byte.MaxValue;
					break;
				case TypeCode.SByte:
					min = (double) SByte.MinValue;
					max = (double) SByte.MaxValue;
					break;
				default:
					throw new ApplicationException ("IntRange editor does not support editing values of type " + prop.PropertyType);
			}

			if (prop.Minimum != null)
				min = (double) Convert.ChangeType (prop.Minimum, typeof(double));
			if (prop.Maximum != null)
				max = (double) Convert.ChangeType (prop.Maximum, typeof(double));
			
			SetRange (min, max);
		}
		protected void NotifyPropertyChanged(PropertyDescriptor property, object oldValue, object newValue)
		{
			if (!property.SuppressNotifications)
			{
				var propertyChanged = PropertyChanged;

				ComposeChildNotifications(property, oldValue, newValue);

				if (propertyChanged != null)
				{
					propertyChanged(this, new PropertyModifiedEventArgs(property.PropertyName, oldValue, newValue));
				}
			}
		}
		protected bool NotifyPropertyChanging(PropertyDescriptor property, object oldValue, object newValue)
		{
			if (!property.SuppressNotifications)
			{
				var propertyChanging = PropertyChanging;

				if (propertyChanging != null)
				{
					var eventArgs = new PropertyModifyingEventArgs(property.PropertyName, oldValue, newValue);
					propertyChanging(this, eventArgs);
					return !eventArgs.Cancel;
				}
			}
			return true;
		}
Esempio n. 22
0
		public void Initialize (PropertyDescriptor descriptor)
		{
			if (descriptor.PropertyType != typeof(string))
				throw new InvalidOperationException ("TextEditor only can edit string properties");
				
			try {
				if (descriptor.Minimum != null)
					min = Convert.ToInt32 (descriptor.Minimum);
			} catch {}
				
			try {
				if (descriptor.Maximum != null)
					max = Convert.ToInt32 (descriptor.Maximum);
			} catch {}
		}
		/// <summary>
		/// Gets the effective dictionary value.
		/// </summary>
		/// <param name="dictionaryAdapter">The dictionary adapter.</param>
		/// <param name="key">The key.</param>
		/// <param name="storedValue">The stored value.</param>
		/// <param name="property">The property.</param>
		/// <param name="ifExists">true if return only existing.</param>
		/// <returns>The effective property value.</returns>
		public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter,
			string key, object storedValue, PropertyDescriptor property, bool ifExists)
		{
			var propertyType = property.PropertyType;

			if (storedValue != null && propertyType.IsInstanceOfType(storedValue) == false)
			{
				if (converter != null && converter.CanConvertFrom(storedValue.GetType()))
				{
					return converter.ConvertFrom(storedValue);
				}
			}

			return storedValue;
		}
Esempio n. 24
0
		/// <summary>
		/// Gets the effective dictionary value.
		/// </summary>
		/// <param name="factory">The dictionary factory.</param>
		/// <param name="dictionary">The dictionary.</param>
		/// <param name="key">The key.</param>
		/// <param name="storedValue">The stored value.</param>
		/// <param name="property">The property.</param>
		/// <returns>The effective property value.</returns>
		public object GetPropertyValue(IDictionaryAdapterFactory factory,
		                               IDictionary dictionary, string key,
		                               object storedValue, PropertyDescriptor property)
		{
			Type propertyType = property.PropertyType;

			if (storedValue != null && !propertyType.IsInstanceOfType(storedValue))
			{
				if (converter != null && converter.CanConvertFrom(storedValue.GetType()))
				{
					return converter.ConvertFrom(storedValue);
				}
			}

			return storedValue;
		}
		private string GetPropertyAsString(PropertyDescriptor property, object value)
		{
			if (!string.IsNullOrEmpty(format))
			{
				return String.Format(format, value);
			}

			TypeConverter converter = property.TypeConverter;


			if (converter != null && converter.CanConvertTo(typeof(string)))
			{
				return (string) converter.ConvertTo(value, typeof(string));
			}

			return value.ToString();
		}
		/// <summary>
		///  Copies an existinginstance of the <see cref="PropertyDescriptor"/> class.
		/// </summary>
		/// <param name="source"></param>
		/// <param name="copyBehaviors"></param>
		public PropertyDescriptor(PropertyDescriptor source, bool copyBehaviors)
		{
			Property = source.Property;
			Behaviors = source.Behaviors;
			IsDynamicProperty = source.IsDynamicProperty;
			TypeConverter = source.TypeConverter;
			SuppressNotifications = source.SuppressNotifications;
			state = source.state;
			Fetch = source.Fetch;

			if (copyBehaviors)
			{
				keyBuilders = source.keyBuilders;
				getters = source.getters;
				setters = source.setters;
			}
		}
        public void ConstructorReadOnlyTests()
        {
            var descriptors = new PropertyDescriptor[]
            {
                new MockPropertyDescriptor("descriptor1")
            };

            var collection = new PropertyDescriptorCollection(descriptors, true);

            Assert.Equal(descriptors.Cast<PropertyDescriptor>(), collection.Cast<PropertyDescriptor>());

            // These methods are implemented as explicit properties so we need to ensure they are what we expect
            Assert.True(((IDictionary)collection).IsReadOnly);
            Assert.True(((IDictionary)collection).IsFixedSize);
            Assert.True(((IList)collection).IsReadOnly);
            Assert.True(((IList)collection).IsFixedSize);
        }
Esempio n. 28
0
        public override PropertyDescriptor GetOwnProperty(string propertyName)
        {
            PropertyDescriptor x;
            if (Properties.TryGetValue(propertyName, out x))
                return x;

            var library = (Library) Target;
            var method = library.GetFunction(propertyName);

            if (method != null)
            {
                var descriptor = new PropertyDescriptor(new MethodInfoFunctionInstance(Engine, new[] { method }), false, true, false);
                Properties.Add(propertyName, descriptor);
                return descriptor;
            }

            return PropertyDescriptor.Undefined;
        }
		public override IEnumerable<IPropertyDescriptor> GetProperties(Type type, object container)
		{
			return innerTypeDescriptor.GetProperties(type, container)
				.Where(p => p.GetCustomAttribute<YamlIgnoreAttribute>() == null)
				.Select(p =>
				{
					var descriptor = new PropertyDescriptor(p);

#pragma warning disable 0618 // 'YamlDotNet.Serialization.YamlAliasAttribute' is obsolete: 'Please use YamlMember instead'
					var alias = p.GetCustomAttribute<YamlAliasAttribute>();
					if (alias != null)
					{
						descriptor.Name = alias.Alias;
					}
#pragma warning restore 0618 // 'YamlDotNet.Serialization.YamlAliasAttribute' is obsolete: 'Please use YamlMember instead'

					var member = p.GetCustomAttribute<YamlMemberAttribute>();
					if (member != null)
					{
						if (member.SerializeAs != null)
						{
							descriptor.TypeOverride = member.SerializeAs;
						}

						descriptor.Order = member.Order;
						descriptor.ScalarStyle = member.ScalarStyle;

						if (member.Alias != null)
						{
							if (alias != null)
							{
								throw new InvalidOperationException("Mixing YamlAlias(...) with YamlMember(Alias = ...) is an error. The YamlAlias attribute is obsolete and should be removed.");
							}
							descriptor.Name = member.Alias;
						}
					}

					return (IPropertyDescriptor)descriptor;
				})
				.OrderBy(p => p.Order);
		}
Esempio n. 30
0
		public void Initialize (PropertyDescriptor prop)
		{
			if (!prop.PropertyType.IsEnum)
				throw new ApplicationException ("Enumeration editor does not support editing values of type " + prop.PropertyType);
				
			ebox = new Gtk.EventBox ();
			ebox.Show ();
			PackStart (ebox, true, true, 0);

			combo = Gtk.ComboBoxEntry.NewText ();
			combo.Changed += combo_Changed;
			combo.Entry.IsEditable = false;
			combo.Entry.HasFrame = false;
			combo.Entry.HeightRequest = combo.SizeRequest ().Height;	// The combo does not set the entry to the correct size when it does not have a frame
			combo.Show ();
			ebox.Add (combo);

			enm = Registry.LookupEnum (prop.PropertyType.FullName);
			foreach (Enum value in enm.Values)
				combo.AppendText (enm[value].Label);
		}
 private void SetNextTabIndex(Control ctl)
 {
     if (this.tabControls != null)
     {
         int     num;
         Control sitedParent = this.GetSitedParent(ctl);
         object  obj2        = this.tabNext[sitedParent];
         if (this.tabComplete.IndexOf(ctl) == -1)
         {
             this.tabComplete.Add(ctl);
         }
         if (obj2 != null)
         {
             num = (int)obj2;
         }
         else
         {
             num = 0;
         }
         try
         {
             PropertyDescriptor descriptor = (PropertyDescriptor)this.tabProperties[ctl];
             if (descriptor != null)
             {
                 int num3 = num + 1;
                 if (descriptor.IsReadOnly)
                 {
                     num3 = ((int)descriptor.GetValue(ctl)) + 1;
                 }
                 int maxControlCount = this.GetMaxControlCount(sitedParent);
                 if (num3 >= maxControlCount)
                 {
                     num3 = 0;
                 }
                 this.tabNext[sitedParent] = num3;
                 if (this.tabComplete.Count == this.tabControls.Count)
                 {
                     this.tabComplete.Clear();
                 }
                 if (!descriptor.IsReadOnly)
                 {
                     try
                     {
                         descriptor.SetValue(ctl, num);
                     }
                     catch (Exception)
                     {
                     }
                 }
                 else
                 {
                     base.Invalidate();
                 }
             }
         }
         catch (Exception exception)
         {
             if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
             {
                 throw;
             }
         }
     }
 }
Esempio n. 32
0
        public Type GetEditorType(PropertyDescriptor pd)
        {
            //try to find a custom editor
            //TODO: Find a way to provide a IWindowsFormsEditorService so this can work directly
            //for now, substitute GTK#-based editors

            /*
             * UITypeEditor UITypeEd = (UITypeEditor) pd.GetEditor(typeof (System.Drawing.Design.UITypeEditor));//first, does it have custom editors?
             * if (UITypeEd != null)
             *      if (surrogates.Contains(UITypeEd.GetType ()))
             *              return instantiateEditor((Type) surrogates[UITypeEd.GetType()], parentRow);
             */

            //does a registered GTK# editor support this natively?
            Type editType = pd.PropertyType;

            if (editors.Contains(editType))
            {
                return((Type)editors [editType]);
            }

            //editors that edit derived types
            foreach (DictionaryEntry de in inheritingEditors)
            {
                if (editType.IsSubclassOf((Type)de.Key))
                {
                    return((Type)de.Value);
                }
            }

            if (pd.PropertyType.IsEnum)
            {
                if (pd.PropertyType.IsDefined(typeof(FlagsAttribute), true))
                {
                    return(typeof(PropertyEditors.FlagsEditorCell));
                }
                else
                {
                    return(typeof(PropertyEditors.EnumerationEditorCell));
                }
            }

            //collections with items of single type that aren't just objects
            if (typeof(IList).IsAssignableFrom(editType))
            {
                // Iterate through all properties since there may be more than one indexer.
                if (GetCollectionItemType(editType) != null)
                {
                    return(typeof(CollectionEditor));
                }
            }

            //TODO: support simple SWF collection editor derivatives that just override Types available
            // and reflect protected Type[] NewItemTypes {get;} to get types
            //if (UITypeEd is System.ComponentModel.Design.CollectionEditor)
            //	((System.ComponentModel.Design.CollectionEditor)UITypeEd).

            //can we use a type converter with a built-in editor?
            TypeConverter tc = pd.Converter;

            if (typeof(ExpandableObjectConverter).IsAssignableFrom(tc.GetType()))
            {
                return(typeof(ExpandableObjectEditor));
            }

            //This is a temporary workaround *and* and optimisation
            //First, most unknown types will be most likely to convert to/from strings
            //Second, System.Web.UI.WebControls/UnitConverter.cs dies on non-strings
            if (tc.CanConvertFrom(typeof(string)) && tc.CanConvertTo(typeof(string)))
            {
                return(typeof(TextEditor));
            }

            foreach (DictionaryEntry editor in editors)
            {
                if (tc.CanConvertFrom((Type)editor.Key) && tc.CanConvertTo((Type)editor.Key))
                {
                    return((Type)editor.Value);
                }
            }

            foreach (DictionaryEntry de in inheritingEditors)
            {
                if (tc.CanConvertFrom((Type)de.Key) && tc.CanConvertTo((Type)de.Key))
                {
                    return((Type)de.Value);
                }
            }

            //nothing found - just display type
            return(null);
        }
Esempio n. 33
0
 /// <summary>
 /// Returns an object that contains the property described by the specified property descriptor.
 /// </summary>
 /// <param name="pd">A PropertyDescriptor that represents the property whose owner is to be found. </param>
 /// <returns>Handle object</returns>
 public object GetPropertyOwner(PropertyDescriptor pd)
 {
     return(m_handle);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="prop"></param>
        /// <param name="direction"></param>
        /// <exception cref="NotSupportedException">If cannot sort by .</exception>
        protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection direction)
        {
            var sortedList = new List <SortIndex <T> >();

            // Check to see if the property type we are sorting by implements
            // the IComparable interface.
            var interfaceType = prop.PropertyType.GetInterface("IComparable");

            if (interfaceType != null)
            {
                RaiseListChangedEvents = false;
                // If so, set the SortPropertyValue and SortDirectionValue.
                _sortPropertyValue  = prop;
                _sortDirectionValue = direction;

                _unsortedItems = new ArrayList(Count);

                // Loop through each item, adding it the the sortedItems ArrayList.
                foreach (var item in Items)
                {
                    sortedList.Add(new SortIndex <T>((IComparable)prop.GetValue(item), item));
                    _unsortedItems.Add(item);
                }
                // Call Sort on the ArrayList.
                sortedList.Sort();

                // Check the sort direction and then copy the sorted items
                // back into the list.
                if (direction == ListSortDirection.Descending)
                {
                    sortedList.Reverse();
                }

                for (var i = 0; i < sortedList.Count; i++)
                {
                    try
                    {
                        var position = IndexOf(sortedList[i].Item);
                        if (position == i)
                        {
                            continue;
                        }
                        var temp = this[i];
                        this[i]        = this[position];
                        this[position] = temp;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }

                _isSortedValue = true;

                // Raise the ListChanged event so bound controls refresh their
                // values.
                RaiseListChangedEvents = true;

                OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
            }
            else
            {
                // If the property type does not implement IComparable, let the user
                // know.
                throw new NotSupportedException($"Cannot sort by {prop.Name}. This{prop.PropertyType} does not implement IComparable");
            }
        }
Esempio n. 35
0
 public WidgetOption(PropertyDescriptor propertyDescriptor)
 {
     PropertyDescriptor = propertyDescriptor;
 }
Esempio n. 36
0
 public void RemoveIndex(PropertyDescriptor property)
 {
 }
 public object GetPropertyOwner(PropertyDescriptor pd)
 {
     return(this.owner);
 }
Esempio n. 38
0
 /// <summary>
 /// Returns an object that contains the property described by the specified property descriptor.
 /// </summary>
 /// <param name="pd">A <see cref="T:System.ComponentModel.PropertyDescriptor"/> that represents the property whose owner is to be found.</param>
 /// <returns>
 /// An <see cref="T:System.Object"/> that represents the owner of the specified property.
 /// </returns>
 object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
 {
     return(null);
 }
Esempio n. 39
0
 object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
 {
     throw new NotImplementedException();
 }
Esempio n. 40
0
        /// <include file='doc\MenuDesigner.uex' path='docs/doc[@for="MenuDesigner.IMISetProp"]/*' />
        /// <devdoc>
        ///     This method is called by the IVsMenuEditor when properties of a particular menu
        ///     item need to be set.
        /// </devdoc>
        public int IMISetProp(int propId, object obj)
        {
            //make sure we can get a component that is a menuitem
            //so we can adjust its' properties...
            IComponent c = Component;

            if (!(c is MenuItem))
            {
                return(NativeMethods.S_OK);
            }

            PropertyDescriptor prop  = null;
            object             value = null;

            try {
                //if this is the first call to setProp since we've been created
                //then we need to be sure to ignore any name change from the
                //menu editor
                if (justCreated)
                {
                    if (propId == __VSMEPROPID.VSMEPROPID_NAME)
                    {
                        return(NativeMethods.S_OK);
                    }
                }

                switch (propId)
                {
                case __VSMEPROPID.VSMEPROPID_NAME:
                    prop  = TypeDescriptor.GetProperties(c)["Name"];
                    value = Convert.ToString(obj);
                    break;

                case __VSMEPROPID.VSMEPROPID_CAPTION:
                    if (obj == null)
                    {
                        textCache = "";
                    }
                    else
                    {
                        textCache = obj.ToString();
                    }
                    break;

                case __VSMEPROPID.VSMEPROPID_CHECKED:
                    prop  = TypeDescriptor.GetProperties(c)["Checked"];
                    value = (bool)obj;
                    break;

                case __VSMEPROPID.VSMEPROPID_ENABLED:
                    prop  = TypeDescriptor.GetProperties(c)["Enabled"];
                    value = (bool)obj;
                    break;

                case __VSMEPROPID.VSMEPROPID_VISIBLE:
                    prop  = TypeDescriptor.GetProperties(c)["Visible"];
                    value = (bool)obj;
                    break;

                case __VSMEPROPID.VSMEPROPID_RADIOCHECK:
                    prop  = TypeDescriptor.GetProperties(c)["RadioCheck"];
                    value = (bool)obj;
                    break;
                }
            }
            catch (Exception e) {
                //try to get the iuiservice and show the error that we encountered
                IUIService uiService = (IUIService)GetService(typeof(IUIService));
                if (uiService != null)
                {
                    uiService.ShowError(e, SR.GetString(SR.MenuDesignerInvalidPropertyValue));
                }
                return(NativeMethods.S_FALSE);
            }

            //This will call prop.SetValue and push the info onto the undo stack
            //
            if (propId != __VSMEPROPID.VSMEPROPID_CAPTION)
            {
                try {
                    CommitPropertyChange(c, prop, value);
                }
                catch (Exception e) {
                    //try to get the iuiservice and show the error that we encountered
                    IUIService uiService = (IUIService)GetService(typeof(IUIService));
                    if (uiService != null)
                    {
                        uiService.ShowError(e.InnerException);
                    }
                    return(NativeMethods.S_FALSE);
                }
            }

            return(NativeMethods.S_OK);
        }
Esempio n. 41
0
        /// <include file='doc\MenuDesigner.uex' path='docs/doc[@for="MenuDesigner.IMIGetProp"]/*' />
        /// <devdoc>
        ///     This method is called by the IVsMenuEditor when properties of a particular menu
        ///     item need to be retrieved.
        /// </devdoc>
        public int IMIGetProp(int propId, out object pObj)
        {
            //make sure we can get a component that is a menuitem
            //so we can get its' properties...
            IComponent c = Component;

            if (!(c is MenuItem))
            {
                pObj = null;
                return(NativeMethods.S_OK);
            }

            MenuItem menuItem = (MenuItem)c;

            switch (propId)
            {
            case __VSMEPROPID.VSMEPROPID_NAME:
                String             name = null;
                PropertyDescriptor pd   = TypeDescriptor.GetProperties(menuItem)["Name"];
                if (pd != null)
                {
                    name = pd.GetValue(menuItem).ToString();
                }
                pObj = name;
                break;

            case __VSMEPROPID.VSMEPROPID_CAPTION:
                pObj = TypeDescriptor.GetProperties(menuItem)["Text"].GetValue(menuItem).ToString();

                //passing a 0 length string back into the menu editor if it's not
                //active will not redraw... so here, we force a repaint, by setting the appropriate item.
                //This case only surfaces if you "undo" a menu item's text and the menu editor is not active.
                //
                if (pObj != null && pObj.ToString().Length == 0)
                {
                    MenuEditorService menuEdSvc = GetService(typeof(IMenuEditorService)) as MenuEditorService;
                    if (menuEdSvc != null && !menuEdSvc.IsActive())
                    {
                        menuEdSvc.SetSelection(menuItem);
                    }
                }
                break;

            case __VSMEPROPID.VSMEPROPID_CHECKED:
                pObj = TypeDescriptor.GetProperties(menuItem)["Checked"].GetValue(menuItem);
                break;

            case __VSMEPROPID.VSMEPROPID_ENABLED:
                pObj = TypeDescriptor.GetProperties(menuItem)["Enabled"].GetValue(menuItem);
                break;

            case __VSMEPROPID.VSMEPROPID_VISIBLE:
                pObj = TypeDescriptor.GetProperties(menuItem)["Visible"].GetValue(menuItem);
                break;

            case __VSMEPROPID.VSMEPROPID_RADIOCHECK:
                pObj = TypeDescriptor.GetProperties(menuItem)["RadioCheck"].GetValue(menuItem);
                break;

            default:
                pObj = null;
                break;
            }

            return(NativeMethods.S_OK);
        }
Esempio n. 42
0
 public void RemoveIndex(PropertyDescriptor property)
 {
     BindingListImpl.RemoveIndex(property);
 }
Esempio n. 43
0
            // this returns an array list of the propertydescriptor arrays, one for each
            // component
            //
            private static ArrayList GetCommonProperties(object[] objs, bool presort, PropertyTab tab, GridEntry parentEntry)
            {
                PropertyDescriptorCollection[] propCollections = new PropertyDescriptorCollection[objs.Length];

                Attribute[] attrs = new Attribute[parentEntry.BrowsableAttributes.Count];
                parentEntry.BrowsableAttributes.CopyTo(attrs, 0);

                for (int i = 0; i < objs.Length; i++)
                {
                    PropertyDescriptorCollection pdc = tab.GetProperties(parentEntry, objs[i], attrs);
                    if (presort)
                    {
                        pdc = pdc.Sort(PropertyComparer);
                    }
                    propCollections[i] = pdc;
                }

                ArrayList mergedList = new ArrayList();

                PropertyDescriptor[] matchArray = new PropertyDescriptor[objs.Length];

                //
                // Merge the property descriptors
                //
                int[] posArray = new int[propCollections.Length];
                for (int i = 0; i < propCollections[0].Count; i++)
                {
                    PropertyDescriptor pivotDesc = propCollections[0][i];

                    bool match = pivotDesc.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute();

                    for (int j = 1; match && j < propCollections.Length; j++)
                    {
                        if (posArray[j] >= propCollections[j].Count)
                        {
                            match = false;
                            break;
                        }

                        // check to see if we're on a match
                        //
                        PropertyDescriptor jProp = propCollections[j][posArray[j]];
                        if (pivotDesc.Equals(jProp))
                        {
                            posArray[j] += 1;

                            if (!jProp.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute())
                            {
                                match = false;
                                break;
                            }
                            matchArray[j] = jProp;
                            continue;
                        }

                        int jPos = posArray[j];
                        jProp = propCollections[j][jPos];

                        match = false;

                        // if we aren't on a match, check all the items until we're past
                        // where the matching item would be
                        while (PropertyComparer.Compare(jProp, pivotDesc) <= 0)
                        {
                            // got a match!
                            if (pivotDesc.Equals(jProp))
                            {
                                if (!jProp.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute())
                                {
                                    match = false;
                                    jPos++;
                                }
                                else
                                {
                                    match         = true;
                                    matchArray[j] = jProp;
                                    posArray[j]   = jPos + 1;
                                }
                                break;
                            }

                            // try again
                            jPos++;
                            if (jPos < propCollections[j].Count)
                            {
                                jProp = propCollections[j][jPos];
                            }
                            else
                            {
                                break;
                            }
                        }

                        // if we got here, there is no match, quit for this guy
                        if (!match)
                        {
                            posArray[j] = jPos;
                            break;
                        }
                    }

                    // do we have a match?
                    if (match)
                    {
                        matchArray[0] = pivotDesc;
                        mergedList.Add(matchArray.Clone());
                    }
                }

                return(mergedList);
            }
Esempio n. 44
0
 public void ApplySort(PropertyDescriptor property, ListSortDirection direction)
 {
     BindingListImpl.ApplySort(property, direction);
 }
Esempio n. 45
0
 public void AddIndex(PropertyDescriptor property)
 {
 }
        // Reminder: We set control.Parent so that it gets serialized for Undo/Redo
        //
        private void Paste(object sender, EventArgs args)
        {
            IDesignerSerializationService stateSerializer = GetService(typeof(IDesignerSerializationService)) as IDesignerSerializationService;
            ISelectionService             selection       = GetService(typeof(ISelectionService)) as ISelectionService;
            IDesignerHost           host          = GetService(typeof(IDesignerHost)) as IDesignerHost;
            IComponentChangeService changeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (host == null || stateSerializer == null)
            {
                return;
            }
            //
            // TODO: MWF X11 doesn't seem to support custom clipboard formats - bug #357642
            //
            // IDataObject dataObject = Clipboard.GetDataObject ();
            // byte[] data = dataObject == null ? null : dataObject.GetData (DT_DATA_FORMAT) as byte[];
            // if (data != null) {
            //  MemoryStream stream = new MemoryStream (data);
            //  stateSerializer.Deserialize (new BinaryFormatter().Deserialize (stream));
            // .....
            // }
            //
            if (_clipboard == null)
            {
                return;
            }

            DesignerTransaction transaction = host.CreateTransaction("Paste");
            ICollection         components  = stateSerializer.Deserialize(_clipboard);

            // Console.WriteLine ("Pasted components: ");
            // foreach (object c in components)
            //  Console.WriteLine (((IComponent)c).Site.Name);
            foreach (object component in components)
            {
                Control control = component as Control;
                if (control == null)
                {
                    continue; // pure Components are added to the ComponentTray by the DocumentDesigner
                }
                PropertyDescriptor parentProperty = TypeDescriptor.GetProperties(control)["Parent"];
                if (control.Parent != null)
                {
                    // Already parented during deserialization?
                    // In that case explicitly raise component changing/ed for the Parent property,
                    // so it get's cought by the UndoEngine
                    if (changeService != null)
                    {
                        changeService.OnComponentChanging(control, parentProperty);
                        changeService.OnComponentChanged(control, parentProperty, null, control.Parent);
                    }
                }
                else
                {
                    ParentControlDesigner parentDesigner = null;
                    if (selection != null && selection.PrimarySelection != null)
                    {
                        parentDesigner = host.GetDesigner((IComponent)selection.PrimarySelection) as ParentControlDesigner;
                    }
                    if (parentDesigner == null)
                    {
                        parentDesigner = host.GetDesigner(host.RootComponent) as DocumentDesigner;
                    }
                    if (parentDesigner != null && parentDesigner.CanParent(control))
                    {
                        parentProperty.SetValue(control, parentDesigner.Control);
                    }
                }
            }
            _clipboard = null;
            transaction.Commit();
            ((IDisposable)transaction).Dispose();
        }
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            PropertyDescriptor ftpSessionProperty = context.DataContext.GetProperties()[WithFtpSession.FtpSessionPropertyName];
            IFtpSession        ftpSession         = ftpSessionProperty?.GetValue(context.DataContext) as IFtpSession;

            if (ftpSession == null)
            {
                throw new InvalidOperationException(Resources.FTPSessionNotFoundException);
            }

            string remotePath = RemotePath.Get(context);
            string localPath  = LocalPath.Get(context);

            FtpObjectType objectType = await ftpSession.GetObjectTypeAsync(remotePath, cancellationToken);

            if (objectType == FtpObjectType.Directory)
            {
                if (string.IsNullOrWhiteSpace(Path.GetExtension(localPath)))
                {
                    if (!Directory.Exists(localPath))
                    {
                        if (Create)
                        {
                            Directory.CreateDirectory(localPath);
                        }
                        else
                        {
                            throw new ArgumentException(string.Format(Resources.PathNotFoundException, localPath));
                        }
                    }
                }
                else
                {
                    throw new InvalidOperationException(Resources.IncompatiblePathsException);
                }
            }
            else
            {
                if (objectType == FtpObjectType.File)
                {
                    if (string.IsNullOrWhiteSpace(Path.GetExtension(localPath)))
                    {
                        localPath = Path.Combine(localPath, Path.GetFileName(remotePath));
                    }

                    string directoryPath = Path.GetDirectoryName(localPath);

                    if (!Directory.Exists(directoryPath))
                    {
                        if (Create)
                        {
                            Directory.CreateDirectory(directoryPath);
                        }
                        else
                        {
                            throw new InvalidOperationException(string.Format(Resources.PathNotFoundException, directoryPath));
                        }
                    }
                }
                else
                {
                    throw new NotImplementedException(Resources.UnsupportedObjectTypeException);
                }
            }

            await ftpSession.DownloadAsync(remotePath, localPath, Overwrite, Recursive, cancellationToken);

            return((asyncCodeActivityContext) =>
            {
            });
        }
        private JsValue ConstructGrouping(List <BlittableJsonReaderObject> values)
        {
            var jsValues = ConstructValues();
            var jsKey    = ConstructKey();

            var result = new ObjectInstance(Engine);

            result.Set("values", jsValues, false);
            result.Set("key", jsKey, false);

            return(result);

            JsValue ConstructKey()
            {
                if (_singleField)
                {
                    var index = values[0].GetPropertyIndex(_groupByFields[0].Name);
                    if (index != -1)
                    {
                        BlittableJsonReaderObject.PropertyDetails prop = default;
                        values[0].GetPropertyByIndex(index, ref prop);

                        return(JsValue.FromObject(Engine, prop.Value));
                    }

                    return(JsValue.Null);
                }

                var key = new ObjectInstance(Engine);

                foreach (var groupByField in _groupByFields)
                {
                    var index = values[0].GetPropertyIndex(groupByField.Name);
                    if (index != -1)
                    {
                        BlittableJsonReaderObject.PropertyDetails prop = default;
                        values[0].GetPropertyByIndex(index, ref prop);

                        var propertyName = groupByField.Name;
                        if (groupByField is JsNestedField jsnf)
                        {
                            propertyName = jsnf.PropertyName;
                        }

                        var value = groupByField.GetValue(null, prop.Value);

                        key.Set(propertyName, JsValue.FromObject(Engine, value), throwOnError: false);
                    }
                }

                return(key);
            }

            ArrayInstance ConstructValues()
            {
                var items = new PropertyDescriptor[values.Count];

                for (var i = 0; i < values.Count; i++)
                {
                    var val = values[i];

                    if (JavaScriptIndexUtils.GetValue(Engine, val, out var jsValue, isMapReduce: true) == false)
                    {
                        continue;
                    }

                    items[i] = new PropertyDescriptor(jsValue, true, true, true);
                }

                var jsArray = new ArrayInstance(Engine, items);

                jsArray.SetPrototypeOf(Engine.Array.PrototypeObject);
                jsArray.PreventExtensions();

                return(jsArray);
            }
        }
 public PropertyCompare(PropertyDescriptor property, ListSortDirection direction)
 {
     this._property  = property;
     this._direction = direction;
 }
 public ValueSerializer GetValueSerializerFor(PropertyDescriptor descriptor)
 {
     return(null);
 }
 /// <summary>
 /// Returns the property owner</summary>
 /// <param name="propertyDescriptor">PropertyDescriptor</param>
 /// <returns>Property owner</returns>
 public override object GetPropertyOwner(PropertyDescriptor propertyDescriptor)
 {
     return(m_propertyOwner);
 }
Esempio n. 52
0
        /// <summary>
        /// Make a column from the given PropertyDescriptor
        /// </summary>
        /// <param name="pd"></param>
        /// <returns></returns>
        public virtual OLVColumn MakeColumnFromPropertyDescriptor(PropertyDescriptor pd)
        {
            OLVColumnAttribute attr = pd.Attributes[typeof(OLVColumnAttribute)] as OLVColumnAttribute;

            return(MakeColumn(pd.Name, DisplayNameToColumnTitle(pd.DisplayName), !pd.IsReadOnly, pd.PropertyType, attr));
        }
 /// <summary>
 /// Removes any sort applied with ApplySortCore if sorting is implemented
 /// </summary>
 protected override void RemoveSortCore()
 {
     _sortDirection = ListSortDirection.Ascending;
     _sortProperty  = null;
     _isSorted      = false; //thanks Luca
 }
Esempio n. 54
0
        internal void WithField(string name, string jsonPath           = null, Type fieldType = null, ChoFieldValueTrimOption fieldValueTrimOption = ChoFieldValueTrimOption.Trim, string fieldName = null, Func <object, object> valueConverter = null,
                                Func <object, object> itemConverter    = null,
                                Func <object, object> customSerializer = null,
                                object defaultValue = null, object fallbackValue = null, string fullyQualifiedMemberName = null,
                                string formatText   = null, bool?isArray         = null, string nullValue = null, Type recordType = null,
                                Type subRecordType  = null, Func <JObject, Type> fieldTypeSelector = null)
        {
            ChoGuard.ArgumentNotNull(recordType, nameof(recordType));

            if (!name.IsNullOrEmpty())
            {
                if (subRecordType != null)
                {
                    MapRecordFieldsForType(subRecordType);
                }

                string fnTrim = fieldName.IsNullOrWhiteSpace() ? name.NTrim() : fieldName;
                ChoJSONRecordFieldConfiguration fc = null;
                PropertyDescriptor pd = null;
                if (JSONRecordFieldConfigurations.Any(o => o.FieldName == fnTrim))
                {
                    fc = JSONRecordFieldConfigurations.Where(o => o.FieldName == fnTrim).First();
                    JSONRecordFieldConfigurations.Remove(fc);
                    pd = ChoTypeDescriptor.GetNestedProperty(recordType, fullyQualifiedMemberName.IsNullOrWhiteSpace() ? name : fullyQualifiedMemberName);
                }
                else if (subRecordType != null)
                {
                    pd = ChoTypeDescriptor.GetNestedProperty(subRecordType, fullyQualifiedMemberName.IsNullOrWhiteSpace() ? name : fullyQualifiedMemberName);
                }
                else
                {
                    pd = ChoTypeDescriptor.GetNestedProperty(recordType, fullyQualifiedMemberName.IsNullOrWhiteSpace() ? name : fullyQualifiedMemberName);
                }

                var nfc = new ChoJSONRecordFieldConfiguration(fnTrim, pd != null ? ChoTypeDescriptor.GetPropetyAttribute <ChoJSONRecordFieldAttribute>(pd) : null,
                                                              pd != null ? pd.Attributes.OfType <Attribute>().ToArray() : null)
                {
                };
                nfc.JSONPath             = !jsonPath.IsNullOrWhiteSpace() ? jsonPath : nfc.JSONPath;
                nfc.FieldType            = fieldType != null ? fieldType : nfc.FieldType;
                nfc.FieldValueTrimOption = fieldValueTrimOption;
                nfc.FieldName            = fieldName.IsNullOrWhiteSpace() ? (name.IsNullOrWhiteSpace() ? nfc.FieldName : name) : fieldName;
                nfc.ValueConverter       = valueConverter != null ? valueConverter : nfc.ValueConverter;
                nfc.CustomSerializer     = customSerializer != null ? customSerializer : nfc.CustomSerializer;
                nfc.DefaultValue         = defaultValue != null ? defaultValue : nfc.DefaultValue;
                nfc.FallbackValue        = fallbackValue != null ? fallbackValue : nfc.FallbackValue;
                nfc.FormatText           = !formatText.IsNullOrWhiteSpace() ? formatText : nfc.FormatText;
                nfc.ItemConverter        = itemConverter != null ? itemConverter : nfc.ItemConverter;
                nfc.IsArray           = isArray != null ? isArray : nfc.IsArray;
                nfc.NullValue         = !nullValue.IsNullOrWhiteSpace() ? nullValue : nfc.NullValue;
                nfc.FieldTypeSelector = fieldTypeSelector != null ? fieldTypeSelector : nfc.FieldTypeSelector;

                if (fullyQualifiedMemberName.IsNullOrWhiteSpace())
                {
                    nfc.PropertyDescriptor = fc != null ? fc.PropertyDescriptor : pd;
                    nfc.DeclaringMember    = fc != null ? fc.DeclaringMember : fullyQualifiedMemberName;
                }
                else
                {
                    if (subRecordType == null)
                    {
                        pd = ChoTypeDescriptor.GetNestedProperty(recordType, fullyQualifiedMemberName);
                    }
                    else
                    {
                        pd = ChoTypeDescriptor.GetNestedProperty(subRecordType, fullyQualifiedMemberName);
                    }

                    nfc.PropertyDescriptor = pd;
                    nfc.DeclaringMember    = fullyQualifiedMemberName;
                }
                if (pd != null)
                {
                    if (nfc.FieldType == null)
                    {
                        nfc.FieldType = pd.PropertyType;
                    }
                }

                if (subRecordType == null)
                {
                    JSONRecordFieldConfigurations.Add(nfc);
                }
                else
                {
                    AddFieldForType(subRecordType, nfc);
                }
            }
        }
Esempio n. 55
0
        private static object GetViaCustomTypeDescriptor(object obj, PropertyDescriptor descriptor)
        {
            var customTypeDescriptor = obj as ICustomTypeDescriptor;

            return(customTypeDescriptor != null?customTypeDescriptor.GetPropertyOwner(descriptor) : obj);
        }
Esempio n. 56
0
 public object GetPropertyOwner(PropertyDescriptor pd)
 {
     return(null);
 }
Esempio n. 57
0
 public virtual object?GetPropertyOwner(PropertyDescriptor pd) => null;
        public void ChangeParent()
        {
            Cursor current = Cursor.Current;
            // create a transaction so this happens as an atomic unit.
            DesignerTransaction changeParent = _host.CreateTransaction("Add ToolStripContainer Transaction");

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                //Add a New ToolStripContainer to the RootComponent ...
                Control root = _host.RootComponent as Control;
                if (_host.GetDesigner(root) is ParentControlDesigner rootDesigner)
                {
                    // close the DAP first - this is so that the autoshown panel on drag drop here is not conflicting with the currently opened panel
                    // if the verb was called from the panel
                    ToolStrip toolStrip = _designer.Component as ToolStrip;
                    if (toolStrip != null && _designer != null && _designer.Component != null && _provider != null)
                    {
                        DesignerActionUIService dapuisvc = _provider.GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
                        dapuisvc.HideUI(toolStrip);
                    }

                    // Get OleDragHandler ...
                    ToolboxItem        tbi = new ToolboxItem(typeof(System.Windows.Forms.ToolStripContainer));
                    OleDragDropHandler ddh = rootDesigner.GetOleDragHandler();
                    if (ddh != null)
                    {
                        IComponent[] newComp = ddh.CreateTool(tbi, root, 0, 0, 0, 0, false, false);
                        if (newComp[0] is ToolStripContainer tsc)
                        {
                            if (toolStrip != null)
                            {
                                IComponentChangeService changeSvc = _provider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
                                Control            newParent      = GetParent(tsc, toolStrip);
                                PropertyDescriptor controlsProp   = TypeDescriptor.GetProperties(newParent)["Controls"];
                                Control            oldParent      = toolStrip.Parent;
                                if (oldParent != null)
                                {
                                    changeSvc.OnComponentChanging(oldParent, controlsProp);
                                    //remove control from the old parent
                                    oldParent.Controls.Remove(toolStrip);
                                }

                                if (newParent != null)
                                {
                                    changeSvc.OnComponentChanging(newParent, controlsProp);
                                    //finally add & relocate the control with the new parent
                                    newParent.Controls.Add(toolStrip);
                                }

                                //fire our comp changed events
                                if (changeSvc != null && oldParent != null && newParent != null)
                                {
                                    changeSvc.OnComponentChanged(oldParent, controlsProp, null, null);
                                    changeSvc.OnComponentChanged(newParent, controlsProp, null, null);
                                }

                                //Set the Selection on the new Parent ... so that the selection is restored to the new item,
                                if (_provider.GetService(typeof(ISelectionService)) is ISelectionService selSvc)
                                {
                                    selSvc.SetSelectedComponents(new IComponent[] { tsc });
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (e is System.InvalidOperationException)
                {
                    IUIService uiService = (IUIService)_provider.GetService(typeof(IUIService));
                    uiService.ShowError(e.Message);
                }

                if (changeParent != null)
                {
                    changeParent.Cancel();
                    changeParent = null;
                }
            }
            finally
            {
                if (changeParent != null)
                {
                    changeParent.Commit();
                    changeParent = null;
                }
                Cursor.Current = current;
            }
        }
Esempio n. 59
0
 public int Find(PropertyDescriptor property, object key)
 {
     return(BindingListImpl.Find(property, key));
 }
Esempio n. 60
0
 public void AddIndex(PropertyDescriptor property)
 {
     BindingListImpl.AddIndex(property);
 }