本文整理汇总了C#中PropertyDescriptor类的典型用法代码示例。如果您正苦于以下问题:C# PropertyDescriptor类的具体用法?C# PropertyDescriptor怎么用?C# PropertyDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyDescriptor类属于命名空间,在下文中一共展示了PropertyDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
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);
}
示例2: GetProperties
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;
});
}
示例3: GeneratePropertySet
protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
{
if (prop.Name == "Alpha" && Alpha == -1)
return;
else
base.GeneratePropertySet (ctx, var, prop);
}
示例4: PropertyDescriptor
/// <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);
}
示例5: Create
/// <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;
}
示例6: DefineOwnProperty
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;
}
示例7: PropertyDescriptor
public PropertyDescriptor(PropertyDescriptor descriptor)
{
Get = descriptor.Get;
Set = descriptor.Set;
Value = descriptor.Value;
Enumerable = descriptor.Enumerable;
Configurable = descriptor.Configurable;
Writable = descriptor.Writable;
}
示例8: GetPropertyAsString
bool IDictionaryPropertySetter.SetPropertyValue(
IDictionaryAdapterFactory factory, IDictionary dictionary,
string key, ref object value, PropertyDescriptor property)
{
if (value != null)
{
value = GetPropertyAsString(property, value);
}
return true;
}
示例9: Initialize
public override void Initialize (PropertyDescriptor prop)
{
base.Initialize (prop);
entry = new Gtk.Entry ();
entry.HasFrame = false;
entry.Show ();
entry.Changed += EntryChanged;
Add (entry);
}
示例10: NotifyPropertyChanged
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));
}
示例11: BuildColumnConstraints
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;
}
示例12: ApplyValidationRules
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);
}
}
}
示例13: Validate
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());
}
示例14: Initialize
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);
}
}
示例15: Initialize
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);
}