This project is read-only.

Quick Example

PDFX.png

The depicted algebra hierarchy represents a C# class. Green circles stand for Input Properties while purple circles indicate calculated properties. The arrows show the underlying math operations as well as the property dependencies.

PDFXClassDiagram.png

As the developer of such a scenario, you're responsible to ensure that all directly and indirectly dependent properties get reevaluated when an input property changes. Furthermore, for efficiency reasons, you also want to ensure that all unrelated properties do not get reevaluated.

If, for example, Property D1 changes, it is necessary to reevaluate C1, B1 and A1.
However, a change of D3 requires a reevaluation of only C2, B1, B2 and A1.

Using the PDFx, you don't have to manually hardcode those relationships anymore but can rather rely on the library taking care of this job for you.
All you have to do is register the relationships in human readable code within the implementation of a property:

class SimplePropertyDependencyVM : BindableExt
{
	public int A1
	{
		get
		{
			Property(() => A1)
				.Depends(p => p.On(() => B1)
						.AndOn(() => B2));

			return B1 + B2;
		}
	}

	public int B1
	{
		get
		{
			Property(() => B1)
				.Depends(p => p.On(() => C1)
						.AndOn(() => C2));

			return 2 * C1 - C2;
		}
	}

	public int B2
	{
		get
		{
			Property(() => B2)
				.Depends(p => p.On(() => C2)
						.AndOn(() => C3));

			return -C2 + C3;
		}
	}

	public int C1
	{
		get
		{
			Property(() => C1)
				.Depends(p => p.On(() => D1)
						.AndOn(() => D2));

			return D1 + D2;
		}
	}

	public int C2
	{
		get
		{
			Property(() => C2)
				.Depends(p => p.On(() => D3));

			return 3 * D3;
		}
	}

	public int C3
	{
		get
		{
			Property(() => C3)
				.Depends(p => p.On(() => D4)
						.AndOn(() => D5));

			return D4 + D5;
		}
	}

	private int _d1;
	public int D1
	{
		get { return _d1; }
		set
		{
			_d1 = value; 
			NotifyPropertyChanged(() => D1);
		}
	}

	private int _d2;
	public int D2
	{
		get { return _d2; }
		set
		{
			_d2 = value;
			NotifyPropertyChanged(() => D2);
		}
	}

	private int _d3;
	public int D3
	{
		get { return _d3; }
		set
		{
			_d3 = value;
			NotifyPropertyChanged(() => D3);
		}
	}

	private int _d4;
	public int D4
	{
		get { return _d4; }
		set
		{
			_d4 = value;
			NotifyPropertyChanged(() => D4);
		}
	}

	private int _d5;
	public int D5
	{
		get { return _d5; }
		set
		{
			_d5 = value;
			NotifyPropertyChanged(() => D5);
		}
	}
}

Last edited May 9, 2013 at 7:17 PM by KevinStumpf, version 11

Comments

No comments yet.