T
Tony Johansson
Hello!
Here I have a simple example of a custom defined Attribute class called
CodeStatus.
Now to my question when I debug this application and I set a breakpoint in
the CodeStatus attribute class
I will never enter that code. So what is the point in using attribute when
the Attribute class is never executed.
I have probably misunderstood something here about Attribute.
So when is the attribute class CodeStatus called ?
Why is it not possible to set a breakpoint that will be hit when the
Attribute class is executed.
using System;
public class CodeStatus : System.Attribute
{
private string STATUS;
private string TESTER;
private string CODER;
public CodeStatus(string Status)
{
this.STATUS = Status;
}
public string Tester
{
set { TESTER = value; }
get { return TESTER; }
}
public string Coder
{
set { CODER = value; }
get { return CODER; }
}
public override string ToString()
{ return STATUS; }
}
[CodeStatus("Final", Coder="Bills")]
public class Rectangle
{
private int length;
private int height;
public Rectangle(int _length, int _height)
{
length = _length;
height = _height;
}
public int Length
{
set { length = value; }
get { return length; }
}
public int Height
{
set { height = value; }
get { return height; }
}
}
public class myApp
{
static void Main(string[] args)
{
Rectangle rect = new Rectangle(5,7);
}
}
//Tony
Here I have a simple example of a custom defined Attribute class called
CodeStatus.
Now to my question when I debug this application and I set a breakpoint in
the CodeStatus attribute class
I will never enter that code. So what is the point in using attribute when
the Attribute class is never executed.
I have probably misunderstood something here about Attribute.
So when is the attribute class CodeStatus called ?
Why is it not possible to set a breakpoint that will be hit when the
Attribute class is executed.
using System;
public class CodeStatus : System.Attribute
{
private string STATUS;
private string TESTER;
private string CODER;
public CodeStatus(string Status)
{
this.STATUS = Status;
}
public string Tester
{
set { TESTER = value; }
get { return TESTER; }
}
public string Coder
{
set { CODER = value; }
get { return CODER; }
}
public override string ToString()
{ return STATUS; }
}
[CodeStatus("Final", Coder="Bills")]
public class Rectangle
{
private int length;
private int height;
public Rectangle(int _length, int _height)
{
length = _length;
height = _height;
}
public int Length
{
set { length = value; }
get { return length; }
}
public int Height
{
set { height = value; }
get { return height; }
}
}
public class myApp
{
static void Main(string[] args)
{
Rectangle rect = new Rectangle(5,7);
}
}
//Tony