コード例 #1
0
        public static FieldFormat createTableField(string name, TableFormat format)
        {
            var ff = (DataTableFieldFormat)FieldFormat.create(name, FieldFormat.DATATABLE_FIELD);

            ff.setDefault(new DataTable(format, true));
            return(ff);
        }
コード例 #2
0
ファイル: DataRecord.cs プロジェクト: AlexBurmatov/AggAgent
        public Object getValue(FieldFormat ff)
        {
            if (data.ContainsKey(ff.getName()))
            {
                return(data[ff.getName()]);
            }

            return(ff.isDefaultOverride() ? null : ff.getDefaultValueCopy());
        }
コード例 #3
0
        public static FieldFormat create(string name, char type, string description, object defaultValue, bool nullable, string group)
        {
            FieldFormat ff = create(name, type, description);

            ff.setNullable(nullable);
            ff.setDefault(defaultValue);
            //ff.setGroup(group);
            return(ff);
        }
コード例 #4
0
ファイル: DataRecord.cs プロジェクト: AlexBurmatov/AggAgent
        public Object getValue(int index)
        {
            FieldFormat ff = format.getFieldFormat(index);

            if (data.ContainsKey(ff.getName()))
            {
                return(data[ff.getName()]);
            }

            return(ff.getDefaultValueCopy());
        }
コード例 #5
0
ファイル: DataRecord.cs プロジェクト: AlexBurmatov/AggAgent
        public StringBuilder encode(StringBuilder sb, ClassicEncodingSettings settings, Boolean isTransferEncode, int encodeLevel)
        {
            if (getId() != null)
            {
                new Element(ELEMENT_ID, getId()).encode(sb, settings, isTransferEncode, encodeLevel);
            }

            for (int i = 0; i < format.getFieldCount(); i++)
            {
                FieldFormat ff = format.getField(i);

                Object value = getValue(ff);

                new Element(null, ff, value).encode(sb, settings, isTransferEncode, encodeLevel);
            }

            return(sb);
        }
コード例 #6
0
ファイル: DataRecord.cs プロジェクト: AlexBurmatov/AggAgent
        private DataRecord setValue(int index, Object value, Boolean validate)
        {
            FieldFormat ff = getFormat().getFieldFormat(index);

            try
            {
                ff.checkAndConvertValue(value, validate);
            }
            catch (ValidationException ex)
            {
                throw new ArgumentException(
                          string.Format(Cres.get().getString("dtIllegalFieldValue"), value, ff) + ex.Message, ex);
            }

            Object oldValue = null;

            if (data.ContainsKey(ff.getName()))
            {
                oldValue = data[ff.getName()];
            }

            try
            {
                data[ff.getName()] = value;
                if (table != null)
                {
                    table.validateRecord(this);
                }
            }
            catch (ValidationException ex1)
            {
                data.Add(ff.getName(), oldValue);
                throw new ArgumentException(ex1.Message, ex1);
            }

            return(this);
        }
コード例 #7
0
        public string extendMessage(FieldFormat other)
        {
            if (!this.getName().Equals(other.getName()))
            {
                return("Wrong name: need " + this.getName() + ", found " + other.getName());
            }
            if (!Util.equals(this.getDescription(), other.getDescription()))
            {
                return("Wrong description: need " + this.getDescription() + ", found " + other.getDescription());
            }
            if (!Util.equals(this.getHelp(), other.getHelp()))
            {
                return("Wrong help: need " + this.getHelp() + ", found " + other.getHelp());
            }
            if (this.getType() != other.getType())
            {
                return("Wrong type: need " + this.getType() + ", found " + other.getType());
            }
            if (!this.isNullable() && other.isNullable())
            {
                return("Different nullable flags: need " + this.isNullable() + ", found " + other.isNullable());
            }
            if (this.isReadonly() != other.isReadonly())
            {
                return("Different readonly flags: need " + this.isReadonly() + ", found " + other.isReadonly());
            }
            if (this.isHidden() != other.isHidden())
            {
                return("Different hidden flags: need " + this.isHidden() + ", found " + other.isHidden());
            }

            if (!isExtendableSelectionValues() || !other.isExtendableSelectionValues())
            {
                bool selectionValuesOk = other.getSelectionValues() == null || Util.equals(getSelectionValues(), other.getSelectionValues());
                if (!selectionValuesOk && getSelectionValues() != null)
                {
                    bool foundMissingValues = false;
                    foreach (var value in getSelectionValues().Keys)
                    {
                        if (!other.getSelectionValues().ContainsKey(value))
                        {
                            foundMissingValues = true;
                        }
                    }
                    if (!foundMissingValues)
                    {
                        selectionValuesOk = true;
                    }
                }

                if (!selectionValuesOk)
                {
                    return("Different selection values: need " + other.getSelectionValues() + ", found " + getSelectionValues());
                }
            }

            if (!Util.equals(this.getEditor(), other.getEditor()))
            {
                return("Different editor: need " + this.getEditor() + ", found " + other.getEditor());
            }
            if (!Util.equals(this.getEditorOptions(), other.getEditorOptions()))
            {
                return("Different editor options: need " + this.getEditorOptions() + ", found " + other.getEditorOptions());
            }
            if (!Util.equals(getIcon(), other.getIcon()))
            {
                return("Wrong icon: need " + getIcon() + ", found " + other.getIcon());
            }
            //if (!Util.equals(getGroup(), other.getGroup()))
            //{
            //    return "Wrong group: need " + getGroup() + ", found " + other.getGroup();
            //}

            List <FieldValidator> otherValidators = other.getValidators();

            foreach (var otherValidator in otherValidators)
            {
                if (!this.getValidators().Contains(otherValidator))
                {
                    return("Different validators: need " + this.getValidators() + ", found " + other.getValidators());
                }
            }

            if (this.getDefaultValue() != null && (this.getDefaultValue() is DataTable) && (other.getDefaultValue() != null) && (other.getDefaultValue() is DataTable))
            {
                DataTable my      = this.getDefaultValue() as DataTable;
                DataTable another = other.getDefaultValue() as DataTable;
                string    msg     = my.getFormat().extendMessage(another.getFormat());
                if (msg != null)
                {
                    return("Field format doesn't match: " + msg);
                }
            }
            return(null);
        }
コード例 #8
0
 public bool extend(FieldFormat other)
 {
     return(this.extendMessage(other) == null);
 }