Esempio n. 1
0
        public object ValueFromXStr(DataSession session, string xStr)
        {
            if (StrUtils.IsNullOrEmpty(xStr) || xStr == "{{null}}")
            {
                return((object)null);
            }
            if (this.IsLink)
            {
                if (this.Association.Refs.Count > 1)
                {
                    throw new MetadataException("Невозможно получить связанный объект по идентификатору: для ассоциации определено более одного варианта связи.");
                }
                return((object)session[this.Association.Refs[0].RefClass][new DataId(xStr)]);
            }
            switch (this.DataType & DataType.BaseMask)
            {
            case DataType.Boolean:
                return((object)XStrUtils.ToBool(xStr, false));

            case DataType.Integer:
                return((object)XStrUtils.ToInt(xStr, 0));

            case DataType.Float:
                return((object)XStrUtils.ToDouble(xStr, 0.0));

            case DataType.Currency:
                return((object)XStrUtils.ToCurrency(xStr, 0M));

            case DataType.DateTime:
                return((object)XStrUtils.ToDateTime(xStr, DateTime.MinValue));

            case DataType.Binary:
                return((object)Convert.FromBase64String(xStr));

            default:
                return((object)XStrUtils.ToString(xStr, string.Empty));
            }
        }
 public object XStrToDbl(string xStr) => xStr == this.XStrNULL ? (object)DBNull.Value : (object)XStrUtils.ToDouble(xStr, 0.0);