public void Bind(PropertyInfo property, IBindingContext context)
        {
            if (context.Object == null)
            {
                return;
            }

            Type entityType = context.Object.GetTrueType();

            // If there is no Extends<> for the entity type, do nothing
            if (!ExtensionProperties.HasExtensionFor(entityType))
            {
                return;
            }

            Type extensionType = ExtensionProperties.ExtensionFor(entityType);

            // direct the FubuMVC model binding to resolve an object of the
            // extensionType using "entityType.Name" as the prefix on the form data,
            // and place the newly created object using the specified property
            var childRequest = context.GetSubRequest(property.Name);

            context.BindObject(childRequest, property.PropertyType, o =>
            {
                property.SetValue(context.Object, o, null);
            });
        }
Exemplo n.º 2
0
 public void Process(Type type, Registry graph)
 {
     if (type.IsConcrete() && type.BaseType.IsGenericType && type.BaseType.GetGenericTypeDefinition() == typeof(Extends <>))
     {
         var entityType = type.BaseType.GetGenericArguments()[0];
         ExtensionProperties.Register(entityType, type);
     }
 }
Exemplo n.º 3
0
        public void Bind(PropertyInfo property, IBindingContext context)
        {
            if (context.Object == null)
            {
                return;
            }

            Type entityType = context.Object.GetTrueType();

            // If there is no Extends<> for the entity type, do nothing
            if (!ExtensionProperties.HasExtensionFor(entityType))
            {
                return;
            }

            Type extensionType = ExtensionProperties.ExtensionFor(entityType);

            // direct the FubuMVC model binding to resolve an object of the
            // extensionType using "entityType.Name" as the prefix on the form data,
            // and place the newly created object using the specified property
            context.BindChild(property, extensionType, string.Empty);
        }