Exemplo n.º 1
0
    public static UIField NewField(FieldInfo info, int arrayLevel, bool makeReadOnly)
    {
        if (info == null)
        {
            return(null);
        }
        Type fieldType = GetElementType(info.FieldType, arrayLevel);

        if (fieldType == null)
        {
            return(null);
        }
        UIField newField;
        bool    isArray = fieldType.IsArray;
        DatabaseReferenceAttribute databaseReference = GetDatabaseReferenceAttribute(info);

        if (databaseReference != null)
        {
            fieldType = databaseReference.dataType;
        }

        if (isArray == false)
        {
            InputType inputType = GetInputType(fieldType);
            switch (inputType)
            {
            case InputType.Value: newField = new UIValueField(); break;

            case InputType.Data: newField = new UIDataPackField(); break;

            default: return(null);
            }
        }
        else
        {
            Type      arrayType = isArray ? fieldType.GetElementType() : null;
            InputType inputType = GetInputType(arrayType);
            switch (inputType)
            {
            case InputType.Value: newField = new UIValueArrayField(); break;

            case InputType.Data: newField = new UIDataPackArrayField(); break;

            default: return(null);
            }
        }

        newField.Info       = info;
        newField.ArrayLevel = arrayLevel;
        newField.label      = UITranslator.TranslateCurrent(info.Name);
        newField.DatabaseID = null;
        newField.ReadOnly   = makeReadOnly;// || databaseReference != null;
        return(newField);
    }
    public override void UpdateInputComponent()
    {
        if (CurrentField == null || CurrentField is UIDataPackField == false)
        {
            return;
        }
        UIDataPackField dataPackField = CurrentField as UIDataPackField;

        if (textComponent != null)
        {
            if (dataPackField.InputCard == null)
            {
                textComponent.text = dataPackField.dataInput != null ? dataPackField.dataInput.DisplayName : "";
            }
            else
            {
                textComponent.text = "...";
            }
        }
        UpdateButtonColor();
    }