using System; using System.Collections.Generic; using System.Text; using System.ComponentModel; using FastReport.Utils; namespace FastReport.Data { /// /// The base class for all data components such as data sources, columns. /// public partial class DataComponentBase : Base { #region Fields private string alias; private bool enabled; private string referenceName; private object reference; #endregion #region Properties /// /// Gets or sets alias of this object. /// /// /// Alias is a human-friendly name of this object. It may contain any symbols (including /// spaces and national symbols). /// [Category("Design")] public new string Alias { get { return alias; } set { alias = value; } } /// /// Gets or sets a value indicates that object is enabled and thus can be used in a report. /// /// /// This property is used to hide an object from the Data Dictionary window. Hidden /// objects are still accessible in the "Data|Choose Data Source..." menu. /// [Browsable(false)] public bool Enabled { get { return enabled; } set { enabled = value; } } /// /// Gets or sets a name of the data object. /// /// /// This property is used to support FastReport.Net infrastructure. Do not use it directly. /// [Browsable(false)] public string ReferenceName { get { return referenceName; } set { referenceName = value; } } /// /// Gets or sets a reference to the data object. /// /// /// This property is used to support FastReport.Net infrastructure. Do not use it directly. /// [Browsable(false)] public object Reference { get { return reference; } set { reference = value; } } /// /// Gets a value indicates that this object has an alias. /// [Browsable(false)] public bool IsAliased { get { return Name != Alias; } } #endregion #region Public Methods /// public override void Assign(Base source) { BaseAssign(source); } /// public override void SetName(string value) { bool changeAlias = String.IsNullOrEmpty(Alias) || String.Compare(Alias, Name, true) == 0; base.SetName(value); if (changeAlias) Alias = Name; } /// public override void Serialize(FRWriter writer) { base.Serialize(writer); if (IsAliased) writer.WriteStr("Alias", Alias); if (!Enabled) writer.WriteBool("Enabled", Enabled); if (!String.IsNullOrEmpty(ReferenceName)) writer.WriteStr("ReferenceName", ReferenceName); } /// /// Initializes the object before running a report. /// /// /// This method is used by the report engine, do not call it directly. /// public virtual void InitializeComponent() { } #endregion /// /// Initializes a new instance of the class with default settings. /// public DataComponentBase() { Alias = ""; ReferenceName = ""; Enabled = true; SetFlags(Flags.CanEdit | Flags.CanCopy, false); } } }