-
Notifications
You must be signed in to change notification settings - Fork 578
/
DataComponentBase.cs
136 lines (125 loc) · 3.98 KB
/
DataComponentBase.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using FastReport.Utils;
namespace FastReport.Data
{
/// <summary>
/// The base class for all data components such as data sources, columns.
/// </summary>
public partial class DataComponentBase : Base
{
#region Fields
private string alias;
private bool enabled;
private string referenceName;
private object reference;
#endregion
#region Properties
/// <summary>
/// Gets or sets alias of this object.
/// </summary>
/// <remarks>
/// Alias is a human-friendly name of this object. It may contain any symbols (including
/// spaces and national symbols).
/// </remarks>
[Category("Design")]
public new string Alias
{
get { return alias; }
set { alias = value; }
}
/// <summary>
/// Gets or sets a value indicates that object is enabled and thus can be used in a report.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
[Browsable(false)]
public virtual bool Enabled
{
get { return enabled; }
set { enabled = value; }
}
/// <summary>
/// Gets or sets a name of the data object.
/// </summary>
/// <remarks>
/// This property is used to support FastReport.Net infrastructure. Do not use it directly.
/// </remarks>
[Browsable(false)]
public string ReferenceName
{
get { return referenceName; }
set { referenceName = value; }
}
/// <summary>
/// Gets or sets a reference to the data object.
/// </summary>
/// <remarks>
/// This property is used to support FastReport.Net infrastructure. Do not use it directly.
/// </remarks>
[Browsable(false)]
public object Reference
{
get { return reference; }
set { reference = value; }
}
/// <summary>
/// Gets a value indicates that this object has an alias.
/// </summary>
[Browsable(false)]
public bool IsAliased
{
get { return Name != Alias; }
}
#endregion
#region Public Methods
/// <inheritdoc/>
public override void Assign(Base source)
{
BaseAssign(source);
}
/// <inheritdoc/>
public override void SetName(string value)
{
bool changeAlias = String.IsNullOrEmpty(Alias) || String.Compare(Alias, Name, true) == 0;
base.SetName(value);
if (changeAlias)
Alias = Name;
}
/// <inheritdoc/>
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);
}
/// <summary>
/// Initializes the object before running a report.
/// </summary>
/// <remarks>
/// This method is used by the report engine, do not call it directly.
/// </remarks>
public virtual void InitializeComponent()
{
}
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="DataComponentBase"/> class with default settings.
/// </summary>
public DataComponentBase()
{
Alias = "";
ReferenceName = "";
Enabled = true;
SetFlags(Flags.CanEdit | Flags.CanCopy, false);
}
}
}