コード例 #1
0
ファイル: Utility.cs プロジェクト: BrettMahon/BladeRazor
        // this is old
        public static string GetFormattedValue(ModelExplorer explorer, DataTypeAttribute dta, bool renderHtml)
        {
            HtmlContentBuilder content = new HtmlContentBuilder();

            if (explorer.Model == null)
            {
                return(string.Empty);
            }

            var value = explorer.Model.ToString();

            content.SetContent(value);

            if (dta == null)
            {
                return(value);
            }

            //TODO: Implement DataTypes as and when these are required
            value = dta.DataType switch
            {
                DataType.Custom => value,
                DataType.DateTime => FormatDateTime(explorer, dta, value),
                DataType.Date => FormatDateTime(explorer, dta, value),
                DataType.Time => FormatDateTime(explorer, dta, value),
                DataType.Duration => value,
                DataType.PhoneNumber => value,
                DataType.Currency => value,
                DataType.Text => value,
                DataType.Html => value,
                DataType.MultilineText => value,
                DataType.EmailAddress => value,
                DataType.Password => value,
                DataType.Url => value,
                DataType.ImageUrl => value,
                DataType.CreditCard => value,
                DataType.PostalCode => value,
                DataType.Upload => value,
                _ => value
            };
            content.SetContent(value);
            return(value);
        }