예제 #1
0
        public object Bind(Type inputModelType, IBindingContext context)
        {
            //we determine the type by sniffing the ctor arg
            var entityType = inputModelType
                             .GetConstructors()
                             .Single(x => x.GetParameters().Count() == 1)
                             .GetParameters()
                             .Single()
                             .ParameterType;

            var entity = tryFindExistingEntity(entityType, context)
                         ?? createNewEntity(entityType, context);

            var model = (EditEntityModel)Activator.CreateInstance(inputModelType, entity);

            context.BindProperties(model);

            // Get the binding errors from conversion of the EditEntityModel
            context.Problems.Each(x =>
            {
                model.Notification.RegisterMessage(x.Property, FastPackKeys.PARSE_VALUE);
            });

            return(model);
        }
예제 #2
0
        public object Bind(Type type, IBindingContext context)
        {
            object model = Activator.CreateInstance(type);

            context.BindProperties(model);
            return(model);
        }
        public object Bind(Type inputModelType, IBindingContext context)
        {
            //we determine the type by sniffing the ctor arg
            var entityType = inputModelType
                .GetConstructors()
                .Single(x => x.GetParameters().Count() == 1)
                .GetParameters()
                .Single()
                .ParameterType;

            var entity = tryFindExistingEntity(entityType, context)
                ?? createNewEntity(entityType, context);

            var model = (EditEntityModel)Activator.CreateInstance(inputModelType, entity);

            context.BindProperties(model);

            // Get the binding errors from conversion of the EditEntityModel
            context.Problems.Each(x =>
            {
                model.Notification.RegisterMessage(x.Property, FastPackKeys.PARSE_VALUE);
            });

            return model;
        }
예제 #4
0
        public object Bind(Type type, IBindingContext context)
        {
            var path = FindPath(context.Service<IRequestData>());
            object instance = Activator.CreateInstance(type, path);

            // Setting additional properties
            // TODO -- have this delegate to a new method on BindingContext instead
            context.BindProperties(instance);

            return instance;
        }
예제 #5
0
        public object Bind(Type type, IBindingContext context)
        {
            var path     = FindPath(context.Service <IRequestData>());
            var instance = Activator.CreateInstance(type, path);

            // Setting additional properties
            // TODO -- have this delegate to a new method on BindingContext instead
            context.BindProperties(instance);    // START HERE AFTER BASEBALL

            return(instance);
        }
예제 #6
0
        public object Bind(Type type, IBindingContext context)
        {
            var instance = Activator.CreateInstance(type);

            // let the default binders set all the route values and things
            context.BindProperties(instance);

            var data = context.Service<IStreamingData>().InputText();

            var x = XDocument.Parse(data);

            // TODO - simple implementation. Would be susceptible to overwriting route values from query and url
            foreach (var element in x.Root.Elements())
            {
                SetProperty(type, instance, element, element.Name.ToString());
            }

            return instance;
        }
예제 #7
0
 public object Bind(Type type, IBindingContext context)
 {
     object model = Activator.CreateInstance(type);
     context.BindProperties(model);
     return model;
 }