24 namespace Deveel.Data.Sql {
42 [DebuggerDisplay(
"{FullName}")]
49 public const string GlobName =
"*";
54 public const char Separator =
'.';
84 if (String.IsNullOrEmpty(name))
85 throw new ArgumentNullException(
"name");
101 public string ParentName {
102 get {
return Parent == null ? null : Parent.
FullName; }
108 public string Name {
get;
private set; }
114 public string FullName {
115 get {
return ToString(); }
122 get {
return Name.Equals(GlobName); }
140 if (String.IsNullOrEmpty(s))
141 throw new ArgumentNullException(
"s");
143 var sp = s.Split(
new[] {
'.'}, StringSplitOptions.RemoveEmptyEntries);
145 throw new FormatException(
"At least one part of the name must be provided");
151 for (
int i = 0; i < sp.Length; i++) {
152 if (finalName == null) {
173 var sb =
new StringBuilder();
174 if (!String.IsNullOrEmpty(schemaName))
175 sb.Append(schemaName).Append(
'.');
178 return Parse(sb.ToString());
196 while (parent != null) {
201 baseName = baseName.
Child(childName.
Name);
217 v = Parent.CompareTo(other.
Parent);
220 v = String.Compare(Name, other.
Name, StringComparison.Ordinal);
226 var sb =
new StringBuilder();
227 if (Parent != null) {
233 return sb.ToString();
241 public override bool Equals(
object obj) {
246 return Equals(other);
250 return Equals(other,
true);
267 if (Parent != null && other.
Parent == null)
269 if (Parent == null && other.
Parent != null)
272 if (Parent != null && !Parent.Equals(other.
Parent, ignoreCase))
275 var comparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
276 return String.Equals(Name, other.
Name, comparison);
280 var code = Name.GetHashCode() ^ 5623;
282 code ^= Parent.GetHashCode();
288 using (var writer =
new BinaryWriter(stream, Encoding.Unicode)) {
289 Serialize(objectName, writer);
294 if (objectName == null) {
295 writer.Write((byte) 0);
299 writer.Write((byte)1);
301 if (objectName.
Parent != null) {
302 writer.Write((byte) 1);
303 Serialize(objectName.
Parent, writer);
305 writer.Write((byte)0);
308 writer.Write(objectName.
Name);
312 using (var reader =
new BinaryReader(stream, Encoding.Unicode)) {
313 return Deserialize(reader);
318 var status = reader.ReadByte();
324 var parentStatus = reader.ReadByte();
325 if (parentStatus == 1)
326 parent = Deserialize(reader);
328 var name = reader.ReadString();
void GetData(SerializeData data)
static ObjectName Parse(string s)
Parses the given string into a ObjectName object.
override string ToString()
ObjectName(ObjectData graph)
static void Serialize(ObjectName objectName, BinaryWriter writer)
ObjectName Child(ObjectName childName)
static void Serialize(ObjectName objectName, Stream stream)
int CompareTo(ObjectName other)
Compares this instance of the object reference to a given one and returns a value indicating if the t...
ObjectName(string name)
Constructs a name reference without a parent.
void SetValue(string key, Type type, object value)
Describes the name of an object within a database.
static ObjectName Deserialize(Stream stream)
ObjectName Child(string name)
Creates a reference what is the child of the current one.
override bool Equals(object obj)
override int GetHashCode()
string FullName
Gets the full reference name formatted.
static ObjectName ResolveSchema(string schemaName, string name)
Creates a new reference to a table, given a schema and a table name.
ObjectName Parent
Gets the parent reference of the current one, if any or null if none.
string Name
Gets the name of the object being referenced.
static ObjectName Deserialize(BinaryReader reader)
object GetValue(string key)
ObjectName(ObjectName parent, string name)
Constructs a name reference with a given parent.
bool Equals(ObjectName other)
bool Equals(ObjectName other, bool ignoreCase)
Compares this object name with the other one given, according to the case sensitivity specified...
string GetString(string key)