title: Get Value Of PropertyInfo
body: <p>I'm creating a small validation framework, I've a custom <code>Validation Attribute</code> which is assignable to methods and a <code>IsValid</code> property in <code>ValidationCore</code> class. When <code>IsValid</code> called inside the method my <code>ValidationCore</code> finds a caller method and get its attribute assigned to method. My custom <code>Validation</code> attribute has a property name named <code>TypeToValidate</code>. So when I find validation attribute I look for any types in class scope of that type. I don't have any problem till now, but the problem is when I want to get the value of property which I've to validate I don't have any instance of that class to get that property value. I don't know how can I handle this situation please help me.</p>
  
  <p>This is my sample :</p>
  
  <pre><code>public class TestClass
  {
      public static TestModel Model { get; set; }
      public static ModelValidator ModelState
      {
          get { return new ModelValidator(); }
      }
  
      [Validate(typeof(TestModel))]
      public static void DoSomething()
      {
          if (ModelState.IsValid)
          {
              // Do something else....
          }
      }
  }
  </code></pre>
  
  <p><strong>Edit :</strong> This is my <code>IsValid</code> property</p>
  
  <pre><code>    public virtual Boolean IsValid
      {
          get
          {
              // Get IsValid caller method
              var method = GetCallerMethod();
  
              // Get method attribute
              var Attrib = GetMethodAttribute(typeof(ValidateAttribute), method);
  
              // Get model to validate inside class scope
              var modelProperty = GetModelToValidateInClassScope(Attrib, method);
  
              if (modelProperty != null)
              {
                  ValidateModel(modelProperty);
              }
  
              ....
          }
      }
  </code></pre>
  
  <p>and here is <code>ValidateModel</code> method :</p>
  
  <pre><code>    protected virtual void ValidateModel(PropertyInfo modelProperty)
      {
          // Here I've model property
          // But I can't get its value
          var model = modelProperty.GetValue(null, null);
          var properties = model.GetType().GetProperties(
                          BindingFlags.FlattenHierarchy |
                          BindingFlags.Public |
                          BindingFlags.Instance |
                          BindingFlags.DeclaredOnly);
  
  
          foreach (var propertyInfo in properties)
          {
              // Add error to error list
              GetPropertyErrors(model, propertyInfo);
          }
      }
  </code></pre>
  
  <p>Thanks in advance.</p>