本文整理汇总了C#中Condition.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Condition.GetType方法的具体用法?C# Condition.GetType怎么用?C# Condition.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Condition
的用法示例。
在下文中一共展示了Condition.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsMeetsRequirements
/// <summary>
/// Check to see if the specified automation element meets the requirements of the specified condition.
/// </summary>
/// <param name="condition">The condition to check.</param>
/// <param name="element">The automation element to check.</param>
/// <returns>True if the automation element meets the condition's requirements. False otherwise.</returns>
public static bool IsMeetsRequirements(Condition condition, AutomationElement element)
{
var type = condition.GetType();
if (condition == Condition.TrueCondition)
// Always return true.
return true;
if (condition == Condition.FalseCondition)
// Always returns false.
return false;
if (type == typeof(NotCondition))
// Return the negation of the inner condition.
return !IsMeetsRequirements(((NotCondition) condition).Condition, element);
if (type == typeof(OrCondition))
// Return true if any of the inner conditions are true.
return ((OrCondition) condition).GetConditions().Any(inner => IsMeetsRequirements(inner, element));
if (type == typeof(AndCondition))
// Return true if all of the inner conditions are true.
return ((AndCondition) condition).GetConditions().All(inner => IsMeetsRequirements(inner, element));
if (type == typeof(StringPropertyCondition))
// Return true if the string property condition matches.
return ((StringPropertyCondition) condition).IsMatch(element);
if (type == typeof(PropertyCondition)) {
// Return true if the property condition matches.
var propertyCondition = (PropertyCondition) condition;
var actual = element.GetCurrentPropertyValue(propertyCondition.Property);
var expected = propertyCondition.Value;
Trace.WriteLine("Checking '" + AutomationPropertyHelper.ToString(actual) + "'='" + AutomationPropertyHelper.ToString(expected) + "'", "UIAutomation-ConditionHelper");
return AutomationPropertyHelper.Equals(actual, expected);
}
// Don't know how to match any other conditions.
throw new NotSupportedException("Condition '" + type + "' is not supported");
}
示例2: FillConditionRow
private void FillConditionRow(DataGridViewRow row, Condition condition)
{
row.Tag = condition;
foreach (DataGridViewColumn col in dgConditions.Columns)
{
foreach (PropertyInfo info in condition.GetType().GetProperties(FLAG))
{
if (info.Name == col.Name)
row.Cells[col.Name].Value = info.GetValue(condition, null).ToString();
}
}
}
示例3: ToString
/// <summary>
/// Gets the string representation of the specified condition.
/// </summary>
/// <param name="condition">The condition.</param>
/// <returns>The string representation.</returns>
public static string ToString(Condition condition)
{
var type = condition.GetType();
if (condition == Condition.TrueCondition)
return "TRUE";
if (condition == Condition.FalseCondition)
return "FALSE";
if (type == typeof(NotCondition))
return "NOT " + ToString(((NotCondition) condition).Condition);
if (type == typeof(OrCondition))
return string.Join(" OR ", ((OrCondition) condition).GetConditions().Select(ToString).ToList());
if (type == typeof(AndCondition))
return string.Join(" AND ", ((AndCondition) condition).GetConditions().Select(ToString).ToList());
if (type == typeof(StringPropertyCondition))
return ToString((StringPropertyCondition) condition);
if (type == typeof(PropertyCondition))
return ToString((PropertyCondition) condition);
// Don't know how to print any other conditions.
throw new NotSupportedException("Condition '" + type + "' not supported");
}
示例4: traiteCondition
private void traiteCondition(Condition conditionAEvaluer)
{
String expressionAEvaluer = conditionAEvaluer.obtenirChaineAEvaluer();
this.remplaceValeurDesVariables(ref expressionAEvaluer);
try
{
bool resultatExpression = (bool)new Expression(expressionAEvaluer).Evaluate();
if (!resultatExpression)
{
if (conditionAEvaluer.GetType() == typeof(TantQue))
{
this.parcourirJusquauProchainFinTantQue();
}
else if (conditionAEvaluer.GetType() == typeof(Si))
{
this.parcourirJusquauProchainFinSi(true);
}
}
}
catch (Exception e)
{
this.expressionAEvaluerInvalide();
}
}