Properties' setters and getters are implemented as methods (get_X and set_X).
Writing Projection = value
within the Projection's setter, causes a recursive call to set_Projection()
from within set_Projection()
. (The same applies to get_Projection()
.)
Since there is no condition surrounding the call, the recursion is infinite.
As for public T PropA { get; set; }
, it is sugar syntax for:
private T _PropA;
public T PropA
{
get
{
return _PropA;
}
set
{
_PropA = value;
}
}
What you should do is:
private Matrix _projection;
public Matrix Projection
{
get
{
return _projection;
}
protected set
{
// Make sure that Matrix is a structure and not a class
// override == and != operators in Matrix (and Equals and GetHashCode)
// If Matrix has to be a class, use !_project.Equals(value) instead
// Consider using an inaccurate compare here instead of == or Equals
// so that calculation inaccuracies won't require recalculation
if (_projection != value)
{
_projection = value;
generateFrustum();
}
}
}