public void InitializeContext() { this.settings = new Mock<IPropertyBindingSettings>(); this.component = new DesignProperty(this.settings.Object); this.component.Attributes = new Attribute[0]; this.component.Type = typeof(int); this.descriptor = new DesignPropertyValueDescriptor("AProperty", typeof(int), new System.ComponentModel.Int32Converter(), new Attribute[0]); }
/// <summary> /// Creates a new instance of the <see cref="DesignValueProvider"/> class. /// </summary> /// <param name="property">The property.</param> /// <param name="name">The name of the property.</param> public DesignValueProvider(DesignProperty property, string name) { Guard.NotNull(() => property, property); Guard.NotNull(() => name, name); this.DesignProperty = property; this.Name = name; }
public void InitializeContext() { this.settings = new Mock<IPropertyBindingSettings>(); this.property = new DesignProperty(this.settings.Object) { Attributes = new Attribute[0], Type = typeof(int) }; }
public void InitializeContext() { this.settings = new Mock<IPropertyBindingSettings>(); this.component = new DesignProperty(this.settings.Object); this.component.Attributes = new Attribute[0]; this.component.Type = typeof(string); var innerDescriptor = new Mock<PropertyDescriptor>("foo", new Attribute[0]); innerDescriptor.Setup(x => x.Name).Returns("Property"); innerDescriptor.Setup(x => x.Attributes).Returns(new AttributeCollection()); this.descriptor = new DesignPropertyValueProviderDescriptor(innerDescriptor.Object); }
private static TypeConverter GetTypeConverter(DesignProperty designProperty) { TypeConverter converter = null; // Get user-defined TypeConverter of property first var typeConverterAttribute = designProperty.Attributes.OfType <TypeConverterAttribute>().FirstOrDefault(); if (typeConverterAttribute != null) { var converterType = Type.GetType(typeConverterAttribute.ConverterTypeName); if (converterType != null) { converter = (TypeConverter)Activator.CreateInstance(converterType); } } // Get the default converter for the type if (converter == null) { converter = TypeDescriptor.GetConverter(designProperty.Type); } return(converter); }
/// <summary> /// Initializes a new instance of the <see cref="DesignPropertyDescriptor"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="designProperty">The design property.</param> public DesignPropertyDescriptor(ICustomTypeDescriptor parent, DesignProperty designProperty) : base(parent) { this.parent = parent; this.designProperty = designProperty; }
private static TypeConverter GetTypeConverter(DesignProperty designProperty) { TypeConverter converter = null; // Get user-defined TypeConverter of property first var typeConverterAttribute = designProperty.Attributes.OfType<TypeConverterAttribute>().FirstOrDefault(); if (typeConverterAttribute != null) { var converterType = Type.GetType(typeConverterAttribute.ConverterTypeName); if (converterType != null) { converter = (TypeConverter)Activator.CreateInstance(converterType); } } // Get the default converter for the type if (converter == null) { converter = TypeDescriptor.GetConverter(designProperty.Type); } return converter; }
/// <summary> /// Creates a new instance of the <see cref="DesignValueProvider"/> class. /// </summary> /// <param name="property">The property.</param> /// <param name="valueProvider">The value provider.</param> public DesignValueProvider(DesignProperty property, IValueProviderBindingSettings valueProvider) : this(property, (valueProvider != null && !string.IsNullOrEmpty(valueProvider.TypeId)) ? valueProvider.TypeId : string.Empty) { this.ValueProvider = valueProvider; }
private static void SetSelectedItem(ITypeDescriptorContext context, ISolutionPicker picker, IUriReferenceService uriService, DesignProperty prop) { if (prop != null) { var value = prop.GetValue().ToString(); if (!String.IsNullOrEmpty(value)) { var item = uriService.TryResolveUri<IItemContainer>(new Uri(value)); if (item != null) { picker.SelectedItem = item; } } } }