• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ComparisonType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ComparisonType的典型用法代码示例。如果您正苦于以下问题:C# ComparisonType类的具体用法?C# ComparisonType怎么用?C# ComparisonType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ComparisonType类属于命名空间,在下文中一共展示了ComparisonType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
 }
开发者ID:Edhendil,项目名称:MonoLiteOrm,代码行数:31,代码来源:ComparisonCondition.cs


示例2: FilterOptions

 public FilterOptions(string col, ComparisonType type, string val)
     : this()
 {
     Col = col;
     Val = val;
     Type = type;
 }
开发者ID:arkanoid1,项目名称:mywowtools,代码行数:7,代码来源:FilterOptions.cs


示例3: WhereItem

 public WhereItem(string field, object value, ComparisonType comparisonType=ComparisonType.Equal,bool parameterize=true)
 {
     Field = field;
     ComparisonType = comparisonType;
     Value = value;
     Parameterize = parameterize;
 }
开发者ID:saneman1,项目名称:IQMap,代码行数:7,代码来源:WhereItem.cs


示例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;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:66,代码来源:ReportingExtensions.cs


示例5: ConditionMaterial

 public ConditionMaterial(string target, ComparisonType targetComp, string calc, int needCount,ComparisonType countComp)
 {
     Target = target;
     TargetComparison = targetComp;
     Calc = calc;
     NeedCount = needCount;
     CountComparison = countComp;
 }
开发者ID:EleBrain,项目名称:-CS-ZWJsonEditor,代码行数:8,代码来源:ConditionMaterial.cs


示例6: RangeIfClientAttribute

 public RangeIfClientAttribute(int minimum, int maximum, string otherProperty, ComparisonType comparisonType, object otherComparisonValue)
 {
     Minimum = minimum;
     Maximum = maximum;
     OtherProperty = otherProperty;
     ComparisonType = comparisonType;
     OtherComparisonValue = otherComparisonValue;
 }
开发者ID:danludwig,项目名称:UCosmic,代码行数:8,代码来源:RangeIfClientAttribute.cs


示例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);
 }
开发者ID:petergeneric,项目名称:xmlunit,代码行数:9,代码来源:Comparison.cs


示例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;
        }
开发者ID:urmilaNominate,项目名称:mERP-framework,代码行数:16,代码来源:ComparisonFilter.cs


示例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;
        }
开发者ID:gsteinbacher,项目名称:RandomOrgSharp,代码行数:18,代码来源:ExceptionExpected.cs


示例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);
        }
开发者ID:TelAPI,项目名称:telapi-dotnet,代码行数:21,代码来源:Recordings.cs


示例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();
     }
 }
开发者ID:lukesmith,项目名称:lix,代码行数:14,代码来源:StringExtensions.cs


示例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;
 }
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:49,代码来源:BaseSqlCriteriaWriter.cs


示例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;
 }
开发者ID:nemcek,项目名称:notenizer,代码行数:15,代码来源:NotenizerDependency.cs


示例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;
        }
开发者ID:christrotter,项目名称:NCache,代码行数:47,代码来源:RBStore.cs


示例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);
        }
开发者ID:TelAPI,项目名称:telapi-dotnet,代码行数:30,代码来源:Conferences.cs


