Please refer to Library Versions to find out whether your platform specific PDFx version supports Sanity Checks

Sanity Checks

In Debug mode, the PDFx performs certain resource expensive Sanity Checks that try to capture typical developer mistakes that are not caught at compile time.

Both the BindableExt's Property and CachedValue methods ensure that the Property that is being pointed to in the first method parameter equals the Property from which either method is being called.

In the following example, the PDFx notices upon first access of the properties DependentPropertyMistake and CachedPropertyMistake that the way they use the PDFx is incorrect.

class WrongPDFXUsageDemonstration : BindableExt
{
	private int _inputValue;
	public int InputValue
	{
		get { return _inputValue; }
		set
		{
			_inputValue = value;
			NotifyPropertyChanged(() => InputValue);
		}
	}

	public int DependentPropertyMistake
	{
		get
		{
			Property(() => InputValue) //Should point to DependentPropertyMistake
				.Depends(p => p.On(() => InputValue));

			return InputValue*2;
		}
	}

	public int DependentPropertyProper
	{
		get
		{
			Property(() => DependentPropertyProper)
				.Depends(p => p.On(() => InputValue));

			return InputValue * 2;
		}
	}

	public int CachedPropertyMistake
	{
		get
		{
			return CachedValue(() => InputValue, () => InputValue * 5);
			//Should point to CachedPropertyMistake
		}
	}

	public int CachedPropertyProper
	{
		get
		{
			return CachedValue(() => CachedPropertyProper, () => InputValue * 5);
		}
	}
}






Last edited May 15, 2013 at 9:27 PM by KevinStumpf, version 2

Comments

No comments yet.