Beispiel #1
0
        public IComponentAdapter CreateComponentAdapter(WebComponentMetadata metadata)
        {
            var componentClrType = metadata.DeclaredProperty.PropertyType.Bindings.First <Type>();

            if (componentClrType.IsGenericType && componentClrType.GetGenericTypeDefinition() == typeof(FormComponent <>))
            {
                var modelClrType         = componentClrType.GenericTypeArguments[0];
                var componentAdapterType = typeof(FormComponentAdapter <>).MakeGenericType(modelClrType);
                return((IComponentAdapter)Activator.CreateInstance(componentAdapterType, new object[] { metadata, null }));
            }

            throw new NotSupportedException($"Component type not supported: '${componentClrType.Name}'.");
        }
Beispiel #2
0
 public FormComponentAdapter(WebComponentMetadata metadata, FormComponent <TModel> component)
     : base(metadata, component)
 {
 }
Beispiel #3
0
 protected ComponentAdapter(WebComponentMetadata metadata, TComponent component)
 {
     this.Metadata     = metadata;
     this.Component    = component;
     this.ModelBinding = Metadata.PropertyMap.GetValueOrDefault("Model"); //TODO: find a way to use nameof()
 }