//
//
//
//
// $Revision: 3863 $
//
using System;
namespace ICSharpCode.Core
{
///
/// Compares two strings.
/// The strings are passed through the StringParser, so it is possible to compare
/// SharpDevelop properties.
/// Useful if you want to run a command only when a setting is active to prevent
/// loading your addin if that setting isn't set.
///
///
/// The first string.
///
///
/// The second string.
///
///
/// The mode of the comparison: a field of the System.StringComparison enumeration. The default is
/// 'OrdinalIgnoreCase'.
///
///
/// <Condition name = "Compare" string = "${property:SharpDevelop.FiletypesRegisterStartup}" equals = "True">
///
public class CompareConditionEvaluator : IConditionEvaluator
{
public bool IsValid(object caller, Condition condition)
{
string comparisonTypeText = condition.Properties["comparisonType"];
StringComparison comparisonType;
if (string.IsNullOrEmpty(comparisonTypeText))
comparisonType = StringComparison.OrdinalIgnoreCase;
else
comparisonType = (StringComparison)Enum.Parse(typeof(StringComparison), comparisonTypeText);
return string.Equals(StringParser.Parse(condition.Properties["string"]),
StringParser.Parse(condition.Properties["equals"]),
comparisonType);
}
}
}