Skip to content

Commit 77be447

Browse files
committed
Migrating to .NET Standard 2.0
1 parent ecbc1db commit 77be447

File tree

2 files changed

+197
-1
lines changed

2 files changed

+197
-1
lines changed

DataCommander.Providers/AboutForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public AboutForm()
3131
<a href=""https://github.com/csbernath/DataCommander"">Data Commander</a>
3232
<br/>
3333
<br/>
34-
Including <a href=""https://github.com/csbernath/DataCommander/blob/master/Foundation/README.md"">Foundation Class Library</a>
34+
Including <a href=""https://github.com/csbernath/DataCommander/blob/master/Foundation.NetStandard-2.0/README.md"">Foundation (.NET Standard 2.0) Class Library</a>
3535
<br/>
3636
<br/>
3737
Build date: {lastWriteTime.ToString("yyyy-MM-dd")}
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
#Foundation Class Library
2+
3+
##Collections
4+
5+
###How to create memory indexes for dynamic (not read only) collections
6+
7+
Input: a collection
8+
9+
Output: an indexable collection which follows add/remove operations in the indexes
10+
11+
See [```IndexableCollection<T>```](Collections/IndexableCollection/IndexableCollection-1.cs).
12+
13+
|Index class|Class implementing the index|Unique|Sorted|Enumerable|T this[int index]|
14+
|-----------|----------------------------|------|------|----------|-----------------|
15+
|[```LinkedListIndex<T>```](Collections/IndexableCollection/LinkedListIndex.cs)|LinkedList<T>|false|false|true|false|
16+
|[```ListIndex<T>```](Collections/IndexableCollection/LinkedListIndex.cs)|[```IList<T>```](https://msdn.microsoft.com/en-us/library/5y536ey6(v=vs.110).aspx)|false|false|true|true|
17+
|[```NonUniqueIndex<TKey,T>```](Collections/IndexableCollection/NonUniqueIndex.cs)|IDictionary<TKey, ICollection<T>>|false|true/false|false|false|
18+
|[```SequenceIndex```](Collections/IndexableCollection/SequenceIndex.cs)|[```IDictionary<TKey,TValue>```](https://msdn.microsoft.com/en-us/library/s4ys34ea(v=vs.110).aspx)|true|true/false|false|false|
19+
|[```UniqueIndex<TKey,T>```](Collections/IndexableCollection/UniqueIndex.cs)|Dictionary<>|false|false|false|false|
20+
|```UniqueIndex<TKey,T>```|SortedDictionary<>|false|true|false|false|
21+
|[```UniqueListIndex<T>```](Collections/IndexableCollection/UniqueListIndex.cs)|[```IList<T>```](https://msdn.microsoft.com/en-us/library/5y536ey6(v=vs.110).aspx)|true|true/false|true|false|
22+
23+
###How to create memory indexes for static (read only) collections
24+
25+
Input: an enumerable item collection (sorted/not sorted, unique/not unique)
26+
27+
Output: a read only index of the input by a key
28+
29+
|Unique|Sorted|Create index method|Class implementing the index|
30+
|------|------|-------------------|----------------------------|
31+
|true|false|[`ToDictionary`](https://msdn.microsoft.com/en-us/library/system.linq.enumerable.todictionary(v=vs.110).aspx) |[`Dictionary<TKey,TValue>`](https://msdn.microsoft.com/en-us/library/xfhwa508(v=vs.110).aspx)
32+
|false|false|[`ToLookup`](https://msdn.microsoft.com/en-us/library/system.linq.enumerable.tolookup(v=vs.110).aspx)|[`Lookup<TKey,TElement>`](https://msdn.microsoft.com/en-us/library/bb460184(v=vs.110).aspx)|
33+
|true|true|[`AsReadOnlySortedList`](Linq/IEnumerableExtensions.cs)|[`ReadOnlySortedList<TKey,TValue>`](Collections/ReadOnlySortedList.cs)|
34+
|false|true|[`AsReadOnlyNonUniqueSortedList`](Linq/IEnumerableExtensions.cs)|[`ReadOnlyNonUniqueSortedList<TKey,TValue>`](Collections/ReadOnlyNonUniqueSortedList.cs)
35+
36+
###How to create large (large object heap friendly, segmented) collections
37+
38+
SegmentedArrayBuilder - build an array of segments
39+
40+
SegmentedCollection - build a linked list of segments
41+
42+
SegmentedListBuilder - build a list of segments
43+
44+
|Method|SegmentedArrayBuilder|SegmentedCollection|SegmentedListBuilder|
45+
|------|---------------------|-------------------|--------------------|
46+
|number of items is known|yes|no|no|
47+
|Add|yes|yes|yes|
48+
|IEnumerable|no|yes|no|
49+
|ToReadOnlyList|yes|no|yes|
50+
51+
###Configuration
52+
53+
The library defines a configuration section handler.
54+
```xml
55+
<configuration>
56+
<configSections>
57+
<section name="DataCommander.Foundation.Configuration" type="DataCommander.Foundation.Configuration.SectionHandler, DataCommander.Foundation"/>
58+
</configSections>
59+
<DataCommander.Foundation.Configuration>
60+
</DataCommander.Foundation.Configuration>
61+
</configuration>
62+
```
63+
64+
The schema of the configuration section is a tree of nodes. The node can contain child nodes and attributes.
65+
66+
```xml
67+
<DataCommander.Foundation.Configuration>
68+
<node name="Node1">
69+
<attribute name="Enabled" type="bool" value="true"/>
70+
<attribute name="Path" value="%TEMP%"/>
71+
</node>
72+
<Node2>
73+
</Node2>
74+
</DataCommander.Foundation.Configuration>
75+
</configuration>
76+
```
77+
78+
Reserved xml element names: node, attribute.
79+
If the name of the xml element is not node or attribute then the type of the element is node and the name of the node is the name of the xml element.
80+
81+
####Nodes
82+
83+
```xml
84+
<node name="<name>" description="<description>">
85+
</node>
86+
```
87+
88+
- name: optional
89+
- description: optional
90+
91+
####Attributes
92+
93+
```xml
94+
<attribute name="<name>" type="<type>" isNull="<isNull>" description="<description>" value="<value>"/>
95+
```
96+
97+
- name: required
98+
- type: optional (the full type name of the .NET type)
99+
- isNull: optional (true,false)
100+
- description: optional
101+
- value: required
102+
103+
#####Array value
104+
105+
```xml
106+
<attribute name="MyArray" type="int[]">
107+
<a value="3"/>
108+
<a value="5"/>
109+
<a value="7"/>
110+
<a value="9"/>
111+
</attribute>
112+
```
113+
114+
- the name of the of the array item xml element: required, arbitrary (in this sample: 'a')
115+
- value: required (3,5,7,9)
116+
117+
#####Byte array value
118+
119+
```xml
120+
<attribute name="EncryptedPassword" type="byte[]">
121+
VGhpcyBpcyBhIHNlY3JldCBwYXNzd29yZA0KVGhpcyBpcyBhIHNlY3JldCBwYXNzd29yZA0KVGhp
122+
cyBpcyBhIHNlY3JldCBwYXNzd29yZA0KVGhpcyBpcyBhIHNlY3JldCBwYXNzd29yZA0KVGhpcyBp
123+
cyBhIHNlY3JldCBwYXNzd29yZA0KVGhpcyBpcyBhIHNlY3JldCBwYXNzd29yZA0KVGhpcyBpcyBh
124+
IHNlY3JldCBwYXNzd29yZA0KVGhpcyBpcyBhIHNlY3JldCBwYXNzd29yZA0KVGhpcyBpcyBhIHNl
125+
Y3JldCBwYXNzd29yZA0KVGhpcyBpcyBhIHNlY3JldCBwYXNzd29yZA==
126+
</attribute>
127+
```
128+
129+
####Simplified syntax
130+
131+
|Full syntax|Simplified syntax|
132+
|-----------|-----------------|
133+
|```<node name="Name1">```|```<Name1>```|
134+
|```<attribute name="Count" type="System.Int32" value="1"/>```|```<attribute name="Count" type="int" value="1"/>``` |
135+
|```<attribute name="Name1" type="string" value="Hello">```|```<attribute name="Name1" value="Hello">```|
136+
137+
C# type names:
138+
- bool
139+
- char
140+
- string
141+
- sbyte
142+
- short
143+
- int
144+
- long
145+
- byte
146+
- ushort
147+
- uint
148+
- ulong
149+
- float
150+
- double
151+
- decimal
152+
153+
Additional reserved type names:
154+
- datetime
155+
- xmlnode
156+
157+
###[IDateTimeProvider](IDateTimeProvider.cs)
158+
This is the unified abstract version of retrieving the current date and time.
159+
The concrete implementations are using the [`DateTime.Now`](https://msdn.microsoft.com/en-us/library/system.datetime.now(v=vs.110).aspx) and `DateTime.UtcNow` properties.
160+
The implementation uses the idea from [NLog's cached time source](https://github.com/NLog/NLog/blob/master/src/NLog/Time/CachedTimeSource.cs). The idea is that the Environment.TickCount is much faster then DateTime.(Utc)Now.
161+
162+
###Logging
163+
The library defines interfaces for logging:
164+
- [`ILog`](Diagnostics/Log/ILog.cs)
165+
- [`ILogFactory`](Diagnostics/Log/ILogFactory.cs)
166+
167+
The library contains an implementation of the interfaces:
168+
- [`FoundationLog`](Diagnostics/Log/FoundationLog.cs)
169+
- [`FoundationLogFactory`](Diagnostics/Log/FoundationLogFactory.cs)
170+
171+
The built-in implementation can be replaced with NLog,log4net etc. The application configuration file can be used for that.
172+
See the default configuration in Data Commander as an example:
173+
```xml
174+
<Diagnostics>
175+
<LogFactory>
176+
<attribute name="TypeName" value="DataCommander.Foundation.Diagnostics.FoundationLogFactory"/>
177+
</LogFactory>
178+
<FoundationLogFactory>
179+
<attribute name="DateTimeKind" type="System.DateTimeKind" value="Local"/>
180+
<LogWriters>
181+
<node>
182+
<attribute name="Type" value="FileLogWriter"/>
183+
<attribute name="Enabled" type="bool" value="true"/>
184+
<attribute name="LogLevel" type="DataCommander.Foundation.Diagnostics.LogLevel" value="Debug"/>
185+
<attribute name="DateTimeKind" type="System.DateTimeKind" value="Local"/>
186+
<attribute name="Path" value="%TEMP%\DataCommander[{date}]({time}) {guid}.log"/>
187+
<attribute name="Async" type="bool" value="true"/>
188+
<attribute name="FileAttributes" type="System.IO.FileAttributes" value="ReadOnly,Hidden"/>
189+
</node>
190+
</LogWriters>
191+
</FoundationLogFactory>
192+
</Diagnostics>
193+
```
194+
The log factory class is the built-in FoundationLogFactory. The configuration of this class is in the FoundationLogFactory xml element. The factory creates a file log writer. The log files will be written into the %TEMP% directory. One file per application start.
195+
196+

0 commit comments

Comments
 (0)