Repository navigation
Expand file tree
/
Copy pathDataPatternRendererAdapter.cs
More file actions
64 lines (54 loc) · 1.65 KB
/
Copy pathDataPatternRendererAdapter.cs
File metadata and controls
64 lines (54 loc) · 1.65 KB
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
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using SoftwarePatterns.Core.Adapter.Library;
namespace SoftwarePatterns.Core.Adapter
{
public class DataPatternRendererAdapter : IDataPatternRendererAdapter
{
public string ListPatterns(IEnumerable<Pattern> patterns)
{
var dataRenderer = new DataRenderer(new IEnumerableDbAdapter<Pattern>(patterns));
var writer = new StringWriter();
dataRenderer.Render(writer);
return writer.ToString();
}
internal class IEnumerableDbAdapter<T> : IDbDataAdapter
{
private readonly IEnumerable<T> collection;
public IEnumerableDbAdapter(IEnumerable<T> collection)
{
this.collection = collection;
}
public int Fill(DataSet dataSet)
{
var dataTable = collection.ToDataTable();
dataSet.Tables.Add(dataTable);
dataSet.AcceptChanges();
return collection.Count();
}
#region Not Implmented
public DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType)
{
throw new System.NotImplementedException();
}
public IDataParameter[] GetFillParameters()
{
throw new System.NotImplementedException();
}
public int Update(DataSet dataSet)
{
throw new System.NotImplementedException();
}
public MissingMappingAction MissingMappingAction { get; set; }
public MissingSchemaAction MissingSchemaAction { get; set; }
public ITableMappingCollection TableMappings { get; private set; }
public IDbCommand SelectCommand { get; set; }
public IDbCommand InsertCommand { get; set; }
public IDbCommand UpdateCommand { get; set; }
public IDbCommand DeleteCommand { get; set; }
#endregion
}
}
}