public override object Convert(IPropertyContext context) { Type propertyType = context.Property.PropertyType; if (context.RawValueFromRequest != null) { var rawValue = context.RawValueFromRequest.RawValue; if (rawValue.GetType() == propertyType) { return rawValue; } var converter = TypeDescriptor.GetConverter(propertyType); if (rawValue.ToString().IsValidNumber()) { var valueToConvert = removeNumericGroupSeparator(rawValue.ToString()); return converter.ConvertFrom(valueToConvert); } return converter.ConvertFrom(rawValue); } return 0; }
public override object Convert(IPropertyContext context) { if (context.PropertyValue is bool) return context.PropertyValue; return context.PropertyValue.ToString().Contains(context.Property.Name) || context.PropertyValue.ToString().EqualsIgnoreCase(CheckboxOn) || (bool)_converter.ConvertFrom(context.PropertyValue); }
public override object Convert(IPropertyContext context) { var strVal = context.PropertyValue as String; return strVal.IsNotEmpty() ? Environment.ExpandEnvironmentVariables(strVal) : strVal; }
public override object Convert(IPropertyContext context) { var strVal = context.PropertyValue as String; return strVal.IsNotEmpty() ? strVal.ToPhysicalPath() : strVal; }
public override object Convert(IPropertyContext context) { var entityType = context.Property.PropertyType; var repo = context.Service<IRepository>(); var id = context.ValueAs<Guid?>(); return (id.HasValue) ? repo.Get(entityType, id.Value) : null; }
public override object Convert(IPropertyContext context) { var stringValue = context.RawValueFromRequest.RawValue as String; return stringValue.IsNotEmpty() ? getConnectionString(stringValue) : stringValue; }
public override object Convert(IPropertyContext context) { var stringValue = context.PropertyValue as String; return stringValue.IsNotEmpty() ? stringValue.ToAbsoluteUrl() : stringValue; }
public override object Convert(IPropertyContext context) { var bindingValue = context.RawValueFromRequest; var strVal = bindingValue.RawValue as string; return strVal.IsNotEmpty() ? Environment.ExpandEnvironmentVariables(strVal) : strVal; }
public override object Convert(IPropertyContext context) { var data = context.RawValueFromRequest == null ? null : context.RawValueFromRequest.RawValue as string; if (data.IsEmpty()) { return new GroupedDependency[0]; } return GroupedDependency.Parse(data); }
public override object Convert(IPropertyContext context) { if (context.Property.PropertyType.IsNullable() && isEmpty(context.RawValueFromRequest.RawValue)) return null; var userTimeZone = context.Get<ITimeZoneContext>().GetTimeZone(); var localTime = System.Convert.ToDateTime(context.ValueAs<DateTime>()); return localTime.ToUniversalTime(userTimeZone); }
public override object Convert(IPropertyContext context) { var rawValue = context.RawValueFromRequest.RawValue; if (rawValue is Duration) return rawValue; if (rawValue is TimeSpan) return new Duration((TimeSpan)rawValue); return Duration.FromHumanReadableString(rawValue.ToString()); }
public override object Convert(IPropertyContext context) { var rawValue = context.RawValueFromRequest.RawValue; if (rawValue is bool) return rawValue; var valueString = rawValue.ToString(); return valueString.Contains(context.Property.Name) || valueString.EqualsIgnoreCase(CheckboxOn) || (bool)_converter.ConvertFrom(rawValue); }
public void SetUp() { _registry = new ValueConverterRegistry(new IConverterFamily[0]); _property = typeof(PropertyHolder).GetProperty("Property"); _basicTypeConverter = _registry.Families.SingleOrDefault(cf => cf.Matches(_property)) as BasicTypeConverter; _basicTypeConverter.ShouldNotBeNull(); _context = MockRepository.GenerateMock<IPropertyContext>(); _propertyValue = "some value"; _context.Expect(c => c.PropertyValue).Return(_propertyValue).Repeat.Times(3); }
public void SetUp() { _registry = new ValueConverterRegistry(new IConverterFamily[0]); _property = typeof(HttpRequestBase).GetProperty("Browser"); _aspNetObjectConversionFamily = _registry.Families.SingleOrDefault(cf => cf.Matches(_property)) as ASPNetObjectConversionFamily; _aspNetObjectConversionFamily.ShouldNotBeNull(); _context = MockRepository.GenerateMock<IPropertyContext>(); _propertyValue = new object(); _context.Expect(c => c.PropertyValue).Return(_propertyValue); }
public void SetUp() { _registry = new BindingRegistry(); _property = typeof (PropertyHolder).GetProperty("Property"); _numericTypeFamily = _registry.AllConverterFamilies().FirstOrDefault(cf => cf.Matches(_property)) as NumericTypeFamily; _numericTypeFamily.ShouldNotBeNull(); _context = MockRepository.GenerateMock<IPropertyContext>(); _context.Stub(x => x.Property).Return(_property); _propertyValue = new BindingValue { RawValue = "1.000,001" }; _context.Expect(c => c.RawValueFromRequest).Return(_propertyValue).Repeat.Times(4); }
public void SetUp() { _registry = StructureMapContainerFacility.GetBasicFubuContainer().GetInstance<IValueConverterRegistry>().As <ValueConverterRegistry>(); _property = typeof(HttpRequestBase).GetProperty("Browser"); _aspNetObjectConversionFamily = _registry.Families.SingleOrDefault(cf => cf.Matches(_property)) as AspNetObjectConversionFamily; _aspNetObjectConversionFamily.ShouldNotBeNull(); _context = MockRepository.GenerateMock<IPropertyContext>(); _propertyValue = new object(); _context.Expect(c => c.PropertyValue).Return(_propertyValue); }
public void SetUp() { _registry = StructureMapContainerFacility.GetBasicFubuContainer().GetInstance <IValueConverterRegistry>().As <ValueConverterRegistry>(); _property = typeof(HttpRequestBase).GetProperty("Browser"); _aspNetObjectConversionFamily = _registry.Families.SingleOrDefault(cf => cf.Matches(_property)) as AspNetObjectConversionFamily; _aspNetObjectConversionFamily.ShouldNotBeNull(); _context = MockRepository.GenerateMock <IPropertyContext>(); _propertyValue = new object(); _context.Expect(c => c.PropertyValue).Return(_propertyValue); }
public override object Convert(IPropertyContext context) { var rawValue = context.RawValueFromRequest.RawValue; if (rawValue is bool) { return(rawValue); } var valueString = rawValue.ToString(); return(valueString.Contains(context.Property.Name) || valueString.EqualsIgnoreCase(CheckboxOn) || (bool)_converter.ConvertFrom(rawValue)); }
public override object Convert(IPropertyContext context) { var rawValue = context.RawValueFromRequest.RawValue; if (rawValue is bool) return rawValue; var valueString = rawValue.ToString(); if (valueString.IsEmpty()) return false; if (valueString.Contains(context.Property.Name)) return true; if (valueString.EqualsIgnoreCase(CheckboxOn)) return true; if (_positives.Any(x => x.Equals(valueString, StringComparison.OrdinalIgnoreCase))) return true; if (_negatives.Any(x => x.Equals(valueString, StringComparison.OrdinalIgnoreCase))) return false; return (bool)_converter.ConvertFrom(rawValue); }
/// <summary> /// Performs the duplicate validation check. /// </summary> /// <param name="context">The <see cref="IPropertyContext"/>.</param> /// <param name="items">The items to duplicate check.</param> private void DuplicateValidation(IPropertyContext context, IEnumerable <TItemEntity> items) { if (!_duplicateCheck) { return; } if (_propertyExpression == null) { var dict = new Dictionary <UniqueKey, object?>(new UniqueKeyComparer()); foreach (var item in items.Where(x => x != null).Cast <IUniqueKey>()) { if (dict.ContainsKey(item.UniqueKey)) { if (item.UniqueKey.Args.Length == 1) { context.CreateErrorMessage(ValidatorStrings.DuplicateValueFormat, _duplicateText !, item.UniqueKey.Args[0]); } else { context.CreateErrorMessage(ValidatorStrings.DuplicateValue2Format, _duplicateText !); } return; } dict.Add(item.UniqueKey, null); } } else { var dict = new Dictionary <object?, object?>(); foreach (var item in items) { var val = _propertyExpression.GetValue(item); if (dict.ContainsKey(_propertyExpression.GetValue(item))) { context.CreateErrorMessage(ValidatorStrings.DuplicateValueFormat, _duplicateText !, val !); return; } dict.Add(val, null); } } }
public override object Convert(IPropertyContext context) { Type propertyType = context.Property.PropertyType; var converter = TypeDescriptor.GetConverter(propertyType); if (context.PropertyValue != null) { if (context.PropertyValue.GetType() == propertyType) { return(context.PropertyValue); } if (context.PropertyValue.ToString().IsValidNumber()) { var valueToConvert = removeNumericGroupSeparator(context.PropertyValue.ToString()); return(converter.ConvertFrom(valueToConvert)); } } return(converter.ConvertFrom(context.PropertyValue)); }
public override object Convert(IPropertyContext context) { var rawValue = context.RawValueFromRequest.RawValue.ToString(); var enumType = context.Property.PropertyType; try { return Enum.Parse(enumType, rawValue, true); } catch (Exception) { var problems = new List<ConvertProblem> { new ConvertProblem { Item = rawValue, Property = context.Property} }; // This is a fubu exception that will build up binding errors in the response // and assign them to the input model (context.Object.GetType()) throw new BindResultAssertionException(context.Object.GetType(), problems); } }
/// <summary> /// Performs the duplicate validation check. /// </summary> /// <param name="context">The <see cref="IPropertyContext"/>.</param> /// <param name="items">The items to duplicate check.</param> void ICollectionRuleItem.DuplicateValidation(IPropertyContext context, IEnumerable items) { DuplicateValidation(context, (IEnumerable <TItemEntity>)items); }
public NamesRepository(PropertyDatabaseContext context) : base(context) { Context = context; }
public void SetUp() { _registry = new ValueConverterRegistry(new IConverterFamily[0], new ConverterLibrary()); _property = typeof (PropertyHolder).GetProperty("Property"); _numericTypeFamily = _registry.Families.FirstOrDefault(cf => cf.Matches(_property)) as NumericTypeFamily; _numericTypeFamily.ShouldNotBeNull(); _context = MockRepository.GenerateMock<IPropertyContext>(); _context.Stub(x => x.Property).Return(_property); _propertyValue = "1,000.001"; _context.Expect(c => c.PropertyValue).Return(_propertyValue).Repeat.Times(4); }
public override object Convert(IPropertyContext context) { var data = context.RawValueFromRequest == null ? null : context.RawValueFromRequest.RawValue as string; return data.IsEmpty() ? null : VersionConstraint.Parse(data); }
public override object Convert(IPropertyContext context) { return(context.RawValueFromRequest != null ? context.RawValueFromRequest.RawValue : null); }
public override object Convert(IPropertyContext context) { return context.RawValueFromRequest; }
protected PropertyRepository(Entity.PropertyDatabaseContext context) : base(context) { Context = context; }
/// <summary> /// Checks the clauses. /// </summary> /// <param name="context">The <see cref="PropertyContext{TEntity, TProperty}"/>.</param> /// <returns><c>true</c> where validation is to continue; otherwise, <c>false</c> to stop.</returns> bool IValueRule <TEntity, TProperty> .Check(IPropertyContext context) { // All good, nothing to see here ;-) throw new NotSupportedException("A property value clauses check should not occur directly on a PropertyRule."); }
public override object Convert(IPropertyContext context) { return(context.PropertyValue); }
public object Convert(IPropertyContext context) { return _converter(context); }
public override object Convert(IPropertyContext context) { if (context.RawValueFromRequest == null) return null; return context.RawValueFromRequest.RawValue; }
/// <summary> /// Checks the clause. /// </summary> /// <param name="context">The <see cref="PropertyContext{TEntity, TProperty}"/>.</param> /// <returns><c>true</c> where validation is to continue; otherwise, <c>false</c> to stop.</returns> public bool Check(IPropertyContext context) { return(_when != null?_when.Invoke() : _entityPredicate != null?_entityPredicate.Invoke((TEntity)context.Parent.Value) : _propertyPredicate.Invoke((TProperty)context.Value)); }
public abstract object Convert(IPropertyContext context);
public PropertyQueryableOwner(IPropertyContext context) { Queryable = context.Set <TProperty>(); }
/// <summary> /// Checks the clause. /// </summary> /// <param name="context">The <see cref="PropertyContext{TEntity, TProperty}"/>.</param> /// <returns><c>true</c> where validation is to continue; otherwise, <c>false</c> to stop.</returns> bool IValueRule <TEntity, TProperty> .Check(IPropertyContext context) { return(Check((PropertyContext <TEntity, TProperty>)context)); }
public object Convert(IPropertyContext context) { return(_converter(context)); }
public override object Convert(IPropertyContext context) { return context.PropertyValue; }
public ManyToManyRepository(PropertyDatabaseContext context) : base(context) { Context = context; }
public static object LuaGetProperty(IPropertyContext context, string name) { return(context.GetProperty <object>(name)); }
public override object Convert(IPropertyContext context) { return new LoanNumber(context.ValueAs<string>()); }
public override object Convert(IPropertyContext context) { var data = context.RawValueFromRequest == null ? null : context.RawValueFromRequest.RawValue as string; return(data.IsEmpty() ? null : VersionConstraint.Parse(data)); }
public static bool LuaSetProperty(IPropertyContext context, string name, object value, PropertyTypeOptions flags) { context.SetProperty(name, value, flags); return(true); }