Ejemplo n.º 1
0
        public BindResult Bind(Type type, object instance, IRequestData data)
        {
            var result = new BindResult
            {
                Value = instance
            };

            Populate(result, type, data);

            return result;
        }
Ejemplo n.º 2
0
        public void SetUp()
        {
            // Lots of stuff to put together, so I'm just using a minimalistic
            // container to do it for me because I'm lazy -- JDM 2/12/2010
            var container = StructureMapContainerFacility.GetBasicFubuContainer();
            binder = container.GetInstance<StandardModelBinder>();

            context = new InMemoryBindingContext();

            result = null;
        }
Ejemplo n.º 3
0
 public void SetUp()
 {
     registry = new ValueConverterRegistry(new IConverterFamily[0]);
     data = new InMemoryRequestData();
     binder = new StandardModelBinder(registry, new TypeDescriptorRegistry());
     locator = MockRepository.GenerateMock<IServiceLocator>();
     result = null;
 }
Ejemplo n.º 4
0
        private void setPropertyValue(PropertyInfo property, object rawValue, BindResult result)
        {
            try
            {
                var value = ConvertValue(property, rawValue);
                property.SetValue(result.Value, value, null);
            }
            catch (Exception e)
            {
                var problem = new ConvertProblem
                {
                    Exception = e,
                    Item = result.Value,
                    Property = property,
                    Value = rawValue
                };

                result.Problems.Add(problem);
            }
        }
Ejemplo n.º 5
0
 private void Populate(BindResult result, Type type, IRequestData data)
 {
     _typeRegistry.ForEachProperty(type, prop =>
         data.Value(NamingStrategy(prop), raw => setPropertyValue(prop, raw, result)));
 }