示例16: CreateKeyComparer

	// Create a new key comparer.
	public static IKeyComparer CreateKeyComparer(ComparisonType comparisonType)
			{
				switch(comparisonType)
				{
					case ComparisonType.CurrentCulture:
					{
						return new KeyComparer
							(new Comparer(CultureInfo.CurrentCulture),
							 defaultHashCodeProvider);
					}

					case ComparisonType.CurrentCultureIgnoreCase:
					{
						return new KeyComparer
							(new CaseInsensitiveComparer
								(CultureInfo.CurrentCulture),
							 new CaseInsensitiveHashCodeProvider
							 	(CultureInfo.CurrentCulture));
					}

					case ComparisonType.InvariantCulture:
					{
						return new KeyComparer
							(Comparer.DefaultInvariant,
							 defaultHashCodeProvider);
					}

					case ComparisonType.InvariantCultureIgnoreCase:
					{
						return new KeyComparer
							(CaseInsensitiveComparer.DefaultInvariant,
							 CaseInsensitiveHashCodeProvider.DefaultInvariant);
					}

					default:
					{
						return new KeyComparer
							(new OrdinalComparer(), defaultHashCodeProvider);
					}
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:42,代码来源:KeyComparer.cs


示例17: Compare

        public static bool Compare(ComparisonType comptype, object e1, object e2)
        {
            if(e1 is string && e2 is char)
                e2 = e2.ToString();
            else if(e2 is string && e1 is char)
                e1 = e1.ToString();

            switch(comptype)
            {
            case ComparisonType.Equal:
                return IsEqual(e1, e2);
            case ComparisonType.NonEqual:
                return !IsEqual(e1, e2);
            case ComparisonType.Less:
                return (Compare(e1, e2) < 0M);
            case ComparisonType.LessOrEqual:
                return (Compare(e1, e2) <= 0M);
            case ComparisonType.GreaterOrEqual:
                return (Compare(e1, e2) >= 0M);
            case ComparisonType.Greater:
                return (Compare(e1, e2) > 0M);
            }
            throw new NotImplementedException();
        }
开发者ID:langpavel,项目名称:LPS-old,代码行数:24,代码来源:CompareExpression.cs


示例18: ComparisonExpression

        /// <summary>
        /// Gets the comparison expression.
        /// </summary>
        /// <param name="comparisonType">Type of the comparison.</param>
        /// <param name="property">The property.</param>
        /// <param name="value">The value.</param>
        /// <param name="value2">If doing ComparisonType.Between, value2 is the upper value between expression</param>
        /// <returns></returns>
        public static Expression ComparisonExpression( ComparisonType comparisonType, MemberExpression property, Expression value, Expression value2 = null)
        {
            MemberExpression valueExpression;
            Expression comparisonExpression = null;
            bool isNullableType = property.Type.IsGenericType && property.Type.GetGenericTypeDefinition() == typeof( Nullable<> );
            if ( isNullableType )
            {
                // if Nullable Type compare on the .Value of the property (if it HasValue)
                valueExpression = Expression.Property( property, "Value" );
            }
            else
            {
                valueExpression = property;
            }

            if ( comparisonType == ComparisonType.Contains )
            {
                if ( valueExpression.Type == typeof( int ) )
                {
                    comparisonExpression = Expression.Call( value, typeof(List<int>).GetMethod( "Contains", new Type[] { typeof(int) } ), valueExpression );
                }
                else
                {
                    comparisonExpression = Expression.Call( valueExpression, typeof( string ).GetMethod( "Contains", new Type[] { typeof( string ) } ), value );
                }
            }
            else if ( comparisonType == ComparisonType.DoesNotContain )
            {
                comparisonExpression = Expression.Not( Expression.Call( valueExpression, typeof( string ).GetMethod( "Contains", new Type[] { typeof( string ) } ), value ) );
            }
            else if ( comparisonType == ComparisonType.EndsWith )
            {
                comparisonExpression = Expression.Call( valueExpression, typeof( string ).GetMethod( "EndsWith", new Type[] { typeof( string ) } ), value );
            }
            else if ( comparisonType == ComparisonType.EqualTo )
            {
                comparisonExpression = Expression.Equal( valueExpression, value );
            }
            else if ( comparisonType == ComparisonType.GreaterThan ||
                comparisonType == ComparisonType.GreaterThanOrEqualTo ||
                comparisonType == ComparisonType.LessThan ||
                comparisonType == ComparisonType.LessThanOrEqualTo ||
                comparisonType == ComparisonType.Between )
            {
                Expression leftExpression = valueExpression;
                Expression rightExpression = value;

                Expression rightExpression2 = value2;

                if ( valueExpression.Type == typeof( string ) )
                {
                    var method = valueExpression.Type.GetMethod( "CompareTo", new[] { typeof( string ) } );
                    leftExpression = Expression.Call( valueExpression, method, value );
                    rightExpression = Expression.Constant( 0 );
                }

                if ( comparisonType == ComparisonType.GreaterThan )
                {
                    comparisonExpression = Expression.GreaterThan( leftExpression, rightExpression );
                }
                else if ( comparisonType == ComparisonType.GreaterThanOrEqualTo )
                {
                    comparisonExpression = Expression.GreaterThanOrEqual( leftExpression, rightExpression );
                }
                else if ( comparisonType == ComparisonType.LessThan )
                {
                    comparisonExpression = Expression.LessThan( leftExpression, rightExpression );
                }
                else if ( comparisonType == ComparisonType.LessThanOrEqualTo )
                {
                    comparisonExpression = Expression.LessThanOrEqual( leftExpression, rightExpression );
                }
                else if (comparisonType == ComparisonType.Between)
                {
                    var lowerComparisonExpression = rightExpression != null ? Expression.GreaterThanOrEqual( leftExpression, rightExpression ) : null;
                    var upperComparisonExpression = rightExpression2 != null ? Expression.LessThanOrEqual( leftExpression, rightExpression2 ) : null;
                    if ( rightExpression != null && rightExpression2 != null )
                    {
                        comparisonExpression = Expression.AndAlso( lowerComparisonExpression, upperComparisonExpression );
                    }
                    else if (rightExpression != null )
                    {
                        comparisonExpression = lowerComparisonExpression;
                    }
                    else if ( rightExpression2 != null )
                    {
                        comparisonExpression = upperComparisonExpression;
                    }
                }
            }
            else if ( comparisonType == ComparisonType.IsBlank )
            {
//.........这里部分代码省略.........
开发者ID:NewSpring,项目名称:Rock,代码行数:101,代码来源:ComparisonHelper.cs


示例19: ComparisonObject

 internal ComparisonObject(ComparisonType comparisonType, ObjectType objectType, string name)
 {
     this.comparisonType = comparisonType;
     this.objectType = objectType;
     this.name = name;
 }
开发者ID:adrianbanks,项目名称:SqlDiff,代码行数:6,代码来源:ComparisonObject.cs


示例20: OnSetParameters

            /// <summary>
            /// Set the property values parsed from a settings string.
            /// </summary>
            /// <param name="version">The version number of the parameter set.</param>
            /// <param name="parameters">An ordered collection of strings representing the parameter values.</param>
            protected override void OnSetParameters( int version, IReadOnlyList<string> parameters )
            {
                // Parameter 1: Person Data View
                PersonDataViewGuid = DataComponentSettingsHelper.GetParameterOrEmpty( parameters, 0 ).AsGuidOrNull();

                // Parameter 2: Person Count Comparison
                PersonCountComparison = DataComponentSettingsHelper.GetParameterAsEnum( parameters, 1, ComparisonType.GreaterThan );

                // Parameter 3: Person Count
                PersonCount = DataComponentSettingsHelper.GetParameterOrEmpty( parameters, 2 ).AsInteger();
            }
开发者ID:azturner,项目名称:Rock,代码行数:16,代码来源:ContainsPeopleFilter.cs



注:本文中的ComparisonType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Compilation类代码示例发布时间:2022-05-24
下一篇:
C# ComparisonOperator类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap