lundi 14 mai 2018

What will be the type for operators?

I want compare two values using the operator in reflections. Where I will be passing an expected value and the type of operator for comparison.

I want to do comparison dynamically based on the expected value and type of operator for how to compare.

Dictionary<string,operator type> dict = new Dictionary<string,operator type>();
dict.Add("firstPropertyValue", >);
dict.Add("secondPropertyValue", !=);

void validate(Dictionary<string,operator type> temp)
{
   foreach(var item in temp)
   {
      if(actualvalue (item.value(operator)) item.key){//do something}
   }
}

this is what i want to verify. Is there any way to do it. Any help would be appreciated. Actual values I am getting from the object using reflections. While using reflections, as i will get the values of the properties at run time, I want the operator to be passed and do the validation at run time.





Aucun commentaire:

Enregistrer un commentaire