コード例 #1
0
        internal DataTypeInfo ResolveDataType(FluidityEditorFieldConfig fieldConfig, bool isReadOnly = false)
        {
            var dtdKey = !fieldConfig.DataTypeName.IsNullOrWhiteSpace()
                ? fieldConfig.DataTypeName
                : fieldConfig.GetOrCalculateDefinititionId().ToString();

            dtdKey += $"_{isReadOnly}";

            return(_cacheProvider.GetCacheItem <DataTypeInfo>($"fluidity_datatypeinfo_{dtdKey}", () =>
            {
                IDataTypeDefinition dataTypeDefinition = null;

                if (!fieldConfig.DataTypeName.IsNullOrWhiteSpace())
                {
                    dataTypeDefinition = _dataTypeService.GetDataTypeDefinitionByName(fieldConfig.DataTypeName);
                }

                if (dataTypeDefinition == null)
                {
                    var dataTypeId = fieldConfig.DataTypeId == 0 && isReadOnly
                        ? -92 // If readonly and no explicit datatype defined, default to label
                        : fieldConfig.GetOrCalculateDefinititionId();
                    dataTypeDefinition = _dataTypeService.GetDataTypeDefinitionById(dataTypeId);
                }

                var preValues = _dataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id);
                var propEditor = _propertyEditorResolver.GetByAlias(dataTypeDefinition.PropertyEditorAlias);

                return new DataTypeInfo(dataTypeDefinition, propEditor, preValues);
            }));
        }
コード例 #2
0
        internal DataTypeInfo ResolveDataType(FluidityEditorFieldConfig fieldConfig)
        {
            var dtdKey = !fieldConfig.DataTypeName.IsNullOrWhiteSpace()
                ? fieldConfig.DataTypeName
                : fieldConfig.GetOrCalculateDefinititionId().ToString();

            return(_cacheProvider.GetCacheItem <DataTypeInfo>($"fluidity_datatypeinfo_{dtdKey}", () =>
            {
                IDataTypeDefinition dataTypeDefinition = null;

                if (!fieldConfig.DataTypeName.IsNullOrWhiteSpace())
                {
                    dataTypeDefinition = _dataTypeService.GetDataTypeDefinitionByName(fieldConfig.DataTypeName);
                }

                if (dataTypeDefinition == null)
                {
                    var dataTypeId = fieldConfig.GetOrCalculateDefinititionId();
                    dataTypeDefinition = _dataTypeService.GetDataTypeDefinitionById(dataTypeId);
                }

                var preValues = _dataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id);
                var propEditor = _propertyEditorResolver.GetByAlias(dataTypeDefinition.PropertyEditorAlias);

                return new DataTypeInfo(dataTypeDefinition, propEditor, preValues);
            }));
        }