How to build a Fluent Nested Guard API : <p>I am building a simple Guard API to protect against illegal parameters being passed to functions and so on.</p>

<p>I have the following code:</p>

<pre><code>public static class Guard
{
    public static GuardArgument&lt;T&gt; Ensure&lt;T&gt;(T value, string argumentName)
    {
        return new GuardArgument&lt;T&gt;(value, argumentName);
    }
}

public class GuardArgument&lt;T&gt;
{
    public GuardArgument(T value, string argumentName)
    {
        Value = value;
        Name = Name;
    }

    public T Value { get; private set; }
    public string Name { get; private set; }
}

// Example extension for validity checks
public static GuardArgument&lt;T&gt; IsNotNull&lt;T&gt;(this GuardArgument&lt;T&gt; guardArgument, string errorMessage)
{
    if (guardArgument.Value == null)
    {
        throw new ArgumentNullException(guardArgument.Name, errorMessage);
    }

    return guardArgument;
}     
</code></pre>

<p>At the moment the code can be used in a similar way to (note this is just a dumb example):</p>

<pre><code>void DummyMethod(int? someObject) {

    Guard.Ensure(someObject, "someObject")
       .IsNotNull()
       .IsGreaterThan(0)
       .IsLessThan(10);
}
</code></pre>

<p>This all works fine.  What I want to be able to do now is extend the API to include child properties in the checks in the following way:</p>

<pre><code>Guard.Ensure(someObject, "someObject")
    .IsNotNull()
    .Property(
        (x =&gt; x.ChildProp1, "childProp1")
           .IsNotNull()
           .IsGreaterThan(10)
     )
     .Property(
        (x =&gt; x.ChildProp2, "childProp2")
           .IsNotNull()
           .IsLessThan(10)
     );
</code></pre>

<p>Obviously the new <code>.Property</code> method needs to return the parent <code>GuardArgument</code> in order to chain. Furthermore the child property needs to be able to use the existing check methods (<code>IsNotNull()</code> etc) to avoid code duplication.</p>

<p>I cannot work out how to construct the lambda/Property function parameters or where the <code>.Property</code> method should be located - i.e. should it be a property on the <code>GuardArgument</code> or somewhere else, or even if there is a better structure to the API.</p>
