本文整理汇总了C#中ComparisonType类的典型用法代码示例。如果您正苦于以下问题:C# ComparisonType类的具体用法?C# ComparisonType怎么用?C# ComparisonType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComparisonType类属于命名空间,在下文中一共展示了ComparisonType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: comparisonTypeToString
private string comparisonTypeToString(ComparisonType type)
{
string result = "";
switch (type) {
case ComparisonType.E: {
result = "=";
break;
}
case ComparisonType.NE: {
result = "!=";
break;
}
case ComparisonType.GT: {
result = ">";
break;
}
case ComparisonType.GTE: {
result = ">=";
break;
}
case ComparisonType.LS: {
result = "<";
break;
}
case ComparisonType.LSE: {
result = "<=";
break;
}
}
return result;
}
示例2: FilterOptions
public FilterOptions(string col, ComparisonType type, string val)
: this()
{
Col = col;
Val = val;
Type = type;
}
示例3: WhereItem
public WhereItem(string field, object value, ComparisonType comparisonType=ComparisonType.Equal,bool parameterize=true)
{
Field = field;
ComparisonType = comparisonType;
Value = value;
Parameterize = parameterize;
}
示例4: CompareTo
/// <summary>
/// Compares to the given value returning true if comparable.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="compareValue">The compare value.</param>
/// <param name="compareType">Type of the compare.</param>
/// <returns></returns>
public static bool CompareTo( this string value, string compareValue, ComparisonType compareType )
{
// Evaluate compare types that are not type specific
switch ( compareType )
{
case ComparisonType.Contains: return value.Contains( compareValue );
case ComparisonType.DoesNotContain: return !value.Contains( compareValue );
case ComparisonType.StartsWith: return value.StartsWith( compareValue, StringComparison.OrdinalIgnoreCase );
case ComparisonType.EndsWith: return value.EndsWith( compareValue, StringComparison.OrdinalIgnoreCase );
case ComparisonType.IsBlank: return string.IsNullOrWhiteSpace( value );
case ComparisonType.IsNotBlank: return !string.IsNullOrWhiteSpace( value );
case ComparisonType.RegularExpression: return Regex.IsMatch( value, compareValue );
}
// numeric compares
decimal? decimalValue = value.AsDecimalOrNull();
decimal? decimalCompareValue = compareValue.AsDecimalOrNull();
if ( decimalValue.HasValue && decimalCompareValue.HasValue )
{
switch ( compareType )
{
case ComparisonType.EqualTo: return decimalValue == decimalCompareValue;
case ComparisonType.GreaterThan: return decimalValue.Value > decimalCompareValue.Value;
case ComparisonType.GreaterThanOrEqualTo: return decimalValue.Value >= decimalCompareValue.Value;
case ComparisonType.LessThan: return decimalValue.Value < decimalCompareValue.Value;
case ComparisonType.LessThanOrEqualTo: return decimalValue.Value <= decimalCompareValue.Value;
case ComparisonType.NotEqualTo: return decimalValue.Value != decimalCompareValue.Value;
}
}
// date time compares
DateTime? datetimeValue = value.AsDateTime();
DateTime? datetimeCompareValue = compareValue.AsDateTime();
if ( datetimeValue.HasValue && datetimeCompareValue.HasValue )
{
switch ( compareType )
{
case ComparisonType.EqualTo: return datetimeValue == datetimeCompareValue;
case ComparisonType.GreaterThan: return datetimeValue.Value > datetimeCompareValue.Value;
case ComparisonType.GreaterThanOrEqualTo: return datetimeValue.Value >= datetimeCompareValue.Value;
case ComparisonType.LessThan: return datetimeValue.Value < datetimeCompareValue.Value;
case ComparisonType.LessThanOrEqualTo: return datetimeValue.Value <= datetimeCompareValue.Value;
case ComparisonType.NotEqualTo: return datetimeValue.Value != datetimeCompareValue.Value;
}
}
// string compares
switch ( compareType )
{
case ComparisonType.EqualTo: return value.Equals( compareValue, StringComparison.OrdinalIgnoreCase );
case ComparisonType.GreaterThan: return value.CompareTo( compareValue ) > 0;
case ComparisonType.GreaterThanOrEqualTo: return value.CompareTo( compareValue ) >= 0;
case ComparisonType.LessThan: return value.CompareTo( compareValue ) < 0;
case ComparisonType.LessThanOrEqualTo: return value.CompareTo( compareValue ) <= 0;
case ComparisonType.NotEqualTo: return !value.Equals( compareValue, StringComparison.OrdinalIgnoreCase );
}
return false;
}
示例5: ConditionMaterial
public ConditionMaterial(string target, ComparisonType targetComp, string calc, int needCount,ComparisonType countComp)
{
Target = target;
TargetComparison = targetComp;
Calc = calc;
NeedCount = needCount;
CountComparison = countComp;
}
示例6: RangeIfClientAttribute
public RangeIfClientAttribute(int minimum, int maximum, string otherProperty, ComparisonType comparisonType, object otherComparisonValue)
{
Minimum = minimum;
Maximum = maximum;
OtherProperty = otherProperty;
ComparisonType = comparisonType;
OtherComparisonValue = otherComparisonValue;
}
示例7: Comparison
public Comparison(ComparisonType t, object controlTarget,
string controlXPath, object controlValue,
object testTarget, string testXPath,
object testValue)
{
type = t;
control = new Detail(controlTarget, controlXPath, controlValue);
test = new Detail(testTarget, testXPath, testValue);
}
示例8: ComparisonFilter
/// <summary>
///
/// </summary>
/// <param name="type"></param>
/// <param name="value"></param>
public ComparisonFilter(ComparisonType type, object value)
{
IComparable r1 = value as IComparable;
if (value != null && r1 == null)
{
throw new ArgumentException("value is not IComparable", "value");
}
m_comparionType = type;
m_value = r1;
}
示例9: ExceptionExpectedAttribute
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.VisualStudio.TestTools.UnitTesting.ExpectedExceptionAttribute" /> class with and expected exception type and a message that describes the exception.</summary>
/// <param name="exceptionType">An expected type of exception to be thrown by a method.</param>
/// <param name="expectedMessage">Message expected to be returned in exception</param>
/// <param name="comparisonType">The manner in which the message is evaluated</param>
/// <param name="noExceptionMessage">The message to be displayed when no exception occurs in test</param>
public ExceptionExpectedAttribute(Type exceptionType, string expectedMessage, ComparisonType comparisonType, string noExceptionMessage)
: base(noExceptionMessage)
{
if (exceptionType == null)
throw new ArgumentNullException(nameof(exceptionType));
if (string.IsNullOrEmpty(expectedMessage))
throw new ArgumentNullException(nameof(expectedMessage));
ExceptionType = exceptionType;
ExceptionMessage = expectedMessage;
ExceptionComparisonType = comparisonType;
}
示例10: GetAccountRecordings
/// <summary>
/// Get account recordings
/// </summary>
/// <param name="dateCreated">Lists all recordings created on or after a certain date. </param>
/// <param name="dateCreatedComparasion">Date created comparasion</param>
/// <param name="page">Used to return a particular page withing the list.</param>
/// <param name="pageSize">Used to specify the amount of list items to return per page.</param>
/// <returns></returns>
public async Task<RecordingResult> GetAccountRecordings(DateTime? dateCreated, ComparisonType? dateCreatedComparasion, int? page, int? pageSize)
{
var request = new RestRequest();
request.Resource = RequestUri.AccountRecordingsUri;
var dateCreatedParameterName = GetParameterNameWithEquality(dateCreatedComparasion, "DateCreated");
if (dateCreated.HasValue) request.AddParameter(dateCreatedParameterName, dateCreated.Value.ToString("yyyy-MM-dd"));
if (page.HasValue) request.AddParameter("Page", page);
if (pageSize.HasValue) request.AddParameter("PageSize", pageSize);
return await Execute<RecordingResult>(request);
}
示例11: Like
public static bool Like(this string source, string compareTo, ComparisonType comparisonType)
{
switch (comparisonType)
{
case ComparisonType.Contains:
return source.Contains(compareTo);
case ComparisonType.EndsWith:
return source.EndsWith(compareTo);
case ComparisonType.StartsWith:
return source.StartsWith(compareTo);
default:
throw new InvalidOperationException();
}
}
示例12: Comparison
public void Comparison(ComparisonType comp)
{
switch (comp)
{
case ComparisonType.Between:
_writer.Write(" BETWEEN ");
break;
case ComparisonType.Contains:
case ComparisonType.EndsWith:
case ComparisonType.Like:
case ComparisonType.StartsWith:
_writer.Write(" LIKE ");
break;
case ComparisonType.Equal:
_writer.Write(" = ");
break;
case ComparisonType.GreaterThan:
_writer.Write(" > ");
break;
case ComparisonType.GreaterThanEqual:
_writer.Write(" >= ");
break;
case ComparisonType.In:
_writer.Write(" IN ");
break;
case ComparisonType.IsNotNull:
_writer.Write(" IS NOT ");
_writer.Null();
_writer.Write(" ");
break;
case ComparisonType.IsNull:
_writer.Write(" IS ");
_writer.Null();
_writer.Write(" ");
break;
case ComparisonType.LessThan:
_writer.Write(" < ");
break;
case ComparisonType.LessThanEqual:
_writer.Write(" <= ");
break;
case ComparisonType.NotEqual:
_writer.Write(" <> ");
break;
case ComparisonType.NotLike:
throw new NotSupportedException();
}
_lastComparison = comp;
}
示例13: NotenizerDependency
public NotenizerDependency(
NotenizerWord governor,
NotenizerWord dependent,
NotenizerRelation relation,
int position,
ComparisonType comparisonType,
TokenType tokenType)
{
_governor = governor;
_dependent = dependent;
_relation = relation;
_position = position;
_comparisonType = comparisonType;
_tokenType = tokenType;
}
示例14: GetData
public ArrayList GetData(object key, ComparisonType comparisonType)
{
RedBlack.COMPARE compare = RedBlack.COMPARE.EQ;
ArrayList result = new ArrayList();
if (_rbTree != null)
{
switch (comparisonType)
{
case ComparisonType.EQUALS:
compare = RedBlack.COMPARE.EQ;
break;
case ComparisonType.NOT_EQUALS:
compare = RedBlack.COMPARE.NE;
break;
case ComparisonType.LESS_THAN:
compare = RedBlack.COMPARE.LT;
break;
case ComparisonType.GREATER_THAN:
compare = RedBlack.COMPARE.GT;
break;
case ComparisonType.LESS_THAN_EQUALS:
compare = RedBlack.COMPARE.LTEQ;
break;
case ComparisonType.GREATER_THAN_EQUALS:
compare = RedBlack.COMPARE.GTEQ;
break;
case ComparisonType.LIKE:
compare = RedBlack.COMPARE.REGEX;
break;
case ComparisonType.NOT_LIKE:
compare = RedBlack.COMPARE.IREGEX;
break;
}
result = _rbTree.GetData(key as IComparable, compare) as ArrayList;
}
return result;
}
示例15: GetConferences
/// <summary>
/// Return list of all conference resources associated with a given account
/// </summary>
/// <param name="friendlyName">List conferences with the given FriendlyName.</param>
/// <param name="status">List conferences with the given status.</param>
/// <param name="dateCreated">List conferences created on, after, or before a given date.</param>
/// <param name="dateCreatedComparasion">Date range can be specified using inequalities.</param>
/// <param name="dateUpdated">List conferences updated on, after, or before a given date.</param>
/// <param name="dateUpdatedComparasion">Date range can be specified using inequalities.</param>
/// <param name="page">Used to return a particular page withing the list.</param>
/// <param name="pageSize">Used to specify the amount of list items to return per page.</param>
/// <returns></returns>
public ConferenceResult GetConferences(string friendlyName, ConferenceStatus? status, DateTime? dateCreated, ComparisonType? dateCreatedComparasion,
DateTime? dateUpdated, ComparisonType? dateUpdatedComparasion, int? page, int?pageSize)
{
var request = new RestRequest();
request.Resource = RequestUri.ConferencesUri;
var dateCreatedParameterName = GetParameterNameWithEquality(dateCreatedComparasion, "DateCreated");
var dateUpdatedParemeterName = GetParameterNameWithEquality(dateUpdatedComparasion, "DateUpdated");
if (friendlyName.HasValue()) request.AddParameter("FriendlyName", friendlyName);
if (status.HasValue) request.AddParameter("Status", status.ToString().ToLower());
if (dateCreated.HasValue) request.AddParameter(dateCreatedParameterName, dateCreated.Value.ToString("yyyy-MM-dd"));
if (dateUpdated.HasValue) request.AddParameter(dateUpdatedParemeterName, dateUpdated.Value.ToString("yyyy-MM-dd"));
if (page.HasValue) request.AddParameter("Page", page);
if (pageSize.HasValue) request.AddParameter("PageSize", pageSize);
return Execute<ConferenceResult>(request);
}