Ejemplo n.º 1
0
    public int GetDataIndexInDatabase()
    {
        DatabaseReferenceAttribute databaseItemAttribute = GetDatabaseReferenceAttribute();

        if (databaseItemAttribute == null)
        {
            return(-1);
        }
        return(databaseItemAttribute.GetIndexInDatabase(DatabaseID));
    }
Ejemplo n.º 2
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);
    }
Ejemplo n.º 3
0
    protected void SetDatabaseID(string newID)
    {
        DatabaseReferenceAttribute databaseReference = GetDatabaseReferenceAttribute();

        if (databaseReference == null || databaseReference.GetIndexInDatabase(newID) == -1)
        {
            newID = null;
        }

        if (DatabaseID != newID)
        {
            DatabaseID = newID;
            onSetDatabaseID?.Invoke(this);
        }
    }
Ejemplo n.º 4
0
    public bool SetInputFromDatabase(string dataID)
    {
        DatabaseReferenceAttribute databaseReference = GetDatabaseReferenceAttribute();

        if (databaseReference == null)
        {
            return(false);
        }
        bool getItem = databaseReference.TryGetSourceItem(dataID, out object databaseItem);

        if (getItem == true)
        {
            SetInput(databaseItem);
            return(true);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 5
0
    public virtual bool SetInputFromDatabase(int indexInDatabase)
    {
        if (indexInDatabase < 0)
        {
            return(false);
        }
        DatabaseReferenceAttribute databaseReference = GetDatabaseReferenceAttribute();

        if (databaseReference == null)
        {
            return(false);
        }
        bool getItem = databaseReference.TryGetSourceItem(indexInDatabase, out object item);

        if (getItem == true)
        {
            SetInput(item);
            return(true);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 6
0
 public virtual object ApplyField(object fieldValue, out bool changeCheck)
 {
     SetDatabaseID(DatabaseReferenceAttribute.GetItemID(fieldValue));
     changeCheck = true;
     return(fieldValue);
 }
Ejemplo n.º 7
0
 public virtual void SetInput(object input)
 {
     SetDatabaseID(DatabaseReferenceAttribute.GetItemID(input));
 }