Namespace: Dapfor.Net.FormatsAssembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)
Syntax
C# |
---|
public FormatAttribute(
Type formatType
) |
Visual Basic |
---|
Public Sub New (
formatType As Type
) |
Visual C++ |
---|
public:
FormatAttribute(
Type^ formatType
) |
F# |
---|
new :
formatType : Type -> FormatAttribute |
Parameters
- formatType
- Type: System..::..Type
Type of the format.
Examples
| Copy |
---|
public class File
{
private long size;
[Format(typeof(SizeCustomFormat))]
public long Size
{
get { return size; }
set { size = value; }
}
}
public class SizeCustomFormat : IFormat
{
public string Format(IDataField dataField)
{
decimal value = Convert.ToDecimal(dataField.Value);
value = Decimal.Ceiling(value/1024);
return value != 0 ? string.Format("{0:n0} Ko", value) : string.Empty;
}
public bool CanParse(string text, IDataField dataField)
{
return false;
}
public void Parse(string text, IDataField dataField)
{
}
public object Clone()
{
return new SizeCustomFormat();
}
} |
See Also