public Compare(CompareType type, string fieldName, params object[] compareValues) { this.Type = type; this.Field = fieldName; this.CompareValues = compareValues; this.Option = CompareOption.IgnoreEmptyString | CompareOption.ConvertDateTime; }
public ComparePredicate(IDataSelector firstArgumentSelector, IDataSelector secondArgumentSelector, CompareType type) { Contract.Requires(firstArgumentSelector != null); Contract.Requires(secondArgumentSelector != null); _firstArgumentSelector = firstArgumentSelector; _secondArgumentSelector = secondArgumentSelector; switch (type) { case CompareType.Less: _checkComparisonResult = r => r < 0; break; case CompareType.LessOrEqual: _checkComparisonResult = r => r <= 0; break; case CompareType.Greater: _checkComparisonResult = r => r > 0; break; case CompareType.GreaterOrEqual: _checkComparisonResult = r => r >= 0; break; default: throw new ArgumentOutOfRangeException("type"); } }
// Post: ((size() == 0) && ! locked()) // Pre = PreCondition, Post = PostCondition public HeapArray(CompareType c) { m_Heap = new List<Linker>(); m_Finder = new List<uint>(); m_Locked = false; m_Compare = c; }
public Compare(CompareType type, CompareOption option, string fieldName, params object[] compareValues) { this.Type = type; this.Field = fieldName; this.CompareValues = compareValues; this.Option = option; }
/// <summary> /// Get all attributes with probability comparison /// </summary> /// <param name="strJobTitle">Job title to get attributes</param> /// <param name="compareType">Compare Type</param> /// <param name="compareValue">Value to compare</param> /// <param name="compareValue2">Value to compare 2 [optional]</param> /// <returns>The attributes appropriate probability comparison</returns> public static List<DecisionTreeAnalysisResult> getAnalysisResults(string strModelName, CompareType compareType, double compareValue, double compareValue2 = -1) { if (compareValue < 0 || compareValue > 1) { throw new Exception("compareValue variable value must be between 0-1"); } if ((compareType == CompareType.Between || compareType == CompareType.NotBetween) && (compareValue2 > 1 || compareValue2 < 0)) { throw new Exception("compareValue2 variable value must be between 0-1"); } if (!existsModelName(strModelName)) { throw new Exception("Model Name doesn't exists! (If model name existed, please check connection!)"); } try { //Get all leaves with Probability and Model Name List<DecisionTreeNode> nodes = getDecisionTreeNodeWithProbability(strModelName, compareType, compareValue, compareValue2); List<DecisionTreeAnalysisResult> results = new List<DecisionTreeAnalysisResult>(); foreach (DecisionTreeNode node in nodes) { DecisionTreeAnalysisResult result = new DecisionTreeAnalysisResult(new NodeDescription(node), node); results.Add(result); } return results; } catch (Exception ex) { throw ex; } }
internal static Expression AttendanceTypeAsOf( ParameterExpression parm, DateTime? from, DateTime? to, int? progid, int? divid, int? org, int orgtype, CompareType op, params int[] ids) { to = to.HasValue ? to.Value.AddDays(1) : from.Value.AddDays(1); Expression<Func<Person, bool>> pred = p => ( from a in p.Attends where a.MeetingDate >= @from where a.MeetingDate < to where (a.AttendanceFlag || (ids.Length == 1 && ids[0] == AttendTypeCode.Offsite)) where ids.Contains(a.AttendanceTypeId ?? 0) where orgtype == 0 || a.Meeting.Organization.OrganizationTypeId == orgtype where org == 0 || a.Meeting.OrganizationId == org where divid == 0 || a.Meeting.Organization.DivOrgs.Any(dg => dg.DivId == divid) where progid == 0 || a.Meeting.Organization.DivOrgs.Any(dg => dg.Division.ProgDivs.Any(pg => pg.ProgId == progid)) select a ).Any(); Expression expr = Expression.Invoke(pred, parm); if (op == CompareType.NotEqual || op == CompareType.NotOneOf) expr = Expression.Not(expr); return expr; }
public QueryBuilder Is(CompareType compareType, string value) { _compareCondition.Compare = compareType; _compareCondition.Value = value; _query.Conditions.Add(_compareCondition); return _queryBuilder; }
public DateGreaterThanAttribute(string firstDate, string secondDate, CompareType type) : base() { FirstDate = firstDate; SecondDate = secondDate; Compare = type; }
internal static Expression CompareConstant(ParameterExpression parm, string prop, CompareType op, object value) { if (value != null) if (value.GetType() == typeof(int[])) // use isarray? return CompareContains(parm, prop, op, value, typeof(int[]), typeof(int)); else if (value.GetType() == typeof(string[])) return CompareContains(parm, prop, op, value, typeof(string[]), typeof(string)); var left = Expression.Property(parm, prop); var right = Expression.Convert(Expression.Constant(value), left.Type); return Compare(parm, left, op, right); }
public IVFilter() { hpValue = 0; hpCompare = CompareType.None; atkValue = 0; atkCompare = CompareType.None; defValue = 0; defCompare = CompareType.None; spaValue = 0; spaCompare = CompareType.None; spdValue = 0; spdCompare = CompareType.None; speValue = 0; speCompare = CompareType.None; }
public static bool CompareAgainst(this int compareTo, CompareType compareType, int value) { switch (compareType) { case CompareType.Greater: return value > compareTo; case CompareType.GEqual: return value >= compareTo; case CompareType.Less: return value < compareTo; case CompareType.LEqual: return value <= compareTo; default: // EQUAL return value == compareTo; } }
public IVFilter(uint hpValue, CompareType hpCompare, uint atkValue, CompareType atkCompare, uint defValue, CompareType defCompare, uint spaValue, CompareType spaCompare, uint spdValue, CompareType spdCompare, uint speValue, CompareType speCompare) { this.hpValue = hpValue; this.hpCompare = hpCompare; this.atkValue = atkValue; this.atkCompare = atkCompare; this.defValue = defValue; this.defCompare = defCompare; this.spaValue = spaValue; this.spaCompare = spaCompare; this.spdValue = spdValue; this.spdCompare = spdCompare; this.speValue = speValue; this.speCompare = speCompare; }
public bool checkFlag(string compareValue, CompareType compareType) { switch(this.flagType) { case FlagType.boolFlag: switch(compareType) { case CompareType.Equal: return checkFlag_BoolEqual(compareValue); case CompareType.NotEqual: return checkFlag_BoolNotEqual(compareValue); default: return false; } case FlagType.intFlag: switch(compareType) { case CompareType.Equal: return checkFlag_IntEqual(compareValue); case CompareType.Less: return checkFlag_IntLess(compareValue); case CompareType.LessEqual: return checkFlag_IntLessEqual(compareValue); case CompareType.Greater: return checkFlag_IntGreater(compareValue); case CompareType.GreaterEqual: return checkFlag_IntGreaterEqal(compareValue); default: return false; } case FlagType.stringFlag: switch(compareType) { case CompareType.Equal: return checkFlag_StringEqual(compareValue); case CompareType.Contains: return checkFlag_StringContains(compareValue); case CompareType.Subset: return checkFlag_StringSubstring(compareValue); default: return false; } default: return false; } }
private int CompareName(string original, string compare, CompareType compareType) { original = original.ToLower(); compare = compare.ToLower(); int charInCommon = 0; if (compare != original) { foreach (char originalChar in original.ToCharArray()) { int index; if ((index = compare.IndexOf(originalChar.ToString()))>=0 && originalChar != ' ') { charInCommon++; if(compareType == CompareType.Distinct) compare = compare.Replace(originalChar, ' '); if (compareType == CompareType.Total) compare.Remove(index, 1); } } } return charInCommon; }
private static Expression CompareContains(ParameterExpression parm, string prop, CompareType op, object a, Type arrayType, Type itemType) { var left = Expression.Constant(a, arrayType); var right = Expression.Convert(Expression.Property(parm, prop), itemType); if (EnumerableContains == null) EnumerableContains = typeof(Enumerable) .GetMethods(BindingFlags.Public | BindingFlags.Static) .First(m => m.Name == "Contains"); var method = EnumerableContains.MakeGenericMethod(itemType); Expression expr = Expression.Call(method, new Expression[] { left, right }); if (op == CompareType.NotOneOf) expr = Expression.Not(expr); return expr; }
public TreeBranchCondition(string flagName, string value, CompareType compareType) { this.flagName = flagName; this.value = value; this.flagCompareType = compareType; }
public void InitMemoryHandler(ValueType valueType, CompareType compareType) { bool is_float = false; cur_compare_type = compareType; switch (valueType) { case ValueType.FLOAT_TYPE: SetBytesByType = set_bytes_4_bytes; GetBytesByType = get_bytes_4_bytes; CompareWithFilterList = compare_with_filter_list_4_bytes; BytesToString = float_to_string; StringToBytes = string_to_float; BytesToUint = bytes_to_uint_4_bytes; UintToBytes = uint_to_bytes_4_bytes; is_float = true; break; case ValueType.INT_TYPE: SetBytesByType = set_bytes_4_bytes; GetBytesByType = get_bytes_4_bytes; CompareWithFilterList = compare_with_filter_list_4_bytes; BytesToString = uint_to_string; StringToBytes = string_to_4_bytes; BytesToUint = bytes_to_uint_4_bytes; UintToBytes = uint_to_bytes_4_bytes; break; case ValueType.SHORT_TYPE: SetBytesByType = set_bytes_2_bytes; GetBytesByType = get_bytes_2_bytes; CompareWithFilterList = compare_with_filter_list_2_bytes; BytesToString = ushort_to_string; StringToBytes = string_to_2_bytes; BytesToUint = bytes_to_uint_2_bytes; UintToBytes = uint_to_bytes_2_bytes; break; case ValueType.HEX_TYPE: SetBytesByType = set_bytes_hex; GetBytesByType = null; CompareWithFilterList = null; BytesToString = print_bytes_hex; StringToBytes = string_to_2_bytes; break; default: break; } switch (compareType) { case CompareType.UNKNOWN_INITIAL_VALUE: if (is_float) { Compare = scan_type_any_float; } else { Compare = scan_type_any_uint; } CompareInFilter = Compare; break; case CompareType.EXACT_VALUE: if (is_float) { Compare = scan_type_equal_float; } else { Compare = scan_type_equal_uint; } CompareInFilter = Compare; break; case CompareType.CHANGED_VALUE: if (is_float) { Compare = scan_type_not_float; CompareInFilter = scan_type_any_float; } else { Compare = scan_type_not_uint; CompareInFilter = scan_type_any_uint; } break; case CompareType.UNCHANGED_VALUE: if (is_float) { Compare = scan_type_equal_float; CompareInFilter = scan_type_any_float; } else { Compare = scan_type_equal_uint; CompareInFilter = scan_type_any_uint; } break; case CompareType.INCREASED_VALUE: if (is_float) { Compare = scan_type_bigger_float; CompareInFilter = scan_type_any_float; } else { Compare = scan_type_bigger_uint; CompareInFilter = scan_type_any_uint; } break; case CompareType.DECREASED_VALUE: if (is_float) { Compare = scan_type_less_float; CompareInFilter = scan_type_any_float; } else { Compare = scan_type_less_uint; CompareInFilter = scan_type_any_uint; } break; case CompareType.BIGGER_THAN_VALUE: if (is_float) { Compare = scan_type_bigger_float; } else { Compare = scan_type_bigger_uint; } CompareInFilter = Compare; break; case CompareType.SMALLER_THAN_VALUE: if (is_float) { Compare = scan_type_less_float; } else { Compare = scan_type_less_uint; } CompareInFilter = Compare; break; default: break; } }
public RequireLevel(int level, CompareType type) { Instructions = new List<TreeCrayonInstruction>(); Level = level; Type = type; }
protected string SelectOperation(CompareType compareType) { switch (compareType) { case CompareType.And: return "AND"; case CompareType.Equal: return "="; case CompareType.GreaterThan: return ">"; case CompareType.GreaterThanOrEqual: return ">="; case CompareType.LessThan: return "<"; case CompareType.LessThanOrEqual: return "<="; case CompareType.Or: return "OR"; case CompareType.Add: return "+"; case CompareType.Substarct: return "-"; case CompareType.Multiply: return "*"; case CompareType.Divide: return "/"; case CompareType.NotEqual: return "<>"; default: throw new Exception(); } }
char DecodeChar(int ofs, CompareType mode) { return _id2ConvertedChar[(int)mode][_tree[ofs] & 127]; }
public WhereExpression(IWhereExpression Expression, string fieldName, object value, CompareType type) { this.Expression = Expression; this.FieldName = fieldName; this.Value = value; this.CompareType = type; }
public List <Guid> GetObjectsFromBT(Type OID, string attribiute, string value, CompareType compare, out int readBTObjects) { List <Guid> ret = new List <Guid>(); foreach (var i in GetObjectsBT(OID, attribiute).find(compare, value, out readBTObjects)) { ret.AddRange(i); } return(ret.Distinct().ToList()); }
public Condition(CompareType comparison, object value) { this.comparison = comparison; this.value = StateValue.NormalizeValue(value); }
public static bool VerifyRequirement(Player player, CompareType compareType, double?prop, double val, string failMsg) { var success = true; switch (compareType) { case CompareType.GreaterThan: if (prop != null && prop.Value > val) { success = false; } break; case CompareType.LessThanEqual: if (prop != null && prop.Value <= val) { success = false; } break; case CompareType.LessThan: if (prop != null && prop.Value < val) { success = false; } break; case CompareType.GreaterThanEqual: if (prop != null && prop.Value >= val) { success = false; } break; case CompareType.NotEqual: if (prop != null && prop.Value != val) { success = false; } break; case CompareType.NotEqualNotExist: if (prop == null || prop.Value != val) { success = false; } break; case CompareType.Equal: if (prop != null && prop.Value == val) { success = false; } break; case CompareType.NotExist: if (prop == null) { success = false; } break; case CompareType.Exist: if (prop != null) { success = false; } break; } if (!success) { player.Session.Network.EnqueueSend(new GameMessageSystemChat(failMsg, ChatMessageType.Craft)); } return(success); }
public RacerComp(CompareType compType) { this.compType = compType; }
public static void AddDataToTableAndSaveFile(Database database, XDocument data, string fileOutput, CompareType type) { var doc = new XDocument(); using (var writer = doc.CreateWriter()) { var serializer = new XmlSerializer(typeof(Database)); serializer.Serialize(writer, database); } var dataElements = data.Elements().FirstOrDefault()?.Elements(XName.Get("Table")).ToList(); var schemaElements = doc.Elements().FirstOrDefault()?.Elements(XName.Get("Table")).ToList(); if (schemaElements != null) { foreach (var element in schemaElements) { if (element.Name.ToString().ToLower() != "table") { continue; } var tableNameAttribute = element.Attribute(XName.Get("Name")); var schemaAttribute = element.Attribute(XName.Get("Schema")); var tableName = string.Empty; var schemaName = string.Empty; if (tableNameAttribute != null) { tableName = tableNameAttribute.Value; } schemaName = schemaAttribute?.Value; if (type == CompareType.Data) { var foundData = (from d in dataElements where d.Attribute(XName.Get("Name"))?.Value == tableName && d.Attribute(XName.Get("Schema"))?.Value == schemaName select d).FirstOrDefault(); if (foundData != null) { element.Add(foundData.Elements(XName.Get("Data"))); } } } } var path = ConstantData.WorkingDir + fileOutput; doc.Save(path); Console.WriteLine("Saving To xml"); }
public OQLCompare Comparer(object field, CompareType type, OQLChildFunc Value) { OQL childOql = Value(this.LinkedOQL); return(Comparer(field, type, childOql)); }
public CompareColor(CompareType value) { Value = value; }
public void SetComparisonType(CompareType value) { Comparison = value.ToString(); }
public Cheat(Watch watch, int value, int?compare = null, bool enabled = true, CompareType comparisonType = CompareType.None) { _enabled = enabled; _watch = watch; _compare = compare; _val = value; _comparisonType = comparisonType; Pulse(); }
public void Find(string word, CompareType mode, Action<string> onFound) { switch (mode) { case CompareType.CaseInsensitive: word = word.ToLowerInvariant(); break; case CompareType.IgnoreDiacritics: word = word.RemoveDiacritics(); break; case CompareType.IgnoreCaseAndDiacritics: word = word.ToLowerInvariant().RemoveDiacritics(); break; } var sb = new StringBuilder(); Match(word, mode, sb, 0, ofs => { if (word.Length != sb.Length) return; ofs = SinkTo(ofs, ':'); if (ofs == -1) return; sb.Append(":"); IterateRaw(sb, ofs, sb1 => onFound(ExpandByType(sb1))); sb.Length--; }); Match(word, mode, sb, _nodePrefix, ofs => { if (ofs != -1) ofs = SinkTo(ofs, ':'); if (ofs == -1) return; Match(word, mode, sb, _nodePostfix, ofs2 => { if (word.Length != sb.Length) return; ofs2 = SinkTo(ofs2, ':'); if (ofs2 == -1) return; sb.Append(":"); IterateRaw(sb, ofs2, sb1 => onFound(ExpandByType(sb1))); sb.Length--; }); }); }
public CompareValidator(string comparePropertyName, CompareOperator compareOperator, CompareType compareType) { _comparePropertyName = comparePropertyName; _compareOperator = compareOperator; _compareType = compareType; }
public void SetComparisonType(CompareType value) { Comparison = value.ToString(); compare = null; compare = Compare2; }
public QueryPropertyAttribute() { _compareType = Models.CompareType.Equal; _allowDefault = false; }
public OQLCompare Comparer <T>(T field, CompareType type, T[] Value) { return(Comparer <T>(field, type, Value, null)); }
private static bool CompareValues <T>(object target, CompareValueRuleArgs <T> e, CompareType compareType) { bool flag = true; if (e != null) { T a; T b = e.CompareValue; PropertyInfo property = target.GetType().GetProperty(e.PropertyName); try { a = (T)property.GetValue(target, null); } catch (Exception) { return(true); } if (property.PropertyType.Name.Equals(typeof(Nullable <>).Name) && (a == null)) { return(true); } int num = Comparer.DefaultInvariant.Compare(a, b); switch (compareType) { case CompareType.LessThanOrEqualTo: flag = num <= 0; if (!flag && string.IsNullOrEmpty(e.Description)) { e.Description = string.Format("{0} can not exceed {1}", e.PropertyName, b.ToString()); } break; case CompareType.LessThan: flag = num < 0; if (!flag && string.IsNullOrEmpty(e.Description)) { e.Description = string.Format("{0} must be less than {1}", e.PropertyName, b.ToString()); } break; case CompareType.EqualTo: flag = num == 0; if (!flag && string.IsNullOrEmpty(e.Description)) { e.Description = string.Format("{0} must equal {1}", e.PropertyName, b.ToString()); } break; case CompareType.GreaterThan: flag = num > 0; if (!flag && string.IsNullOrEmpty(e.Description)) { e.Description = string.Format("{0} must exceed {1}", e.PropertyName, b.ToString()); } break; case CompareType.GreaterThanOrEqualTo: flag = num >= 0; if (!flag && string.IsNullOrEmpty(e.Description)) { e.Description = string.Format("{0} must be greater than or equal to {1}", e.PropertyName, b.ToString()); } break; } if (!flag) { } } return(flag); }
public GuiSearchComparer(CompareType what = CompareType.KeyWords) { _whatToCompare = what; }
/// <summary> /// call constructo base to set IgnoreCase flag /// </summary> public CategoryCompareKey(StringComparison eqRule, CompareType compareMethod) : base(eqRule, compareMethod) { }
/// <summary> /// 获取查询条件模型 /// </summary> /// <param name="field">字段名</param> /// <param name="cType">包含关系</param> /// <param name="value">字段值</param> /// <returns>查询条件</returns> public static QueryCondition GetConditionModel(string field, CompareType cType, string value) { return(new QueryCondition(field, cType, value)); }
/// <summary> /// Constructor /// </summary> /// <param name="eqRule">StringComparison</param> /// <param name="compareMethod">CompareType</param> public CompareEqRule(StringComparison eqRule, CompareType compareMethod) { sb = new StringBuilder(); EqRule = eqRule; CompareMethod = compareMethod; }
private static Expression Compare(ParameterExpression parm, Expression left, CompareType op, Expression right) { Expression expr = null; switch (op) { case CompareType.NotEqual: case CompareType.IsNotNull: expr = Expression.NotEqual(left, right); break; case CompareType.Equal: case CompareType.IsNull: expr = Expression.Equal(left, right); break; case CompareType.Greater: expr = Expression.GreaterThan(left, right); break; case CompareType.GreaterEqual: expr = Expression.GreaterThanOrEqual(left, right); break; case CompareType.Less: expr = Expression.LessThan(left, right); break; case CompareType.LessEqual: expr = Expression.LessThanOrEqual(left, right); break; case CompareType.DoesNotStartWith: case CompareType.StartsWith: expr = Expression.Call(left, typeof(string).GetMethod("StartsWith", new[] { typeof(string) }), new[] { right }); break; case CompareType.DoesNotEndWith: case CompareType.EndsWith: expr = Expression.Call(left, typeof(string).GetMethod("EndsWith", new[] { typeof(string) }), new[] { right }); break; case CompareType.DoesNotContain: case CompareType.Contains: expr = Expression.Call(left, typeof(string).GetMethod("Contains", new[] { typeof(string) }), new[] { right }); break; case CompareType.After: case CompareType.AfterOrSame: case CompareType.Before: case CompareType.BeforeOrSame: expr = Expression.Call(left, typeof(string).GetMethod("CompareTo", new[] { typeof(string) }), new[] { right }); break; } switch (op) { // now reverse the logic if necessary case CompareType.DoesNotEndWith: case CompareType.DoesNotContain: case CompareType.DoesNotStartWith: expr = Expression.Not(expr); break; case CompareType.After: expr = Expression.GreaterThan(expr, Expression.Constant(0)); break; case CompareType.AfterOrSame: expr = Expression.GreaterThanOrEqual(expr, Expression.Constant(0)); break; case CompareType.Before: expr = Expression.LessThan(expr, Expression.Constant(0)); break; case CompareType.BeforeOrSame: expr = Expression.LessThanOrEqual(expr, Expression.Constant(0)); break; } return expr; }
private SelectQuery Compare <T>(CompareType methodType, Table <T> table, Func <T, object> func, object value, object otherValue = null, string As = null) { string fromTable = (string.IsNullOrEmpty(As) ? table._tableName : As); string _value = value?.ToString(); if (value?.GetType() == typeof(string) || value?.GetType() == typeof(DateTime)) { _value = $"'{value}'"; } else if (value?.GetType() == typeof(System.Collections.IEnumerable)) { _value = string.Join(", ", (System.Collections.IEnumerable)value); } else if (value?.GetType() == typeof(SelectQuery)) { _value = ((SelectQuery)value).Translate(); } string _otherValue = otherValue?.ToString(); if (otherValue?.GetType() == typeof(string) || otherValue?.GetType() == typeof(DateTime)) { _otherValue = $"'{otherValue}'"; } else if (otherValue?.GetType() == typeof(System.Collections.IEnumerable)) { _otherValue = string.Join(", ", (System.Collections.IEnumerable)otherValue); } else if (otherValue?.GetType() == typeof(SelectQuery)) { _otherValue = ((SelectQuery)otherValue).Translate(); } var funcResult = func.Invoke(Activator.CreateInstance <T>()); string leftSide; if (funcResult?.GetType() == typeof(Complex)) { var comp = (funcResult as Complex); leftSide = comp.ToString(); } else if (funcResult?.GetType() == typeof(Aggregation)) { var agg = (funcResult as Aggregation); agg.baseFromTable = fromTable; leftSide = agg.ToString(); } else if (funcResult?.IsAnonymousType() ?? false) { leftSide = $"{fromTable}.{funcResult?.GetColumns().First()}"; } else { leftSide = funcResult?.ToString(); } var con = new Condition { CompareType = methodType, First = leftSide, Second = $"{_value}", Third = _otherValue }; if (conditions.Count == 0) { conditions.Add(new List <Condition>()); } conditions.Last().Add(con); return(this); }
public override string GetDesc() { TDBaseAttrData attrData = BaseAttrMgr <Type> .GetAttrDataList()[Enum <Type> .Int(AttrType)]; return(GetStr("AC_IsAttrToAct", (AttrType as Enum).GetName(), CompareType.GetName(), BaseAttrMgr <Type> .GetAttrNumberStr(AttrType, val))); }
private SelectQuery Compare <T1, T2>(CompareType methodType, Table <T1> table1, Func <T1, object> func1, Table <T2> table2, Func <T2, object> func2, string As1 = null, string As2 = null) { string fromTable1 = (string.IsNullOrEmpty(As1) ? table1._tableName : As1); string fromTable2 = (string.IsNullOrEmpty(As2) ? table2._tableName : As2); var leftFuncResult = func1.Invoke(Activator.CreateInstance <T1>()); string leftSide; if (leftFuncResult?.GetType() == typeof(Complex)) { var comp = (leftFuncResult as Complex); leftSide = comp.ToString(); } else if (leftFuncResult?.GetType() == typeof(Aggregation)) { var agg = (leftFuncResult as Aggregation); agg.baseFromTable = fromTable1; leftSide = agg.ToString(); } else if (leftFuncResult?.IsAnonymousType() ?? false) { leftSide = $"{fromTable1}.{leftFuncResult?.GetColumns().First()}"; } else { leftSide = leftFuncResult?.ToString(); } var rightFuncResult = func2.Invoke(Activator.CreateInstance <T2>()); string rightSide; if (rightFuncResult?.GetType() == typeof(Complex)) { var comp = (rightFuncResult as Complex); rightSide = comp.ToString(); } else if (rightFuncResult?.GetType() == typeof(Aggregation)) { var agg = (rightFuncResult as Aggregation); agg.baseFromTable = fromTable2; rightSide = agg.ToString(); } else if (rightFuncResult?.IsAnonymousType() ?? false) { rightSide = $"{fromTable2}.{rightFuncResult?.GetColumns().First()}"; } else { rightSide = rightFuncResult?.ToString(); } var con = new Condition { CompareType = methodType, First = leftSide, Second = rightSide, }; if (conditions.Count == 0) { conditions.Add(new List <Condition>()); } conditions.Last().Add(con); return(this); }
internal void SetFirstPersonSameEmail(CompareType op, bool tf) { var c = this; while (c.Parent != null) c = c.Parent; c.FirstPersonSameEmail = ((tf && op == CompareType.Equal) || (!tf && op == CompareType.NotEqual)); }
public OQLCompare MIN <T>(T field, CompareType type, T Value) { return(Comparer <T>(field, type, Value, "MIN({0})")); }
public void FindNicer(string word, CompareType mode, Action<WordLemmaTaxonomy> onFound) { Find(word, mode, s => onFound(String2WordLemmaTaxonomy(s))); }
public OQLCompare AVG <T>(T field, CompareType type, object oValue) { return(ComparerInner <T>(field, type, oValue, "AVG({0})")); }
void Match(string word, CompareType mode, StringBuilder sb, int ofs, Action<int> onFound) { if (word.Length == sb.Length) { onFound(ofs); return; } if (ofs == -1) { onFound(ofs); return; } var backupOfs = ofs; var head = DecodeNodeHead(ref ofs); if (head.IsFinal) { onFound(backupOfs); } var someFound = false; for (var i = 0; i < head.Edges; i++) { if (word[sb.Length] == DecodeChar(ofs, mode)) { someFound = true; sb.Append(DecodeChar(ofs)); Match(word, mode, sb, DecodeEdgeTarget(ofs), onFound); sb.Length--; } SkipEdgeTarget(ref ofs); } if (someFound) return; onFound(backupOfs); }
/// <summary> /// call constructo base to set IgnoreCase flag and CompareType /// </summary> public EntityKeyCompareKey(StringComparison eqRule, CompareType compareMethod) : base(eqRule, compareMethod) { }
public void Process(DbMethodCallExpression exp, SqlGeneratorBase generator) { DbExpression left = exp.Arguments[0]; DbExpression right = exp.Arguments[2]; CompareType compareType = (CompareType)exp.Arguments[1].Evaluate(); DbExpression newExp = null; switch (compareType) { case CompareType.eq: { MethodInfo method_Sql_Equals = PublicConstants.MethodInfo_Sql_Equals.MakeGenericMethod(left.Type); /* Sql.Equals(left, right) */ DbMethodCallExpression left_equals_right = DbExpression.MethodCall(null, method_Sql_Equals, new List <DbExpression>(2) { left, right }); newExp = left_equals_right; } break; case CompareType.neq: { MethodInfo method_Sql_NotEquals = PublicConstants.MethodInfo_Sql_NotEquals.MakeGenericMethod(left.Type); /* Sql.NotEquals(left, right) */ DbMethodCallExpression left_not_equals_right = DbExpression.MethodCall(null, method_Sql_NotEquals, new List <DbExpression>(2) { left, right }); newExp = left_not_equals_right; } break; case CompareType.gt: { newExp = new DbGreaterThanExpression(left, right); } break; case CompareType.gte: { newExp = new DbGreaterThanOrEqualExpression(left, right); } break; case CompareType.lt: { newExp = new DbLessThanExpression(left, right); } break; case CompareType.lte: { newExp = new DbLessThanOrEqualExpression(left, right); } break; default: throw new NotSupportedException("CompareType: " + compareType.ToString()); } newExp.Accept(generator); }
public OQLCompare Count <T>(T field, CompareType type, object oValue) { return(ComparerInner <T>(field, type, oValue, "COUNT({0})")); }
public Condition AddNewClause(QueryType type, CompareType op, object value = null) { var c = AddNewClause(); c.SetQueryType(type); c.SetComparisonType(op); if (type == QueryType.MatchAnything || type == QueryType.MatchNothing) { c.CodeIdValue = "1,true"; return c; } if (type == QueryType.HasMyTag) { c.Tags = value.ToString(); c.CodeIdValue = "1,true"; return c; } switch (c.FieldInfo.Type) { case FieldType.NullBit: case FieldType.Bit: case FieldType.Code: case FieldType.NullCode: case FieldType.CodeStr: c.CodeIdValue = value.ToString(); break; case FieldType.Date: case FieldType.DateSimple: c.DateValue = (DateTime?)value; break; case FieldType.Number: case FieldType.NullNumber: case FieldType.NullInteger: case FieldType.String: case FieldType.StringEqual: case FieldType.Integer: case FieldType.IntegerSimple: case FieldType.IntegerEqual: c.TextValue = value.ToString(); break; default: throw new ArgumentException("type not allowed"); } return c; }
/// <summary> /// 将当前实体类的属性值应用SQL函数以后,与一个值进行比较。 /// <example> /// <code> /// <![CDATA[ /// //查询15点后登录的用户 /// Users user = new Users(); /// /// OQL q = OQL.From(user) /// .Select() /// .Where(cmp => cmp.ComparerSqlFunction(user.LastLoginTime, OQLCompare.CompareType.Greater, 15, "DATEPART(hh, {0})")) /// .END; /// ]]> /// </code> /// </example> /// </summary> /// <typeparam name="T">属性的类型</typeparam> /// <param name="field">属性字段</param> /// <param name="type">比较类型枚举</param> /// <param name="Value">应用函数后要比较的值</param> /// <param name="sqlFunctionFormat">SQL 函数格式串,例如 "DATEPART(hh, {0})"</param> /// <returns>比较表达式</returns> public OQLCompare ComparerSqlFunction <T>(T field, CompareType type, object Value, string sqlFunctionFormat) { return(ComparerInner <T>(field, type, Value, sqlFunctionFormat)); }
internal void SetPlusParentsOf(CompareType op, bool tf) { var c = this; while (c.Parent != null) c = c.Parent; c.PlusParentsOf = ((tf && op == CompareType.Equal) || (!tf && op == CompareType.NotEqual)); }
private OQLCompare ComparerInner <T>(T field, CompareType type, object oValue, string sqlFunctionFormat) { OQLCompare compare = new OQLCompare(this.LinkedOQL); TableNameField leftField; TableNameField rightField; compare.LinkedOQL.TakeTwoStackFields(field, oValue, out leftField, out rightField); if (leftField != null) { compare.ComparedFieldName = leftField.SqlFieldName; } else if (rightField != null) { compare.ComparedFieldName = rightField.SqlFieldName; } else { throw new Exception("前或者后的比较字段对像均为空!"); } compare.ComparedType = type; if (type == CompareType.IS || type == CompareType.IsNot) { if (oValue != null) { string strValue = oValue.ToString().ToUpper().Trim(); if (strValue == "NULL" || strValue == "NOT NULL") { compare.ComparedParameterName = strValue; } else { throw new ArgumentOutOfRangeException("IS 操作符的对象只能是NULL 或者 NOT NULL"); } } else { compare.ComparedParameterName = "NULL"; } } else if (type == CompareType.IN || type == CompareType.NotIn) { throw new ArgumentOutOfRangeException("IN,NOT IN 操作符请使用Comparer方法中带数组参数的重载方法"); } else { if (leftField != null && rightField != null) { //可能直接用相同的字段来比较,感谢网友Sharp_C 发现此问题 if (leftField.SqlFieldName == rightField.SqlFieldName) { compare.ComparedParameterName = compare.LinkedOQL.CreateParameter(leftField, oValue); } else { compare.ComparedParameterName = rightField.SqlFieldName; } } else if (leftField != null && rightField == null) { compare.ComparedParameterName = compare.LinkedOQL.CreateParameter(leftField, oValue); } else if (leftField == null && rightField != null) { compare.ComparedFieldName = compare.LinkedOQL.CreateParameter(rightField, field); compare.ComparedParameterName = rightField.SqlFieldName; } else { throw new InvalidOperationException("当前OQLCompare 内部操作状态无效,条件比较未使用实体类的属性。"); } } compare.SqlFunctionFormat = sqlFunctionFormat; //compare.LinkedOQL.fieldStack.Clear();//TakeTwoStackFields 方法已经清理过 return(compare); }
public CompareItem(string fullPath, CompareType type) { this.FullPath = fullPath; this.Type = type; }
public OQLCompare SUM <T>(T field, CompareType type, T Value) { return(Comparer <T>(field, type, Value, "SUM({0})")); }
public void AreEqual(string tcnameid, string linkName, string VerifyParameter, string exp, string act, CompareType compareOperator) { if (counter == 1) { dtRep.Columns.Add("TestCaseNameORId"); dtRep.Columns.Add("LinkName"); dtRep.Columns.Add("VerifyParameter"); dtRep.Columns.Add("Expected"); dtRep.Columns.Add("Actual"); dtRep.Columns.Add("Result"); } DataRow dr = dtRep.NewRow(); switch (compareOperator.ToString().ToLower()) #region OperatorsofVerify { case "equal": { if (exp.Length > 0) { if (exp.ToLower().Trim() == act.ToLower().Trim()) { dr["TestCaseNameORId"] = tcnameid; dr["LinkName"] = linkName; dr["VerifyParameter"] = VerifyParameter; dr["Expected"] = exp; dr["Actual"] = trimcustom(act); dr["Result"] = "Pass"; } else { dr["TestCaseNameORId"] = tcnameid; dr["LinkName"] = linkName; dr["VerifyParameter"] = VerifyParameter; dr["Expected"] = exp; dr["Actual"] = trimcustom(act); dr["Result"] = "Fail"; } } break; } case "contains": { if (exp.Length > 0) { if (cleanIntermediateWhiteSpaces(act).ToLower().Contains(cleanIntermediateWhiteSpaces(exp).ToLower())) { dr["TestCaseNameORId"] = tcnameid; dr["LinkName"] = linkName; dr["VerifyParameter"] = VerifyParameter; dr["Expected"] = exp; dr["Actual"] = trimcustom(act); dr["Result"] = "Pass"; } else { dr["TestCaseNameORId"] = tcnameid; dr["LinkName"] = linkName; dr["VerifyParameter"] = VerifyParameter; dr["Expected"] = exp; dr["Actual"] = trimcustom(act); dr["Result"] = "Fail"; } } break; } case "tolerance": { break; } case "decimalround": { break; } default: { break; } } #endregion if (dr["TestCaseNameORId"].ToString().Length > 0) { dtRep.Rows.Add(dr); } counter++; }
/// <summary> /// call constructo base to set IgnoreCase flag /// </summary> public ProjectCompareKey(StringComparison eqRule, CompareType compareMethod) : base(eqRule, compareMethod) { }