public void SortByTime() { IComparer c = new TimeComparator(); Sort(c); this.currentOrder = DataOrder.TimeOrder; } /* SortByTime */
} // getName() // public override Comparator<object> getComparator() public IComparer <object> getComparator() { if (isTimeBased()) { return(TimeComparator.getComparator()); } if (isNumber()) { return(NumberComparator.getComparator()); } if (isLiteral()) { return(ToStringComparator.getComparator()); } return(ObjectComparator.getComparator()); } // getComparator()
public void TestEventuallyTimeBound(string input, TimeComparator comparator) { var model = parser.Parse(input); var root = model.Goals().Where(x => x.Identifier == "test").ShallBeSingle(); var implication = root.FormalSpec as StrongImply; Assert.NotNull(implication); var sooner_or_later = implication.Right as Eventually; Assert.NotNull(sooner_or_later); sooner_or_later.TimeBound.Comparator.ShallEqual(comparator); sooner_or_later.TimeBound.Bound.ShallEqual(new TimeSpan(0, 12, 0)); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { PropertyInfo propertyInfo = validationContext.ObjectType.GetProperty(_comparePropertyName); if (propertyInfo == null) { return(null); } if (value == null) { return(null); } if (!propertyInfo.PropertyType.Equals(value.GetType())) { return(null); } bool result = false; switch (_compareType) { case CompareType.NUMBER: result = new NumberComparator().Compare((float)value, (float)propertyInfo.GetValue(validationContext.ObjectInstance), _compareOperator); break; case CompareType.TIME: result = new TimeComparator().Compare((string)value, (string)propertyInfo.GetValue(validationContext.ObjectInstance), _compareOperator); break; case CompareType.DATE: result = new DateComparator().Compare((DateTime)value, (DateTime)propertyInfo.GetValue(validationContext.ObjectInstance), _compareOperator); break; case CompareType.STRING: result = new StringComparator().Compare((string)value, (string)propertyInfo.GetValue(validationContext.ObjectInstance), _compareOperator); break; } if (!result) { return(new ValidationResult(string.Format(ErrorMessageString, validationContext.DisplayName, _comparePropertyName))); } return(ValidationResult.Success); }
public void TestGloballyTimeBound(string input, TimeComparator comparator) { var model = parser.Parse(input); var root = model.Obstacles().Where(x => x.Identifier == "test").ShallBeSingle(); var sooner_or_later = root.FormalSpec as Eventually; Assert.NotNull(sooner_or_later); var and = sooner_or_later.Enclosed as And; Assert.NotNull(and); var globally = and.Right as Globally; Assert.NotNull(globally); globally.TimeBound.Comparator.ShallEqual(comparator); globally.TimeBound.Bound.ShallEqual(new TimeSpan(0, 12, 0)); }
public void TestGloballyTimeBound(string input, TimeComparator comparator) { var model = parser.Parse (input); var root = model.Obstacles().Where (x => x.Identifier == "test").ShallBeSingle (); var sooner_or_later = root.FormalSpec as Eventually; Assert.NotNull (sooner_or_later); var and = sooner_or_later.Enclosed as And; Assert.NotNull (and); var globally = and.Right as Globally; Assert.NotNull (globally); globally.TimeBound.Comparator.ShallEqual (comparator); globally.TimeBound.Bound.ShallEqual (new TimeSpan (0, 12, 0)); }
public void TestEventuallyTimeBound(string input, TimeComparator comparator) { var model = parser.Parse (input); var root = model.Goals().Where (x => x.Identifier == "test").ShallBeSingle (); var implication = root.FormalSpec as StrongImply; Assert.NotNull (implication); var sooner_or_later = implication.Right as Eventually; Assert.NotNull (sooner_or_later); sooner_or_later.TimeBound.Comparator.ShallEqual (comparator); sooner_or_later.TimeBound.Bound.ShallEqual (new TimeSpan (0, 12, 0)); }