Example #1
0
        internal virtual void Initialize(ContentMetadataProvider contentMetadata, IModelBinding modelBinding)
        {
            ContentMetadata   = contentMetadata;
            this.modelBinding = modelBinding;

            Type = GetType().Name;
            if (Type.EndsWith(TypeValueSuffiks))
            {
                Type = Type.Substring(0, Type.Length - TypeValueSuffiks.Length);
            }

            if (Name == null)
            {
                Name = this.modelBinding.Name;
            }
            if (Title == null)
            {
                Title = Name;
            }

            JsonPropertyName = Name.Substring(0, 1).ToLower() + Name.Substring(1);

            var valueType = this.modelBinding.ValueType;

            if (valueType.IsNullable())
            {
                AllowNull = true;
                valueType = valueType.GenericTypeArguments[0];
            }
            else if (valueType == typeof(string))
            {
                AllowNull = true;
            }
            else if (!valueType.IsValueType)
            {
                AllowNull = true;
            }

            ValueType = valueType;

            OnInitialize();
        }
Example #2
0
 /// <summary>
 /// A part specification is a collection of key:value pairs where the keys are
 ///
 /// The core lowkode components are place-holders for UI parts that are created at runtime.
 /// A placeholder component gives the UI engine a 'specification' of the part that it needs and
 /// the engine returns a part that fulfills the specification.
 ///
 /// The specification
 ///
 /// The most basic parts of a specification are...
 ///
 /// - The view model.  What kind of object does the part display?
 ///
 ///     The ModelType property denotes the kind of object displayed by the part
 ///
 /// - What kind of UI elememnt is needed?
 ///
 ///     User interface elements usually fall into one of the following four categories:
 ///     - Input Controls
 ///     - Navigation Components
 ///     - Informational Components
 ///     - Containers
 ///
 ///     The ElementType property denotes the element type.
 ///
 ///
 ///     The same object can be displayed many different ways.
 ///     For instance, a Cusomter can be displayed in a grid, in a form, in a card.
 ///     Each display is different.
 ///     A lowkode component type demotes the kind of part needed.
 ///     For instance, <DisplayTable> denotes a grid-like component, a <Card> denotes an abbreviated, non-editable view of an object, etc.
 /// </summary>
 /// <param name="componentType"></param>
 /// <param name="modelType"></param>
 public PartSpecification(PlaceholderComponent placeholderComponent, IModelBinding modelBinding)
 {
     this.PlaceholderComponent = placeholderComponent;
     this.ModelBinding         = modelBinding;
 }