private static bool ProcessPropertyInfo( object testSubject, SchemaValidationResult validationResults,
PropertyInfo propertyInfo,
Dictionary<string, XmlSchemaObject> xmlSchemaObjects, bool isValid)
{
string name = propertyInfo.Name;
object oValue = propertyInfo.GetValue( testSubject, null );
bool ok2Run = false;
if (oValue != null)
{
MethodInfo mmi = oValue.GetType().GetMethod( "Validate" );
var collection = oValue as ICollection;
if (collection != null)
{
//Need to get the type of each item schema
foreach (object obj in collection)
{
MethodInfo mi = obj.GetType().GetMethod( "Validate" );
if (mi != null)
{
var result = new SchemaValidationResult( name );
object[] p = {result};
try
{
mi.Invoke( obj, p );
object po = p[0];
validationResults.AddResult( result );
}
catch (Exception)
{
int i = 0;
}
}
}
ok2Run = true;
}
else if (mmi != null)
{
var result = new SchemaValidationResult( name );
object[] p = {result};
mmi.Invoke( oValue, p );
validationResults.AddResult( result );
isValid = !result.HasErrors();
}
else
{
ok2Run = true;
}
}
else
{
ok2Run = true;
}
if (xmlSchemaObjects.ContainsKey( name ) && ok2Run)
{
string value = oValue != null ? oValue.ToString() : null;
XmlSchemaObject schemaObject = xmlSchemaObjects[name];
var attribute = schemaObject as XmlSchemaAttribute;
var element = schemaObject as XmlSchemaElement;
if (attribute != null)
isValid &= ValidateAttribute( attribute, value, validationResults );
if (element != null)
{
string ename = element.Name;
string enamespace = element.QualifiedName.Namespace;
bool isNillable = element.IsNillable;
isValid &= ValidateElement( element, oValue, validationResults );
var sct = element.ElementSchemaType as XmlSchemaComplexType;
if (sct != null)
{
//Validate(sct, o, errors);
int i = 0;
}
//Validate(enamespace, ename, o, errors);
}
}
else
{
int i = 0;
}
return isValid;
}