Files
skills/propdp-generator/source/DependencyPropertyAttribute.cs

162 lines
6.3 KiB
C#

// internal sealed class DependencyPropertyAttribute : global::System.Attribute
// ... 省略
[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = true)]
[global::System.Diagnostics.Conditional("DEPENDENCY_PROPERTY_GENERATOR_ATTRIBUTES")]
internal sealed class DependencyPropertyAttribute<T> : global::System.Attribute
{
/// <summary>
/// Name of this dependency property.
/// </summary>
public string Name { get; }
/// <summary>
/// Type of this dependency property.
/// </summary>
public global::System.Type Type { get; }
/// <summary>
/// Default value of this dependency property. <br/>
/// If you need to pass a new() expression, use <see cref="DefaultValueExpression"/>. <br/>
/// Default - <see langword="default(type)"/>.
/// </summary>
public T? DefaultValue { get; set; }
/// <summary>
/// Default value expression of this dependency property. <br/>
/// Used to pass a new() expression to an initializer. <br/>
/// Default - <see langword="null"/>.
/// </summary>
public string? DefaultValueExpression { get; set; }
/// <summary>
/// Avalonia: For direct properties, the generated property is read-only and the setter is non-public. <br/>
/// Default - <see langword="false"/>.
/// </summary>
public bool IsReadOnly { get; set; }
/// <summary>
/// Avalonia: Direct properties are a lightweight version of styled properties. <br/>
/// Default - <see langword="false"/>.
/// </summary>
public bool IsDirect { get; set; }
/// <summary>
/// Description of this dependency property. <br/>
/// The property will contain a <see cref="global::System.ComponentModel.DescriptionAttribute"/> with this value. <br/>
/// This will also be used in the xml documentation if not explicitly specified. <br/>
/// Default - <see langword="null"/>.
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Category of this dependency property. <br/>
/// The property will contain a <see cref="global::System.ComponentModel.CategoryAttribute"/> with this value. <br/>
/// Default - <see langword="null"/>.
/// </summary>
public string? Category { get; set; }
/// <summary>
/// Type converter of this dependency property. <br/>
/// The property will contain a <see cref="global::System.ComponentModel.TypeConverterAttribute"/> with this value. <br/>
/// Default - <see langword="null"/>.
/// </summary>
public global::System.Type? TypeConverter { get; set; }
/// <summary>
/// The property will contain a <see cref="global::System.ComponentModel.BindableAttribute"/> with this value. <br/>
/// Default - <see langword="null"/>.
/// </summary>
public bool Bindable { get; set; }
/// <summary>
/// The property will contain a <see cref="global::System.ComponentModel.BrowsableAttribute"/> with this value. <br/>
/// Default - <see langword="null"/>.
/// </summary>
public bool Browsable { get; set; }
/// <summary>
/// The property will contain a <see cref="global::System.ComponentModel.DesignerSerializationVisibilityAttribute"/> with this value. <br/>
/// Default - <see langword="null"/>.
/// </summary>
public global::System.ComponentModel.DesignerSerializationVisibility DesignerSerializationVisibility { get; set; }
/// <summary>
/// The property will contain a <see cref="global::System.CLSCompliantAttribute"/> with this value. <br/>
/// Default - <see langword="null"/>.
/// </summary>
public bool ClsCompliant { get; set; }
/// <summary>
/// The dependency property xml documentation. <br/>
/// Default - "&lt;summary&gt;&lt;/summary&gt;".
/// </summary>
public string XmlDocumentation { get; set; } = string.Empty;
/// <summary>
/// The property getter/setter xml documentation. <br/>
/// Default - "&lt;summary&gt;&lt;/summary&gt;".
/// </summary>
public string PropertyXmlDocumentation { get; set; } = string.Empty;
/// <summary>
/// For values other than default(type), will bind/rebind/remove the
/// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event. <br/>
/// It is recommended to specify as nameof(Control.SomeEvent) or another Avalonia event name. <br/>
/// Default - string.Empty.
/// </summary>
public string BindEvent { get; set; } = string.Empty;
/// <summary>
/// For values other than default(type), will bind/rebind/remove the
/// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event. <br/>
/// It is recommended to specify as nameof(Control.SomeEvent) or another Avalonia event name. <br/>
/// Default - <see langword="null"/>.
/// </summary>
public string[]? BindEvents { get; set; }
/// <summary>
/// Allows to set a custom name for the OnChanged method call, allowing this method to be non-partial.
/// </summary>
public string OnChanged { get; set; } = string.Empty;
/// <summary>
/// Avalonia: The values of this property are inherited by child elements.
/// </summary>
public bool Inherits { get; set; }
/// <summary>
/// Avalonia: Default BindingMode. <br/>
/// Default - <see cref="DefaultBindingMode.Default"/>.
/// </summary>
public DefaultBindingMode DefaultBindingMode { get; set; } = DefaultBindingMode.Default;
/// <summary>
/// Avalonia-DirectProperty: Whether the property is interested in data validation. <br/>
/// Default - <see langword="false"/>.
/// </summary>
public bool EnableDataValidation { get; set; }
/// <summary>
/// Avalonia: partial method for coerce callback will be created for styled or attached properties.
/// </summary>
public bool Coerce { get; set; }
/// <summary>
/// Avalonia: partial method for validate callback will be created for styled or attached properties. <br/>
/// Default - <see langword="false"/>.
/// </summary>
public bool Validate { get; set; }
/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <exception cref="global::System.ArgumentNullException"></exception>
public DependencyPropertyAttribute(
string name)
{
Name = name ?? throw new global::System.ArgumentNullException(nameof(name));
Type = typeof(T);
}
}