Skip to content

Commit a1da1df

Browse files
committed
DaJet Type System 1.0.8
Added array support
1 parent fa4908b commit a1da1df

8 files changed

Lines changed: 450 additions & 398 deletions

File tree

src/dajet-data/dajet-data.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<AssemblyName>DaJet.Data</AssemblyName>
99
<Title>DaJet Data Providers</Title>
1010
<Authors>Zhichkin</Authors>
11-
<Version>2.0.1</Version>
11+
<Version>2.0.2</Version>
1212
<Copyright>Zhichkin © 2025</Copyright>
1313
<Description>DaJet database providers core library</Description>
1414
<PackageProjectUrl>https://zhichkin.github.io/</PackageProjectUrl>
@@ -17,7 +17,7 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="Microsoft.Data.SqlClient" Version="7.0.1" />
20+
<PackageReference Include="Microsoft.Data.SqlClient" Version="7.0.2" />
2121
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.9" />
2222
<PackageReference Include="Npgsql" Version="10.0.3" />
2323
</ItemGroup>

src/dajet-metadata/dajet-metadata.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>disable</Nullable>
88
<AssemblyName>DaJet.Metadata</AssemblyName>
9-
<Version>5.0.19</Version>
9+
<Version>5.0.20</Version>
1010
<Authors>Zhichkin</Authors>
1111
<Description>Library to read 1C:Enterprise 8 metadata from Microsoft SQL Server or PostgreSQL databases.</Description>
1212
<Copyright>Zhichkin © 2020</Copyright>
Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,79 @@
1-
namespace DaJet.TypeSystem
1+
using System.Collections;
2+
using System.Dynamic;
3+
4+
namespace DaJet.TypeSystem
25
{
3-
/// <summary>
4-
/// Универсальный объект представления данных, имеющий произвольное количество свойств, создаваемых или удаляемых программно.
5-
/// Экземпляры данного класса предназначены для представления данных запросов, объектов конфигураций баз данных, а также
6-
/// любых иных динамически изменяемых структур данных и переноса этих данных между программными компонентами.
7-
/// </summary>
8-
public sealed class DataObject : Dictionary<string, object>
6+
public sealed class DataObject : DynamicObject, IEnumerable<KeyValuePair<string, object>>
97
{
10-
public DataObject() : base() { }
11-
public DataObject(int capacity) : base(capacity) { }
12-
/// <summary>
13-
/// Replaces an existing property value or adds a new
14-
/// property to the object using the provided value.
15-
/// </summary>
8+
private readonly Dictionary<string, object> _data;
9+
public DataObject()
10+
{
11+
_data = new Dictionary<string, object>();
12+
}
13+
public DataObject(int capacity)
14+
{
15+
_data = new Dictionary<string, object>(capacity);
16+
}
17+
public DataObject(Dictionary<string, object> data)
18+
{
19+
_data = data is not null ? data : new Dictionary<string, object>();
20+
}
21+
public bool IsEmpty { get { return _data.Count == 0; } }
1622
public void SetValue(string name, object value)
1723
{
18-
if (!TryAdd(name, value))
24+
if (!_data.TryAdd(name, value))
1925
{
20-
this[name] = value;
26+
_data[name] = value;
2127
}
2228
}
29+
public bool TrySetValue(string name, object value)
30+
{
31+
if (!_data.ContainsKey(name))
32+
{
33+
return false;
34+
}
35+
36+
_data[name] = value;
37+
38+
return true;
39+
}
40+
public object GetValue(string name)
41+
{
42+
return _data[name];
43+
}
44+
public bool TryGetValue(string name, out object value)
45+
{
46+
return _data.TryGetValue(name, out value);
47+
}
48+
public void Clear()
49+
{
50+
_data.Clear();
51+
}
52+
53+
#region "IENUMERABLE IMPLEMENTATION"
54+
IEnumerator IEnumerable.GetEnumerator()
55+
{
56+
return GetEnumerator();
57+
}
58+
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
59+
{
60+
return _data.GetEnumerator();
61+
}
62+
#endregion
63+
64+
#region "DYNAMIC OBJECT IMPLEMENTATION"
65+
public override IEnumerable<string> GetDynamicMemberNames()
66+
{
67+
return _data.Keys;
68+
}
69+
public override bool TrySetMember(SetMemberBinder binder, object value)
70+
{
71+
return TrySetValue(binder.Name, value);
72+
}
73+
public override bool TryGetMember(GetMemberBinder binder, out object value)
74+
{
75+
return _data.TryGetValue(binder.Name, out value);
76+
}
77+
#endregion
2378
}
2479
}

src/dajet-type-system/Union.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public abstract class Union
3030
public abstract object Value { get; }
3131
public abstract Union Copy();
3232
public abstract bool GetBoolean();
33-
public abstract decimal GetNumeric();
33+
public abstract decimal GetDecimal();
3434
public abstract DateTime GetDateTime();
3535
public abstract string GetString();
3636
public abstract Entity GetEntity();
@@ -52,7 +52,7 @@ public override bool GetBoolean()
5252
{
5353
throw new BadUnionAccessException(typeof(bool), typeof(CaseUndefined));
5454
}
55-
public override decimal GetNumeric()
55+
public override decimal GetDecimal()
5656
{
5757
throw new BadUnionAccessException(typeof(decimal), typeof(CaseUndefined));
5858
}
@@ -79,7 +79,7 @@ public override bool GetBoolean()
7979
{
8080
return _value;
8181
}
82-
public override decimal GetNumeric()
82+
public override decimal GetDecimal()
8383
{
8484
throw new BadUnionAccessException(typeof(decimal), typeof(CaseBoolean));
8585
}
@@ -106,7 +106,7 @@ public override bool GetBoolean()
106106
{
107107
throw new BadUnionAccessException(typeof(bool), typeof(CaseDecimal));
108108
}
109-
public override decimal GetNumeric()
109+
public override decimal GetDecimal()
110110
{
111111
return _value;
112112
}
@@ -133,7 +133,7 @@ public override bool GetBoolean()
133133
{
134134
throw new BadUnionAccessException(typeof(bool), typeof(CaseDateTime));
135135
}
136-
public override decimal GetNumeric()
136+
public override decimal GetDecimal()
137137
{
138138
throw new BadUnionAccessException(typeof(decimal), typeof(CaseDateTime));
139139
}
@@ -160,7 +160,7 @@ public override bool GetBoolean()
160160
{
161161
throw new BadUnionAccessException(typeof(bool), typeof(CaseString));
162162
}
163-
public override decimal GetNumeric()
163+
public override decimal GetDecimal()
164164
{
165165
throw new BadUnionAccessException(typeof(decimal), typeof(CaseString));
166166
}
@@ -187,7 +187,7 @@ public override bool GetBoolean()
187187
{
188188
throw new BadUnionAccessException(typeof(bool), typeof(CaseEntity));
189189
}
190-
public override decimal GetNumeric()
190+
public override decimal GetDecimal()
191191
{
192192
throw new BadUnionAccessException(typeof(decimal), typeof(CaseEntity));
193193
}

src/dajet-type-system/dajet-type-system.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageProjectUrl>https://zhichkin.github.io/</PackageProjectUrl>
1111
<Description>DaJet type system core library</Description>
1212
<Title>DaJet Type System</Title>
13-
<Version>1.0.7</Version>
13+
<Version>1.0.8</Version>
1414
<Authors>Zhichkin</Authors>
1515
<RepositoryUrl>https://github.com/zhichkin/dajet-metadata</RepositoryUrl>
1616
<PackageLicenseExpression>MIT</PackageLicenseExpression>

0 commit comments

Comments
 (0)