[global::System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
sealed class MyControlAttribute : Attribute
{
    
// See the attribute guidelines at 
    
//  http://go.microsoft.com/fwlink/?LinkId=85236
    readonly string positionalString;

    
// This is a positional argument
    public MyControlAttribute(string positionalString)
    {
        
this.positionalString = positionalString;

        
// TODO: Implement code here
        throw new NotImplementedException();
    }

    
public string PositionalString
    {
        
get { return positionalString; }
    }

    
// This is a named argument
    public int NamedInt { getset; }


    
public ControlTypes ControlName
    { 
getset; }


    
public MyControlAttribute()
    {
        
    }
}

public class MyClass
{
    [MyControl(ControlName 
= ControlTypes.TextBox)]
    
public string MyProperty
    { 
getset; }
}


public enum ControlTypes
{
    TextBox,
    DropDownList,
    Label,
}

相关文章:

  • 2021-08-27
  • 2021-10-16
  • 2021-07-24
  • 2021-11-20
  • 2021-10-02
  • 2021-09-19
  • 2022-01-22
  • 2021-06-08
猜你喜欢
  • 2021-06-25
  • 2021-09-30
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2022-02-09
  • 2021-06-02
相关资源
相似解决方案