public override BooleanValue HasField(StringValue fieldName) { if (fieldName.Equals(RTTargetField)) { return(true); } return(base.HasField(fieldName)); }
public bool Matches(QueryNestedGuidItem item) { return (SortOrder.Equals(item.SortOrder) && StringValue.Equals(item.StringValue) && Container.NestedInt.Equals(item.Container.NestedInt) && Container.NestedString.Equals(item.Container.NestedString)); }
public void CreateStringValue(string value, string expected, bool isEmpty) { // Arrange & Act var stringValue = new StringValue(value); // Assert Assert.Equal(expected, stringValue.ToStringValue()); Assert.Equal(isEmpty, stringValue.Equals(StringValue.Empty)); }
/// <summary> /// Equals overload. /// </summary> /// <param name="s">The string to compare to.</param> /// <returns>bool</returns> public bool Equals(string s) { if (s == null) { return(false); } else { return(StringValue.Equals(s)); } }
/// <summary> /// WARNING: This function returns true if the object being compared can provide an equal value, even if the types differ. /// Use IsIdenticalTo to check for complete equality (same type and value) /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { object compareObject = obj; if (obj == this) { return(true); } else if (obj == Empty || this == Empty) { return(false); } if (obj is BindingValue) { BindingValue bvObj = (BindingValue)obj; switch (bvObj._nativeValueType) { case BindingValueType.Boolean: compareObject = bvObj.BoolValue; break; case BindingValueType.String: compareObject = bvObj.StringValue; break; case BindingValueType.Double: compareObject = bvObj.DoubleValue; break; } } // XXX rewrite. this is insanely inefficient to use a type check here to check what branch we took above if (compareObject is string) { return(StringValue.Equals(compareObject)); } else if (compareObject is double) { return(DoubleValue.Equals(compareObject)); } else if (compareObject is bool) { return(BoolValue.Equals(compareObject)); } return(false); }
public override bool Equals(object obj) { object compareObject = obj; if (obj == this) { return(true); } else if (obj == Empty || this == Empty) { return(false); } if (obj is BindingValue) { BindingValue bvObj = (BindingValue)obj; switch (bvObj._nativeValueType) { case BindingValueType.Boolean: compareObject = bvObj.BoolValue; break; case BindingValueType.String: compareObject = bvObj.StringValue; break; case BindingValueType.Double: compareObject = bvObj.DoubleValue; break; } } if (compareObject is string) { return(StringValue.Equals(compareObject)); } else if (compareObject is double) { return(DoubleValue.Equals(compareObject)); } else if (compareObject is bool) { return(BoolValue.Equals(compareObject)); } return(false); }
public void TestLookupMultipleValuesForTemplate() { Dictionary dictionary = new TemplateDictionary(); Group template = new MessageTemplate("Position", new Field[] { new Scalar("exchange", FASTType.STRING, Operator.COPY, ScalarValue.UNDEFINED, false) }); ScalarValue value = new StringValue("NYSE"); ScalarValue marketValue = new DecimalValue(100000.00); dictionary.Store(template, FastConstants.ANY_TYPE, new QName("exchange"), value); dictionary.Store(template, FastConstants.ANY_TYPE, new QName("marketValue"), marketValue); Assert.IsFalse(value.Equals(ScalarValue.UNDEFINED)); Assert.AreEqual(value, dictionary.Lookup(template, new QName("exchange"), FastConstants.ANY_TYPE)); Assert.AreEqual(marketValue, dictionary.Lookup(template, new QName("marketValue"), FastConstants.ANY_TYPE)); }
public bool Equals(TestObject other) { return(IntValue == other.IntValue && (NullableIntValue == null && other.NullableIntValue == null) || NullableIntValue.Equals(other.NullableIntValue) && DecimalValue == other.DecimalValue && (NullableDecimalValue == null && other.NullableDecimalValue == null) || NullableDecimalValue.Equals(other.NullableDecimalValue) && (StringValue == null && other.StringValue == null) || StringValue.Equals(other.StringValue) && DateValue == other.DateValue && (NullableDateValue == null && other.NullableDateValue == null) || NullableDateValue.Equals(other.NullableDateValue) && TimeSpanValue == other.TimeSpanValue && (NullableDateValue == null && other.NullableDateValue == null) || NullableDateValue.Equals(other.NullableDateValue) && (IntArray == null && other.IntArray == null) || IntArray.SequenceEqual(other.IntArray) && (IntCollection == null && other.IntCollection == null) || IntCollection.SequenceEqual(other.IntCollection) && GuidValue == other.GuidValue && (NullableGuidValue == null && other.NullableGuidValue == null) || NullableGuidValue.Equals(other.NullableGuidValue) ); }
// Checks if one value is the same as another value public override Boolean Equals(Object o) { /* * ValType thisType = this.GetType(); * * ValType thatType = that.GetType(); */ var that = (Value)o; if (TypeEquals(ValType.Double, true) || that.TypeEquals(ValType.Double, true)) { // Float Comparison double diff = Math.Abs(DoubleValue - that.DoubleValue); return(diff < 0.00000000001); } else if (TypeEquals(ValType.Integer, true) && that.TypeEquals(ValType.Integer, true)) { // Integer Comparison return(IntValue == that.IntValue); } else if (Type == ValType.Boolean && that.Type == ValType.Boolean) { // Boolean Comparison return(BoolValue == that.BoolValue); } else if (Type == ValType.String && that.Type == ValType.String) { // String Comparison return(StringValue.Equals(that.StringValue, StringComparison.Ordinal)); } else if (Type == that.Type && (Type == ValType.Layer || Type == ValType.LoopType || Type == ValType.Origin || Type == ValType.LoopTrigger)) { // Comparison of other string-like types return(StringValue.Equals(that.StringValue, StringComparison.Ordinal)); } else { // everything else shouldn't be compared //throw new CompilerException(-1, 204, new String[] {Value.TypeToString(thisType), Value.TypeToString(thatType)}); // TODO: Exception //throw new Exception(); return(false); } }
public IHttpActionResult PostAddFavourite([FromBody] StringValue query) { try { if (query.Equals(null)) { return(Ok(new Login(false, "Query can not be equal to null"))); } string value1 = query.value1; string value2 = query.value2; if (stringValidate(value1) && stringValidate(value2)) { MySQLConnection dbConnection = new MySQLConnection(); MySqlDataReader reader = dbConnection.getMySqlDataReader("INSERT INTO opensouce.favourites (favourites.email_address1, favourites.email_address2) VALUES ('" + value1 + "', '" + value2 + "');"); reader.Read(); StringValue response = new StringValue(); if (reader.RecordsAffected == 1) { response.value1 = "done"; dbConnection.closeConnection(); return(Ok(response)); } else { response.value1 = "failed"; dbConnection.closeConnection(); return(Ok(response)); } } else { return(Ok(new User())); } } catch (MySqlException ex) { return(NotFound()); } catch (NullReferenceException ex) { return(NotFound()); } }
public static ScalarValue GetDifference(StringValue newValue, StringValue priorValue) { string value_Renamed = newValue.value_Renamed; if ((priorValue == null) || (priorValue.value_Renamed.Length == 0)) { return(new TwinValue(new IntegerValue(0), newValue)); } if (priorValue.Equals(newValue)) { return(NO_DIFF); } string base_Renamed = priorValue.value_Renamed; int appendIndex = 0; while ((appendIndex < base_Renamed.Length) && (appendIndex < value_Renamed.Length) && (value_Renamed[appendIndex] == base_Renamed[appendIndex])) { appendIndex++; } string append = value_Renamed.Substring(appendIndex); int prependIndex = 1; while ((prependIndex <= value_Renamed.Length) && (prependIndex <= base_Renamed.Length) && (value_Renamed[value_Renamed.Length - prependIndex] == base_Renamed[base_Renamed.Length - prependIndex])) { prependIndex++; } string prepend = value_Renamed.Substring(0, (value_Renamed.Length - prependIndex + 1) - (0)); if (prepend.Length < append.Length) { return(new TwinValue(new IntegerValue(prependIndex - base_Renamed.Length - 2), new StringValue(prepend))); } return(new TwinValue(new IntegerValue(base_Renamed.Length - appendIndex), new StringValue(append))); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is CatalogCustomAttributeValue other && ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) && ((StringValue == null && other.StringValue == null) || (StringValue?.Equals(other.StringValue) == true)) && ((CustomAttributeDefinitionId == null && other.CustomAttributeDefinitionId == null) || (CustomAttributeDefinitionId?.Equals(other.CustomAttributeDefinitionId) == true)) && ((Type == null && other.Type == null) || (Type?.Equals(other.Type) == true)) && ((NumberValue == null && other.NumberValue == null) || (NumberValue?.Equals(other.NumberValue) == true)) && ((BooleanValue == null && other.BooleanValue == null) || (BooleanValue?.Equals(other.BooleanValue) == true)) && ((SelectionUidValues == null && other.SelectionUidValues == null) || (SelectionUidValues?.Equals(other.SelectionUidValues) == true)) && ((Key == null && other.Key == null) || (Key?.Equals(other.Key) == true))); }
public IHttpActionResult PostUserOffline([FromBody] StringValue query) { try { if (query.Equals(null)) { return(Ok(new Login(false, "Query can not be equal to null"))); } string value2 = query.value2; if (stringValidate(value2)) { MySQLConnection dbConnection = new MySQLConnection(); MySqlDataReader reader = dbConnection.getMySqlDataReader("SELECT user.email_address, user.first_name, user.last_name, user.course_name, user.year_of_study, user.contact_number, date(user.date_created), (SELECT count(*) FROM opensouce.favourites WHERE favourites.email_address2='" + value2 + "') as favouriteCount, group_concat(skill.skill SEPARATOR '$') as skill, user.user_status, user.user_report FROM opensouce.user left join opensouce.skill on user.email_address=skill.email_address WHERE user.email_address='" + value2 + "';"); reader.Read(); if (reader.HasRows) { User sendUser = new User(); sendUser.email_address = reader.GetString(0); sendUser.first_name = reader.GetString(1); sendUser.last_name = reader.GetString(2); sendUser.course_name = reader.GetString(3); sendUser.year_of_study = reader.GetString(4); sendUser.contact_number = reader.GetString(5); sendUser.date_created = reader.GetString(6); sendUser.favourite_count = reader.GetString(7); string tempSkill = reader.GetString(8); sendUser.user_status = reader.GetString(9); sendUser.user_report = reader.GetInt32(10); char[] delimiterChars = { '$' }; string[] skills = tempSkill.Split(delimiterChars); List <Skill> templist = new List <Skill>(); foreach (string skill in skills) { Skill newSkill = new Skill(); newSkill.skill = skill; templist.Add(newSkill); } sendUser.skills = templist; dbConnection.closeConnection(); return(Ok(sendUser)); } else { dbConnection.closeConnection(); return(Ok(new User())); } } else { return(Ok(new User())); } } catch (MySqlException ex) { return(NotFound()); } catch (NullReferenceException ex) { return(NotFound()); } }
public IHttpActionResult PostSearch([FromBody] StringValue query) { try { if (query.Equals(null)) { return(Ok(new Login(false, "Query can not be equal to null"))); } string value1 = query.value1; string value2 = query.value2; if (stringValidate(value1)) { MySQLConnection dbConnection = new MySQLConnection(); MySqlDataReader reader = dbConnection.getMySqlDataReader("SELECT * FROM (SELECT user.email_address, user.first_name, user.last_name, user.profile_picture, group_concat(skill.skill SEPARATOR '$') as skill, (SELECT count(*) FROM opensouce.favourites WHERE favourites.email_address2=user.email_address) as favouriteCount, user.user_status, user.user_report FROM opensouce.user left join opensouce.skill on user.email_address=skill.email_address WHERE not user.email_address='" + value2 + "' group by user.email_address) AS here WHERE here.email_address like '%" + value1 + "%' or here.first_name like '%" + value1 + "%' or here.last_name like '%" + value1 + "%' or here.skill like '%" + value1 + "%' order by here.favouriteCount DESC;"); if (reader.HasRows) { UserList userList = new UserList(); while (reader.Read()) { User sendUser = new User(); sendUser.email_address = reader.GetString(0); sendUser.first_name = reader.GetString(1); sendUser.last_name = reader.GetString(2); sendUser.profile_picture = reader.GetString(3); string tempSkill = reader.GetString(4); sendUser.favourite_count = reader.GetString(5); sendUser.user_status = reader.GetString(6); sendUser.user_report = reader.GetInt32(7); char[] delimiterChars = { '$' }; string[] skills = tempSkill.Split(delimiterChars); List <Skill> templist = new List <Skill>(); foreach (string skill in skills) { Skill newSkill = new Skill(); newSkill.skill = skill; templist.Add(newSkill); } sendUser.skills = templist; if (sendUser.user_report < 5) { userList.Users.Add(sendUser); } } dbConnection.closeConnection(); return(Ok(userList)); } else { dbConnection.closeConnection(); return(Ok(new User())); } } else { return(Ok(new User())); } } catch (MySqlException ex) { return(NotFound()); } catch (NullReferenceException ex) { return(NotFound()); } }
public override bool CompareStrings(StringValue itemValue, StringValue value) { return(itemValue.Equals(value)); }
public TableRow CreateRowItem(StringValue title, Int32Value tableWidth, Int32Value columnNum, UInt32Value rowHeight, StringValue fontSize, JustificationValues justification) { Int32Value cellWidth = tableWidth / columnNum; TableRow tableRow = new GenerateTableRow().Create( new GenerateTablePropertyExceptions().Create( new GenerateTableBorders().Create( new GenerateTopBorder().Create(), new GenerateLeftBorder().Create(), new GenerateBottomBorder().Create(), new GenerateRightBorder().Create(), new GenerateInsideHorizontalBorder().Create(), new GenerateInsideVerticalBorder().Create() ), new GenerateTableLayout().Create(), new GenerateTableCellMarginDefault().Create( new GenerateTopMargin().Create(), new GenerateTableCellLeftMargin().Create(), new GenerateBottomMargin().Create(), new GenerateTableCellRightMargin().Create() ) ), new GenerateTableRowProperties().Create( new GenerateTableCantSplit().Create(), new GenerateTableRowHeight(rowHeight).Create() ) ); for (int i = 0; i < columnNum; i++) { Run runLeftSpace = new GenerateRun().Create( new GenerateRunProperties().Create( new GenerateRunFonts().Create(), new GenerateFontSize().Create("12") ), new GenerateText().Create(" ") ); Run runRightSpace = new GenerateRun().Create( new GenerateRunProperties().Create( new GenerateRunFonts().Create(), new GenerateFontSize().Create("12") ), new GenerateText().Create(" ") ); Run runLeft = new GenerateRun().Create( new GenerateRunProperties().Create( new GenerateRunFonts().Create(), new GenerateFontSize().Create(fontSize) ), new GenerateText().Create("[ ") ); Run runRight = new GenerateRun().Create( new GenerateRunProperties().Create( new GenerateRunFonts().Create(), new GenerateFontSize().Create(fontSize) ), new GenerateText().Create(" ]") ); Run runContent = new GenerateRun().Create( new GenerateRunProperties().Create( new GenerateRunFonts().Create(), new Color() { Val = "C0C0C0" }, new GenerateFontSize().Create(fontSize) ), new GenerateText().Create(title) ); Paragraph paragraph = new GenerateParagraph().Create( new GenerateParagraphProperties().Create( new GenerateJustification().Create(justification) // 分散对齐 ) ); if (title.Equals("")) { paragraph.Append(runContent); } else { paragraph.Append(runLeft); paragraph.Append(runLeftSpace); paragraph.Append(runContent); paragraph.Append(runRightSpace); paragraph.Append(runRight); } tableRow.Append( new GenerateTableCell().Create( new GenerateTableCellProperties().Create( new GenerateTableCellWidth(cellWidth).Create(), new GenerateTableCellBorders().Create(), new GenerateTableCellVerticalAlignment().Create() ), paragraph ) ); } return(tableRow); }
public static ScalarValue GetDifference(StringValue newValue, StringValue priorValue) { string value_Renamed = newValue.value_Renamed; if ((priorValue == null) || (priorValue.value_Renamed.Length == 0)) { return new TwinValue(new IntegerValue(0), newValue); } if (priorValue.Equals(newValue)) { return NO_DIFF; } string base_Renamed = priorValue.value_Renamed; int appendIndex = 0; while ((appendIndex < base_Renamed.Length) && (appendIndex < value_Renamed.Length) && (value_Renamed[appendIndex] == base_Renamed[appendIndex])) appendIndex++; string append = value_Renamed.Substring(appendIndex); int prependIndex = 1; while ((prependIndex <= value_Renamed.Length) && (prependIndex <= base_Renamed.Length) && (value_Renamed[value_Renamed.Length - prependIndex] == base_Renamed[base_Renamed.Length - prependIndex])) prependIndex++; string prepend = value_Renamed.Substring(0, (value_Renamed.Length - prependIndex + 1) - (0)); if (prepend.Length < append.Length) { return new TwinValue(new IntegerValue(prependIndex - base_Renamed.Length - 2), new StringValue(prepend)); } return new TwinValue(new IntegerValue(base_Renamed.Length - appendIndex), new StringValue(append)); }
public static bool Equal(StringValue a, StringValue b) => a.Equals(b);