public static void UseDefaultUIKit(this ILowkoderConfigurationService config)
        {
            // todo:unfinished


            config.Metadata.ComponentTypes.Add(new ComponentTypeMapping()
            {
                ComponentType = typeof(LowkoderDisplayName),
                SiteType      = typeof(DisplayName)
            });


            config.Metadata.ComponentTypes.Add(new ComponentTypeMapping()
            {
                ComponentType = typeof(LowkoderInputText),
                ModelType     = TypeDescriptor.ForSystemType(typeof(String)),
                SiteType      = typeof(Input)
            });
            config.Metadata.ComponentTypes.Add(new ComponentTypeMapping()
            {
                ComponentType = typeof(LowkoderInputNumber),
                ModelType     = TypeDescriptor.ForSystemType(typeof(Int32)),
                SiteType      = typeof(Input)
            });
            config.Metadata.ComponentTypes.Add(new ComponentTypeMapping()
            {
                ComponentType = typeof(LowkoderInputCheckbox),
                ModelType     = TypeDescriptor.ForSystemType(typeof(Boolean)),
                SiteType      = typeof(Input)
            });
            config.Metadata.ComponentTypes.Add(new ComponentTypeMapping()
            {
                ComponentType = typeof(LowkoderInputDate),
                ModelType     = TypeDescriptor.ForSystemType(typeof(DateTime)),
                SiteType      = typeof(Input)
            });
            config.Metadata.ComponentTypes.Add(new ComponentTypeMapping()
            {
                ComponentType = typeof(LowkoderInputSelect),
                ModelType     = TypeDescriptor.ForSystemType(typeof(Enum)),
                SiteType      = typeof(Input)
            });
        }
Exemple #2
0
        public Type Handle(FindKitType request, CancellationToken cancellationToken)
        {
            var siteSpecification = request.SiteSpecification;

            // set site type, one of: Input, Display, etc...
            var siteType      = typeof(TSite);
            var specification = site.Context.SiteSpecification;

            specification.SiteType = siteType;

            // get model type
            var modelType = specification.ModelType;

            if (specification.ModelMember != null)
            {
                modelType = specification.ModelMember.TargetProperty.PropertyType;
            }

            // get kit component type
            ComponentTypeMapping componentMapping = null;

            if (componentMapping == null && specification.ModelMember.TargetProperty.EnumType != null)
            {
                componentMapping = site.Metadata.ComponentTypes.Where(t => t.SiteType == siteType && t.ModelType == TypeDescriptor.ForSystemType(typeof(Enum))).FirstOrDefault();
            }
            if (componentMapping == null)
            {
                componentMapping = site.Metadata.ComponentTypes.Where(t => t.SiteType == siteType && t.ModelType == modelType).FirstOrDefault();
            }
            if (componentMapping == null)
            {
                componentMapping = site.Metadata.ComponentTypes.Where(t => t.SiteType == siteType && t.ModelType == null).FirstOrDefault();
            }
            if (componentMapping == null)
            {
                throw new Exception("No component mapping found for SiteType '" + siteType.FullName + "' and  ModelType '" + modelType.DisplayName + "'");
            }

            // render 'kit' component
            var componentType = componentMapping.ComponentType;

            return(componentType);
        }
        public static void ContributeMetadataForType <TEntity>(this ILowkoderConfigurationService config)
        {
            var typeMetadata = TypeDescriptor.ForSystemType(typeof(TEntity));

            config.Metadata.TypeDescriptors.Add(typeMetadata);
        }