using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using FastReport.Utils;
namespace FastReport.Format
{
///
/// Base class for all formats.
///
///
/// The format is used to format expression value in a object.
///
[TypeConverter(typeof(FastReport.TypeConverters.FormatConverter))]
public abstract class FormatBase : IFRSerializable
{
#region Properties
///
/// Gets the short format name (e.g. without a "Format" suffix).
///
[Browsable(false)]
public string Name
{
get { return GetType().Name.Replace("Format", ""); }
}
#endregion
#region Public Methods
///
/// Creates exact copy of this format.
///
/// The copy of this format.
public abstract FormatBase Clone();
///
/// Formats the specified value.
///
/// The value to format.
/// The string that represents the formatted value.
public abstract string FormatValue(object value);
internal abstract string GetSampleValue();
internal virtual void Serialize(FRWriter writer, string prefix, FormatBase format)
{
if (format.GetType() != GetType())
writer.WriteStr("Format", Name);
}
///
public void Serialize(FRWriter writer)
{
writer.ItemName = GetType().Name;
Serialize(writer, "", writer.DiffObject as FormatBase);
}
///
public void Deserialize(FRReader reader)
{
reader.ReadProperties(this);
}
#endregion
}
}