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);
            });
        }
Beispiel #2
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);
        }